Igor Lvovsky has uploaded a new change for review.

Change subject: NIC hotplug should fail if setPortMirroring failed
......................................................................

NIC hotplug should fail if setPortMirroring failed

Change-Id: If1b62fdec5f2c1a462283ff591d24e7b6f526f9e
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=867806
Signed-off-by: Igor Lvovsky <[email protected]>
---
M vdsm/libvirtvm.py
1 file changed, 19 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/42/8742/1

diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index 2b2b891..032159d 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -1450,7 +1450,7 @@
         nicParams = params.get('nic', {})
         nic = NetworkInterfaceDevice(self.conf, self.log, **nicParams)
         nicXml = nic.getXML().toprettyxml(encoding='utf-8')
-        self.log.debug("Hotplug NIC xml: %s" % (nicXml))
+        self.log.debug("Hotplug NIC xml: %s", nicXml)
 
         try:
             self._dom.attachDevice(nicXml)
@@ -1470,10 +1470,26 @@
             self.saveState()
             self._getUnderlyingNetworkInterfaceInfo()
 
+        mirroredNetworks = []
         if hasattr(nic, 'portMirroring'):
-            for network in nic.portMirroring:
-                supervdsm.getProxy().setPortMirroring(network, nic.name)
+            try:
+                for network in nic.portMirroring:
+                    supervdsm.getProxy().setPortMirroring(network, nic.name)
+                    mirroredNetworks.append(network)
+            # The better way would be catch the proper exception.
+            # One of such exceptions is TrafficControlException, but
+            # I am not sure that we'll get it for all traffic control errors.
+            # In any case we need below rollback for all kind of failures.
+            except Exception, e:
+                self.log.error("setPortMirroring for network %s failed",
+                                network, exc_info=True)
+                nicParams['portMirroring'] = mirroredNetworks
+                self.hotunplugNic({'nic': nicParams})
+                return {'status': \
+                        {'code': errCode['hotplugNic']['status']['code'],
+                         'message': e.message}}
 
+                
         return {'status': doneCode, 'vmList': self.status()}
 
     def hotunplugNic(self, params):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If1b62fdec5f2c1a462283ff591d24e7b6f526f9e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Igor Lvovsky <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to