[Kimchi-devel] [PATCH] issue #429: Properly set rollback function when creating vlan tagged bridged

Aline Manera alinefm at linux.vnet.ibm.com
Mon Sep 22 19:45:42 UTC 2014


The rollback function must be defined right after the action.
It is not linked to the exception raised.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 src/kimchi/model/networks.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/kimchi/model/networks.py b/src/kimchi/model/networks.py
index 73e7ace..0ea9449 100644
--- a/src/kimchi/model/networks.py
+++ b/src/kimchi/model/networks.py
@@ -216,12 +216,11 @@ class NetworksModel(object):
                                                    'err': error_msg})
 
         with RollbackContext() as rollback:
-
             try:
                 vlan_tagged_br = conn.interfaceDefineXML(br_xml, 0)
+                rollback.prependDefer(vlan_tagged_br.destroy)
                 vlan_tagged_br.create(0)
             except libvirt.libvirtError as e:
-                rollback.prependDefer(vlan_tagged_br.destroy)
                 raise OperationFailed(e.message)
             else:
                 return br_name
-- 
1.9.3




More information about the Kimchi-devel mailing list