Ondřej Svoboda has uploaded a new change for review.

Change subject: netinfo: Report bonding options as a dictionary of strings
......................................................................

netinfo: Report bonding options as a dictionary of strings

The values of bonding options are read from the kernel
as one or two strings. If there is only one string,
the value is actually numeric. If there are two,
the value is an enumeration, with a symbolic name in
the first string, a numeric code in the second string.

To simplify the API from the current state (reporting
the options as "raw" arrays of one or two strings),
the only value reported now is the number in both cases,
left in its textual representation.

A bond info dictionary is thus changed to (abriged):
'bond4': {
    'cfg': {'BONDING_OPTS': 'miimon=150 mode=3'},
    'options': {'miimon': '150', 'mode': '3'}
}

Change-Id: I1d29618c6d19d8c7f36fa674043488480dc346fb
Bug-Url: https://bugzilla.redhat.com/987813
Signed-off-by: Ondřej Svoboda <osvob...@redhat.com>
---
M lib/vdsm/netinfo.py
M tests/netinfoTests.py
M vdsm/rpc/vdsmapi-schema.json
3 files changed, 8 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/45/28845/1

diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py
index 812771a..9cf985a 100644
--- a/lib/vdsm/netinfo.py
+++ b/lib/vdsm/netinfo.py
@@ -589,7 +589,7 @@
     mode = opts['mode'][-1] if 'mode' in opts else None
     defaults = _getDefaultBondingOptions(mode)
 
-    return dict(((opt, val) for (opt, val) in opts.iteritems()
+    return dict(((opt, val[-1]) for (opt, val) in opts.iteritems()
                  if val and val != defaults.get(opt)))
 
 
@@ -599,7 +599,7 @@
     the order symbolic name, numeric value, e.g. 'balance-rr 0'.
     Choose the numeric value from a list given by bondOpts().
     """
-    return ' '.join((opt + '=' + val[-1] for (opt, val)
+    return ' '.join((opt + '=' + val for (opt, val)
                      in sorted(opts.iteritems())))
 
 
diff --git a/tests/netinfoTests.py b/tests/netinfoTests.py
index ff6e90e..dd90613 100644
--- a/tests/netinfoTests.py
+++ b/tests/netinfoTests.py
@@ -343,7 +343,7 @@
                     opt.write(INTERVAL)
 
                 self.assertEqual(_getBondingOptions(bondName),
-                                 {'miimon': [INTERVAL]})
+                                 {'miimon': INTERVAL})
 
             finally:
                 bonds.write('-' + bondName)
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index dd97594..2ccf963 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -600,7 +600,7 @@
 #
 # @qosOutbound: #optional BandwidthParams for outgoing traffic.
 #
-# @opts: A map containing information about the bridge specific options.
+# @opts:        A map containing information about the bridge specific options.
 #               (new in version 4.15.0)
 #
 # Since: 4.10.0
@@ -696,12 +696,15 @@
 #
 # @mtu:         The Maximum Transmission Unit size for the nic
 #
+# @opts:        A map of options; the values are numeric, but reported as
+#               strings (new in version 4.16.0)
+#
 # Since: 4.10.0
 ##
 {'type': 'NetInfoBond',
  'data': {'slaves': ['str'], 'addr': 'str', 'netmask': 'str',
           'ipv4addrs': ['str'], 'ipv6addrs': ['str'], 'hwaddr': 'str',
-          'cfg': 'StringMap', 'mtu': 'uint'}}
+          'cfg': 'StringMap', 'mtu': 'uint', 'opts': 'StringMap'}}
 
 ##
 # @NetInfoVlan:


-- 
To view, visit http://gerrit.ovirt.org/28845
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d29618c6d19d8c7f36fa674043488480dc346fb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <osvob...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to