#NEWLINE# def get_nova_client( auth_token = None , bypass_url = None , previous_tries = 0 ) : #NEWLINE# #INDENT# if ( previous_tries > 3 ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# auth_ref = get_auth_ref ( ) #NEWLINE# auth_details = get_auth_details ( ) #NEWLINE# keystone = get_keystone_client ( auth_ref ) #NEWLINE# if ( not auth_token ) : #NEWLINE# #INDENT# auth_token = keystone . auth_token #NEWLINE# #UNINDENT# if ( not bypass_url ) : #NEWLINE# #INDENT# bypass_url = get_endpoint_url_for_service ( 'compute' , auth_ref , get_endpoint_type ( auth_details ) ) #NEWLINE# #UNINDENT# nova = nova_client . Client ( '2' , auth_token = auth_token , bypass_url = bypass_url , insecure = auth_details [ 'OS_API_INSECURE' ] ) #NEWLINE# try : #NEWLINE# #INDENT# flavors = nova . flavors . list ( ) #NEWLINE# [ flavor . id for flavor in flavors ] #NEWLINE# #UNINDENT# except ( nova_exc . Unauthorized , nova_exc . AuthorizationFailure , AttributeError ) as e : #NEWLINE# #INDENT# auth_ref = force_reauth ( ) #NEWLINE# keystone = get_keystone_client ( auth_ref ) #NEWLINE# auth_token = keystone . auth_token #NEWLINE# nova = get_nova_client ( auth_token , bypass_url , ( previous_tries + 1 ) ) #NEWLINE# #UNINDENT# except nova_exc . ClientException : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# status_err ( str ( e ) ) #NEWLINE# #UNINDENT# return nova