Fix some bugs
This commit is contained in:
		@@ -72,8 +72,8 @@ def node_flush(node, wait):
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    zk_conn = pvc_common.startZKConnection(zk_host)
 | 
					    zk_conn = pvc_common.startZKConnection(zk_host)
 | 
				
			||||||
    retstate, retmsg = pvc_node.flush_node(zk_conn, node, wait)
 | 
					    retcode, retmsg = pvc_node.flush_node(zk_conn, node, wait)
 | 
				
			||||||
    cleanup(retstate, retmsg, zk_conn)
 | 
					    cleanup(retcode, retmsg, zk_conn)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
###############################################################################
 | 
					###############################################################################
 | 
				
			||||||
# pvc node ready/unflush
 | 
					# pvc node ready/unflush
 | 
				
			||||||
@@ -88,8 +88,8 @@ def node_ready(node):
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    zk_conn = pvc_common.startZKConnection(zk_host)
 | 
					    zk_conn = pvc_common.startZKConnection(zk_host)
 | 
				
			||||||
    retstate, retmsg = pvc_node.ready_node(zk_conn, node)
 | 
					    retcode, retmsg = pvc_node.ready_node(zk_conn, node)
 | 
				
			||||||
    cleanup(retstate, retcode, zk_conn)
 | 
					    cleanup(retcode, retmsg, zk_conn)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@click.command(name='unflush', short_help='Restore node to service.')
 | 
					@click.command(name='unflush', short_help='Restore node to service.')
 | 
				
			||||||
@click.argument(
 | 
					@click.argument(
 | 
				
			||||||
@@ -101,8 +101,8 @@ def node_unflush(node):
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    zk_conn = pvc_common.startZKConnection(zk_host)
 | 
					    zk_conn = pvc_common.startZKConnection(zk_host)
 | 
				
			||||||
    retstate, retmsg = pvc_node.ready_node(zk_conn, node)
 | 
					    retcode, retmsg = pvc_node.ready_node(zk_conn, node)
 | 
				
			||||||
    cleanup(retstate, retcode, zk_conn)
 | 
					    cleanup(retcode, retmsg, zk_conn)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
###############################################################################
 | 
					###############################################################################
 | 
				
			||||||
# pvc node info
 | 
					# pvc node info
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -170,9 +170,9 @@ def getDomainControllers(parsed_xml):
 | 
				
			|||||||
def verifyNode(zk_conn, node):
 | 
					def verifyNode(zk_conn, node):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        zk_conn.get('/nodes/{}'.format(node))
 | 
					        zk_conn.get('/nodes/{}'.format(node))
 | 
				
			||||||
 | 
					        return True
 | 
				
			||||||
    except:
 | 
					    except:
 | 
				
			||||||
        click.echo('ERROR: No node named "{}" is present in the cluster.'.format(node))
 | 
					        return False
 | 
				
			||||||
        exit(1)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Get the list of valid target hypervisors
 | 
					# Get the list of valid target hypervisors
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -106,7 +106,8 @@ def getInformationFromNode(zk_conn, node_name, long_output):
 | 
				
			|||||||
#
 | 
					#
 | 
				
			||||||
def flush_node(zk_conn, node, wait):
 | 
					def flush_node(zk_conn, node, wait):
 | 
				
			||||||
    # Verify node is valid
 | 
					    # Verify node is valid
 | 
				
			||||||
    common.verifyNode(zk_conn, node)
 | 
					    if not common.verifyNode(zk_conn, node):
 | 
				
			||||||
 | 
					        return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    click.echo('Flushing hypervisor {} of running VMs.'.format(node))
 | 
					    click.echo('Flushing hypervisor {} of running VMs.'.format(node))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -126,7 +127,8 @@ def flush_node(zk_conn, node, wait):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def ready_node(zk_conn, node):
 | 
					def ready_node(zk_conn, node):
 | 
				
			||||||
    # Verify node is valid
 | 
					    # Verify node is valid
 | 
				
			||||||
    common.verifyNode(zk_conn, node)
 | 
					    if not common.verifyNode(zk_conn, node):
 | 
				
			||||||
 | 
					        return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    click.echo('Restoring hypervisor {} to active service.'.format(node))
 | 
					    click.echo('Restoring hypervisor {} to active service.'.format(node))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -139,7 +141,8 @@ def ready_node(zk_conn, node):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def get_info(zk_conn, node, long_output):
 | 
					def get_info(zk_conn, node, long_output):
 | 
				
			||||||
    # Verify node is valid
 | 
					    # Verify node is valid
 | 
				
			||||||
    common.verifyNode(zk_conn, node)
 | 
					    if not common.verifyNode(zk_conn, node):
 | 
				
			||||||
 | 
					        return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Get information about node in a pretty format
 | 
					    # Get information about node in a pretty format
 | 
				
			||||||
    information = getInformationFromNode(zk_conn, node, long_output)
 | 
					    information = getInformationFromNode(zk_conn, node, long_output)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user