Python binding for libvirt does not support conn.changeBegin() and
conn.commit(). To make the change safe, this procedure was changed to a
internal framework: RollbackContext.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
src/kimchi/model.py | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/kimchi/model.py b/src/kimchi/model.py
index 81c1507..a2f5634 100644
--- a/src/kimchi/model.py
+++ b/src/kimchi/model.py
@@ -951,16 +951,17 @@ class Model(object):
br_xml = networkxml.create_vlan_tagged_bridge_xml(br_name, interface,
vlan_id)
conn = self.conn.get()
- conn.changeBegin()
- try:
- vlan_tagged_br = conn.interfaceDefineXML(br_xml)
- vlan_tagged_br.create()
- except libvirt.libvirtError as e:
- conn.changeRollback()
- raise OperationFailed(e.message)
- else:
- conn.changeCommit()
- return br_name
+
+ with RollbackContext() as rollback:
+
+ try:
+ vlan_tagged_br = conn.interfaceDefineXML(br_xml)
+ vlan_tagged_br.create()
+ except libvirt.libvirtError as e:
+ raise OperationFailed(e.message)
+ rollback.prependDefer(vlan_tagged_br.destroy)
+ else:
+ return br_name
def _remove_vlan_tagged_bridge(self, network):
try:
--
1.8.3.1