Skip to content

Commit

Permalink
Merge pull request #8 from mfalesni/scvmm-failed-delete
Browse files Browse the repository at this point in the history
Also be able to delete VMs that failed to create
  • Loading branch information
psav committed Dec 14, 2015
2 parents ae331c1 + e3e5cc4 commit 02a4e1d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mgmtsystem/scvmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SCVMMSystem(MgmtSystemAPIBase):
STATE_PAUSED = "Paused"
STATES_STEADY = {STATE_RUNNING, STATE_PAUSED}
STATES_STEADY.update(STATES_STOPPED)
STATES_FAILED = {'Creation Failed'}

_stats_available = {
'num_vm': lambda self: len(self.list_vm()),
Expand Down Expand Up @@ -103,10 +104,11 @@ def create_vm(self, vm_name):
raise NotImplementedError('create_vm not implemented.')

def delete_vm(self, vm_name):
if not self.is_vm_stopped(vm_name):
if not self.is_vm_stopped(vm_name) and self.vm_status(vm_name) not in self.STATES_FAILED:
# Paused VM can be stopped too, so no special treatment here
self.stop_vm(vm_name)
self.wait_vm_stopped(vm_name)
# Now the VM is either stopped or in failed state which should be ok to delete
self._do_vm(vm_name, "Remove")

def restart_vm(self, vm_name):
Expand Down

0 comments on commit 02a4e1d

Please sign in to comment.