Add verification and output text to flush/ready commands
This commit is contained in:
		
							
								
								
									
										18
									
								
								pvc.py
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								pvc.py
									
									
									
									
									
								
							| @@ -66,6 +66,15 @@ def flush_host(node_name): | |||||||
|     # Open a Zookeeper connection |     # Open a Zookeeper connection | ||||||
|     zk = pvcf.startZKConnection(zk_host) |     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 |     # Add the new domain to Zookeeper | ||||||
|     transaction = zk.transaction() |     transaction = zk.transaction() | ||||||
|     transaction.set_data('/nodes/{}/state'.format(node_name), 'flush'.encode('ascii')) |     transaction.set_data('/nodes/{}/state'.format(node_name), 'flush'.encode('ascii')) | ||||||
| @@ -95,6 +104,15 @@ def ready_host(node_name): | |||||||
|     # Open a Zookeeper connection |     # Open a Zookeeper connection | ||||||
|     zk = pvcf.startZKConnection(zk_host) |     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 |     # Add the new domain to Zookeeper | ||||||
|     transaction = zk.transaction() |     transaction = zk.transaction() | ||||||
|     transaction.set_data('/nodes/{}/state'.format(node_name), 'unflush'.encode('ascii')) |     transaction.set_data('/nodes/{}/state'.format(node_name), 'unflush'.encode('ascii')) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user