Change in vdsm[master]: network: Reset bonding options we did not modify to defaults...

osvoboda at redhat.com osvoboda at redhat.com
Wed Apr 2 16:46:28 UTC 2014


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

Change subject: network: Reset bonding options we did not modify to defaults (WIP)
......................................................................

network: Reset bonding options we did not modify to defaults (WIP)

This is an attempt to have bonds configured with exactly
the options that were requested.

The handling of mode 4 options (if they are options at all?)
is yet to be investigated. I suspect the also belong to the set
of run-time values we should not even report as bonding options.

Change-Id: I884b7436e12df9dc8572694f886a3c7eb32de200
Bug-Url: https://bugzilla.redhat.com/987813
Signed-off-by: Ondřej Svoboda <osvoboda at redhat.com>
---
M vdsm/network/models.py
1 file changed, 37 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/74/26374/1

diff --git a/vdsm/network/models.py b/vdsm/network/models.py
index ced0a30..a44c24c 100644
--- a/vdsm/network/models.py
+++ b/vdsm/network/models.py
@@ -190,6 +190,41 @@
     def __repr__(self):
         return 'Bond(%s: %r)' % (self.name, self.slaves)
 
+    def _confOptions(self):
+        return [option.split('=', 1) for option in self.options.split(' ')]
+
+    def replaceCurrentOptsWithDefaults(self):
+        '''
+        Any active non-default value not touched by options being currently
+        set is added so it is explicitly reset to its default.
+
+        This is intended to make sure no other options than those we modified
+        have non-default values.
+        '''
+        activeOpts = netinfo._getBondingOptions(self.name)
+
+        defaults, defaultMode = netinfo._getDefaultBondingOptions()
+        mode = (activeOpts['mode'][-1] if 'mode' in activeOpts
+                else defaultMode[-1])
+        defaults = defaults[mode]
+
+        confOpts = dict(self._confOptions())
+
+        for key in activeOpts:
+            if key not in confOpts:
+                logging.error('Clearing pre-existing non-default %s option'
+                              ' (%s=%s)', self.name, key, activeOpts[key])
+
+                if key in defaults:
+                    activeOpts[key] = defaults[key][-1]
+                else:
+                    logging.error('No default value found! '
+                                  'The mode is %s.', mode)
+                    activeOpts[key] = ''
+
+        activeOpts.update(confOpts)
+        return netinfo._bondOptsForIfcfg(activeOpts)
+
     def configure(self, **opts):
         # When the bond is up and we are not changing the configuration that
         # is already applied in any way, we can skip the configuring.
@@ -203,10 +238,11 @@
                 frozenset(netinfo.slaves(self.name))):
                 return
 
+        self.options = self.resetUnwantedOptions()
         self.configurator.configureBond(self, **opts)
 
     def areOptionsApplied(self):
-        confOpts = [option.split('=', 1) for option in self.options.split(' ')]
+        confOpts = self._confOpts()
         activeOpts = netinfo.bondOpts(self.name,
                                       (name for name, value in confOpts))
         return all(value in activeOpts[name] for name, value in confOpts)


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I884b7436e12df9dc8572694f886a3c7eb32de200
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <osvoboda at redhat.com>


More information about the vdsm-patches mailing list