Don't try to stop a stopped VM when undefining
This commit is contained in:
parent
3851069b7a
commit
e4fd4f858c
4
pvc.py
4
pvc.py
|
@ -205,11 +205,13 @@ def undefine_vm(dom_name, dom_uuid):
|
|||
click.echo('ERROR: Could not find VM "{}" in the cluster!'.format(message_name))
|
||||
return
|
||||
|
||||
current_vm_state = zk.get('/domains/{}/state'.format(dom_uuid))[0].decode('ascii')
|
||||
if current_vm_state != 'stop':
|
||||
click.echo('Forcibly stopping VM "{}".'.format(dom_uuid))
|
||||
# Set the domain into stop mode
|
||||
transaction = zk.transaction()
|
||||
transaction.set_data('/domains/{}/state'.format(dom_uuid), 'stop'.encode('ascii'))
|
||||
results = transaction.commit()
|
||||
transaction.commit()
|
||||
|
||||
# Wait for 3 seconds to allow state to flow to all hypervisors
|
||||
click.echo('Waiting for cluster to update.')
|
||||
|
|
Loading…
Reference in New Issue