[PATCH] Bug fix #309 - network: Unable to create vlan tagged on Ubuntu v2

Changes: v1: Put the rollback function above the raise, unless, the line will never run. Ramon Medeiros (1): Bug fix #309 - network: Unable to create vlan tagged on Ubuntu src/kimchi/model.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) -- 1.8.3.1

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.:wq! Signed-off-by: Ramon Medeiros <ramonn@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..e36b485 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: + rollback.prependDefer(vlan_tagged_br.destroy) + raise OperationFailed(e.message) + else: + return br_name def _remove_vlan_tagged_bridge(self, network): try: -- 1.8.3.1

Am 29-01-2014 16:53, schrieb Ramon Medeiros:
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.:wq! It looks like you use vim... :-)

On 01/29/2014 04:58 PM, Crístian Viana wrote:
Am 29-01-2014 16:53, schrieb Ramon Medeiros:
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.:wq! It looks like you use vim... :-) Sorry for my hurry!
-- Ramon Nunes Medeiros Software Engineer - Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com

On 01/29/2014 04:53 PM, Ramon Medeiros wrote:
Changes:
v1: Put the rollback function above the raise, unless, the line will never run.
Ramon Medeiros (1): Bug fix #309 - network: Unable to create vlan tagged on Ubuntu
src/kimchi/model.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
Ramon, could you resend it based on refator model patches?
participants (3)
-
Aline Manera
-
Crístian Viana
-
Ramon Medeiros