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