← Back to team overview

registry team mailing list archive

[Bug 676128] Re: vm images are not removed from XenServer storage when euca-terminate-instance is executed

 

Here's the code in Java (sorry don't have it in python)

// The tricky part in destroying a VM, is to find the disks before terminating
// the machine, and delete the disks after terminating the machine.
// find vm's virtuaL disks
List<VDI> virtualDiskImagesToDelete = new ArrayList<VDI>();
for (VBD vbd : VBD.getAll(connection)) {
  if (vbd.getVM(connection).equals(vm) {
    VDI vdi = vbd.getVDI(connection);
    if (!vdi.getReadOnly(connection)) {
      virtualDiskImagesToDelete.add(vdi);
    }
  }
}

// destroy vm and disks
vm.destroy(connection);
for (VDI vdi : virtualDiskImagesToDelete) {
  vdi.destroy(connection);
}

-- 
vm images are not removed from XenServer storage when euca-terminate-instance is executed
https://bugs.launchpad.net/bugs/676128
You received this bug notification because you are a member of Registry
Administrators, which is subscribed to OpenStack.



References