Xenserver 5.5 Api Cheat Sheet Page 4

ADVERTISEMENT

Destroy machine and its virtual disk
// 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);
}

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 4