Change in vdsm[master]: undo the change in vdsm-restore and incorporate it into setu...

ibarkan at redhat.com ibarkan at redhat.com
Wed Nov 18 10:52:42 UTC 2015


Ido Barkan has uploaded a new change for review.

Change subject: undo the change in vdsm-restore and incorporate it into setupNetworks
......................................................................

undo the change in vdsm-restore and incorporate it into setupNetworks

Change-Id: If9afffad0699683e7b373355d640f4dc0d85fd75
Signed-off-by: Ido Barkan <ibarkan at redhat.com>
---
M vdsm/network/api.py
M vdsm/vdsm-restore-net-config
2 files changed, 54 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/25/48725/1

diff --git a/vdsm/network/api.py b/vdsm/network/api.py
index 4ed64f3..dda67a6 100755
--- a/vdsm/network/api.py
+++ b/vdsm/network/api.py
@@ -669,8 +669,14 @@
                                     attrs.get('nics'), mtu=None,
                                     _netinfo=_netinfo,
                                     destroyOnMasterRemoval='remove' in attrs)
-            bond.remove()
-            del _netinfo.bondings[name]
+            try:
+                bond.remove()
+                del _netinfo.bondings[name]
+            except:
+                if in_rollback:
+                    pass
+                else:
+                    raise
         elif name in _netinfo.bondings:
             edition.append((name, attrs))
         else:
@@ -684,7 +690,13 @@
             raise ConfigNetworkError(ne.ERR_BAD_PARAMS, 'Missing required nics'
                                      ' for bonding device.')
         logger.debug("Editing bond %r with options %s", bond, bond.options)
-        configurator.editBonding(bond, _netinfo)
+        try:
+            configurator.editBonding(bond, _netinfo)
+        except:
+            if in_rollback:
+                pass
+            else:
+                raise
     for name, attrs in addition:
         bond = Bond.objectivize(name, configurator, attrs.get('options'),
                                 attrs.get('nics'), mtu=None, _netinfo=_netinfo,
@@ -693,7 +705,13 @@
             raise ConfigNetworkError(ne.ERR_BAD_PARAMS, 'Missing required nics'
                                      ' for bonding device.')
         logger.debug("Creating bond %r with options %s", bond, bond.options)
-        configurator.configureBond(bond)
+        try:
+            configurator.configureBond(bond)
+        except:
+            if in_rollback:
+                pass
+            else:
+                raise
 
 
 def _buildBondOptions(bondName, bondings, _netinfo):
@@ -752,7 +770,7 @@
 
 
 def _add_missing_networks(configurator, networks, bondings, force, logger,
-                          _netinfo=None):
+                          in_rollback, _netinfo=None):
     # We need to use the newest host info
     if _netinfo is None:
         _netinfo = netinfo.NetInfo()
@@ -780,7 +798,10 @@
                              "orphan-devices cleanup", network)
                 _emergencyNetworkCleanup(network, attrs,
                                          configurator)
-            raise
+            if in_rollback:
+                pass
+            else:
+                raise
 
         _netinfo.updateDevices()  # Things like a bond mtu can change
 
@@ -920,20 +941,31 @@
                     currently_bridged=_netinfo.networks[network]['bridged'],
                     net_kernel_config=kernel_config.networks[network]
                 )
-
-                _delNetwork(network, configurator=configurator, force=force,
-                            implicitBonding=False, _netinfo=_netinfo,
-                            keep_bridge=keep_bridge)
-                del _netinfo.networks[network]
-                _netinfo.updateDevices()
+                try:
+                    _delNetwork(network, configurator=configurator,
+                                force=force, implicitBonding=False,
+                                _netinfo=_netinfo, keep_bridge=keep_bridge)
+                    del _netinfo.networks[network]
+                    _netinfo.updateDevices()
+                except:
+                    if in_rollback:
+                        pass
+                    else:
+                        raise
             elif network in libvirt_nets:
                 # If the network was not in _netinfo but is in the networks
                 # returned by libvirt, it means that we are dealing with
                 # a broken network.
-                logger.debug('Removing broken network %r', network)
-                _delBrokenNetwork(network, libvirt_nets[network],
-                                  configurator=configurator)
-                _netinfo.updateDevices()
+                try:
+                    logger.debug('Removing broken network %r', network)
+                    _delBrokenNetwork(network, libvirt_nets[network],
+                                      configurator=configurator)
+                    _netinfo.updateDevices()
+                except:
+                    if in_rollback:
+                        pass
+                    else:
+                        raise
             elif 'remove' in attrs:
                 raise ConfigNetworkError(ne.ERR_BAD_BRIDGE, "Cannot delete "
                                          "network %r: It doesn't exist in the "
@@ -944,7 +976,7 @@
         _handleBondings(bondings, configurator, in_rollback)
 
         _add_missing_networks(configurator, networks, bondings, force,
-                              logger, _netinfo)
+                              logger, in_rollback, _netinfo)
 
         _check_connectivity(connectivity_check_networks, networks, bondings,
                             options, logger)
diff --git a/vdsm/vdsm-restore-net-config b/vdsm/vdsm-restore-net-config
index bc63485..1dab8bf 100755
--- a/vdsm/vdsm-restore-net-config
+++ b/vdsm/vdsm-restore-net-config
@@ -123,44 +123,11 @@
     changed_config = _filter_changed_nets_bonds(available_config)
     nets = changed_config.networks
     bonds = changed_config.bonds
-    _convert_to_blocking_dhcp(nets)
-    failed_bonds, failed_nets = _try_setup_networks(bonds, nets)
-    _update_running_config_with_failures(failed_bonds, failed_nets)
-
-
-def _try_setup_networks(bonds, nets):
-    failed_bonds = []
-    failed_nets = []
-    for bond, bond_attr in bonds.iteritems():
-        logging.debug('Calling setupNetworks with {%s:%s}', bond, bond_attr)
-        try:
-            setupNetworks({}, {bond: bond_attr}, connectivityCheck=False,
-                          _inRollback=True)
-        except:
-            logging.error('failed to setup bond %s. proceeding with '
-                          'restoration', bond)
-            failed_bonds.append(bond)
-
-    for net, net_attr in nets.iteritems():
-        logging.debug('Calling setupNetworks with {%s:%s}', net, net_attr)
-        try:
-            setupNetworks({net: net_attr}, {}, connectivityCheck=False,
-                          _inRollback=True)
-        except:
-            logging.error('failed to setup network %s. proceeding with '
-                          'restoration', net)
-            failed_nets.append(net)
-
-    return failed_bonds, failed_nets
-
-
-def _update_running_config_with_failures(failed_bonds, failed_nets):
-    running_config = RunningConfig()
-    for net in failed_nets:
-        running_config.removeNetwork(net)
-    for bond in failed_bonds:
-        running_config.removeBonding(bond)
-    running_config.save()
+    if nets or bonds:
+        _convert_to_blocking_dhcp(nets)
+        logging.debug('Calling setupNetworks with networks (%s) '
+                      'and bond (%s).', nets, bonds)
+        setupNetworks(nets, bonds, connectivityCheck=False, _inRollback=True)
 
 
 def _verify_all_devices_are_up(owned_ifcfg_files):


-- 
To view, visit https://gerrit.ovirt.org/48725
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If9afffad0699683e7b373355d640f4dc0d85fd75
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ido Barkan <ibarkan at redhat.com>


More information about the vdsm-patches mailing list