Skip to content

Commit 1bf9da9

Browse files
ydirsonglehmann
authored andcommitted
BaseVM: move implementation to VM
mypy will complain not finding _destroy in BaseVM once we add typing hints. `Snapshot` and `VM` have had different implementations because of vm-uninstall vs snapshot-uninstall, and diverged further because of xapi-project/xen-api#4145. The code in `BaseVM.destroy` is specific to this issue's workaround for VM and has no reason to be there. This corrects the situation, and moves the comment about the xapi issue to a better place. Signed-off-by: Yann Dirson <[email protected]>
1 parent 714c930 commit 1bf9da9

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

lib/basevm.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ def vdi_uuids(self, sr_uuid=None):
6464
def destroy_vdi(self, vdi_uuid: str) -> None:
6565
self.host.xe('vdi-destroy', {'uuid': vdi_uuid})
6666

67-
# FIXME: move this method and the above back to class VM if not useful in Snapshot class?
68-
def destroy(self):
69-
for vdi_uuid in self.vdi_uuids():
70-
self.destroy_vdi(vdi_uuid)
71-
self._destroy()
72-
7367
def all_vdis_on_host(self, host):
7468
for vdi_uuid in self.vdi_uuids():
7569
sr = SR(self.host.pool.get_vdi_sr_uuid(vdi_uuid), self.host.pool)

lib/vm.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,16 @@ def unpause(self):
161161
def _disk_list(self):
162162
return self.host.xe('vm-disk-list', {'uuid': self.uuid, 'vbd-params': ''}, minimal=True)
163163

164-
def _destroy(self):
165-
self.host.xe('vm-destroy', {'uuid': self.uuid})
166-
167164
def destroy(self, verify=False):
168-
# Note: not using xe vm-uninstall (which would be convenient) because it leaves a VDI behind
169-
# See https://github.com/xapi-project/xen-api/issues/4145
170165
if not self.is_halted():
171166
self.shutdown(force=True)
172-
super().destroy()
167+
168+
# Note: not using xe vm-uninstall (which would be convenient) because it leaves a VDI behind
169+
# See https://github.com/xapi-project/xen-api/issues/4145
170+
for vdi_uuid in self.vdi_uuids():
171+
self.destroy_vdi(vdi_uuid)
172+
self.host.xe('vm-destroy', {'uuid': self.uuid})
173+
173174
if verify:
174175
wait_for_not(self.exists, "Wait for VM destroyed")
175176

0 commit comments

Comments
 (0)