<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Am 27-02-2014 14:29, schrieb Aline Manera:<br>
<blockquote cite="mid:530F75DC.7030203@linux.vnet.ibm.com"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
Even using UUID, the rollback problem will still exist.<br>
</blockquote>
<br>
Using UUID would be enough.<br>
<br>
Take a look at the code:<br>
<br>
<tt>with RollbackContext() as rollback:</tt><tt><br>
</tt><tt> params = {'name': u'test', 'disks': []}</tt><tt><br>
</tt><tt> inst.templates_create(params)</tt><tt><br>
</tt><tt> rollback.prependDefer(inst.template_delete, 'test')</tt><tt><br>
</tt><tt><br>
</tt><tt> params = {'name': u'kīмсhī-∨м', 'template':
u'/templates/test'}</tt><tt><br>
</tt><tt> inst.vms_create(params)</tt><tt><br>
</tt><b><tt> rollback.prependDefer(self._rollback_wrapper,
inst.vm_delete,</tt></b><b><tt><br>
</tt></b><b><tt> u'kīмсhī-∨м')</tt></b><tt><br>
</tt><tt><br>
</tt><tt> inst.vm_start(u'kīмсhī-∨м')</tt><tt><br>
</tt><b><tt> rollback.prependDefer(self._rollback_wrapper,
inst.vm_stop,</tt></b><b><tt><br>
</tt></b><b><tt> u'kīмсhī-∨м')</tt></b><tt><br>
</tt><tt><br>
</tt><tt> inst.vm_delete(u'kīмсhī-∨м')</tt><tt><br>
</tt><tt><br>
</tt><tt> vms = inst.vms_get_list()</tt><tt><br>
</tt><tt> self.assertFalse(u'kīмсhī-∨м' in vms)</tt><br>
<br>
Suppose the two lines defer commands like
"inst.vm_delete_by_uuid(uuid)". Even if something fails, if the VMs'
names change, or if everything executes successfully, they would
stop and delete the VM in the end of the transaction.<br>
<br>
By the way, the command "inst.vm_delete(u'kīмсhī-∨м')" will delete
the VM and will obviously lead to an error when the deferred
"vm_delete" is executed, because the VM will not exist anymore.<br>
</body>
</html>