Am 27-02-2014 14:29, schrieb Aline Manera:
Even using UUID, the rollback problem will still exist.

Using UUID would be enough.

Take a look at the code:

with RollbackContext() as rollback:
    params = {'name': u'test', 'disks': []}
    inst.templates_create(params)
    rollback.prependDefer(inst.template_delete, 'test')

    params = {'name': u'kīмсhī-∨м', 'template': u'/templates/test'}
    inst.vms_create(params)
    rollback.prependDefer(self._rollback_wrapper, inst.vm_delete,
                          u'kīмсhī-∨м')

    inst.vm_start(u'kīмсhī-∨м')
    rollback.prependDefer(self._rollback_wrapper, inst.vm_stop,
                          u'kīмсhī-∨м')

    inst.vm_delete(u'kīмсhī-∨м')

    vms = inst.vms_get_list()
    self.assertFalse(u'kīмсhī-∨м' in vms)

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.

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.