Add verification and output text to flush/ready commands

This commit is contained in:
Joshua Boniface 2018-06-11 02:15:46 -04:00
parent fa423bbfe7
commit 33b6b46935
1 changed files with 18 additions and 0 deletions

18
pvc.py
View File

@ -66,6 +66,15 @@ def flush_host(node_name):
# Open a Zookeeper connection
zk = pvcf.startZKConnection(zk_host)
# Verify node is valid
try:
zk.get('/nodes/{}'.format(node_name)
except:
click.echo('ERROR: No node named {} is present in the cluster.'.format(node_name))
exit(1)
click.echo('Flushing hypervisor {} of running VMs.'.format(node_name)
# Add the new domain to Zookeeper
transaction = zk.transaction()
transaction.set_data('/nodes/{}/state'.format(node_name), 'flush'.encode('ascii'))
@ -95,6 +104,15 @@ def ready_host(node_name):
# Open a Zookeeper connection
zk = pvcf.startZKConnection(zk_host)
# Verify node is valid
try:
zk.get('/nodes/{}'.format(node_name)
except:
click.echo('ERROR: No node named {} is present in the cluster.'.format(node_name))
exit(1)
click.echo('Restoring hypervisor {} to active service.'.format(node_name)
# Add the new domain to Zookeeper
transaction = zk.transaction()
transaction.set_data('/nodes/{}/state'.format(node_name), 'unflush'.encode('ascii'))