#NEWLINE# def _get_hosts_name_for_node( ssh_obj , driver_info ) : #NEWLINE# #INDENT# 'Get the name the host uses to reference the node.\n\n    :param ssh_obj: paramiko.SSHClient, an active ssh connection.\n    :param driver_info: information for accessing the node.\n    :returns: the name of the node.\n    :raises: NodeNotFound if could not find a VM corresponding to any of\n        the provided MACs\n\n    ' #NEWLINE# @ retrying . retry ( retry_on_result = ( lambda v : ( v is None ) ) , retry_on_exception = ( lambda _ : False ) , stop_max_attempt_number = CONF . ssh . get_vm_name_attempts , wait_fixed = ( CONF . ssh . get_vm_name_retry_interval * 1000 ) ) #NEWLINE# def _with_retries( ) : #NEWLINE# #INDENT# matched_name = None #NEWLINE# cmd_to_exec = ( '%s %s' % ( driver_info [ 'cmd_set' ] [ 'base_cmd' ] , driver_info [ 'cmd_set' ] [ 'list_all' ] ) ) #NEWLINE# full_node_list = _ssh_execute ( ssh_obj , cmd_to_exec ) #NEWLINE# LOG . debug ( ( 'Retrieved Node List: %s' % repr ( full_node_list ) ) ) #NEWLINE# for node in full_node_list : #NEWLINE# #INDENT# if ( not node ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# LOG . debug ( ( "Checking Node: %s's Mac address." % node ) ) #NEWLINE# cmd_to_exec = ( '%s %s' % ( driver_info [ 'cmd_set' ] [ 'base_cmd' ] , driver_info [ 'cmd_set' ] [ 'get_node_macs' ] ) ) #NEWLINE# cmd_to_exec = cmd_to_exec . replace ( '{_NodeName_}' , node ) #NEWLINE# hosts_node_mac_list = _ssh_execute ( ssh_obj , cmd_to_exec ) #NEWLINE# for host_mac in hosts_node_mac_list : #NEWLINE# #INDENT# if ( not host_mac ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# for node_mac in driver_info [ 'macs' ] : #NEWLINE# #INDENT# if ( driver_utils . normalize_mac ( host_mac ) in driver_utils . normalize_mac ( node_mac ) ) : #NEWLINE# #INDENT# LOG . debug ( ( 'Found Mac address: %s' % node_mac ) ) #NEWLINE# matched_name = node #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if matched_name : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# if matched_name : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# return matched_name #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return _with_retries ( ) #NEWLINE# #UNINDENT# except retrying . RetryError : #NEWLINE# #INDENT# raise exception . NodeNotFound ( ( _ ( 'SSH driver was not able to find a VM with any of the specified MACs: %(macs)s for node %(node)s.' ) % { #NEWLINE# #INDENT# 'macs' : driver_info [ 'macs' ] , #NEWLINE# 'node' : driver_info [ 'uuid' ] , #NEWLINE# #UNINDENT# } ) )