From 33b6b46935cef454b3fb2ef7e8d19cc63e865b11 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Mon, 11 Jun 2018 02:15:46 -0400 Subject: [PATCH] Add verification and output text to flush/ready commands --- pvc.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pvc.py b/pvc.py index c8b3fc73..8e89cb89 100755 --- a/pvc.py +++ b/pvc.py @@ -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'))