#NEWLINE# def api_request( self , relative_uri , check_response_status = None , strip_version = False , **kwargs ) : #NEWLINE# #INDENT# auth_result = self . _authenticate ( ) #NEWLINE# base_uri = auth_result [ 'x-server-management-url' ] #NEWLINE# if strip_version : #NEWLINE# #INDENT# base_uri = '/' . join ( base_uri . split ( '/' , 3 ) [ : ( - 1 ) ] ) #NEWLINE# #UNINDENT# full_uri = ( '%s/%s' % ( base_uri , relative_uri ) ) #NEWLINE# headers = kwargs . setdefault ( 'headers' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# headers [ 'X-Auth-Token' ] = headers [ 'x-auth-token' ] #NEWLINE# if self . microversion : #NEWLINE# #INDENT# headers [ 'X-OpenStack-Nova-API-Version' ] = self . microversion #NEWLINE# #UNINDENT# response = self . request ( full_uri , ** kwargs ) #NEWLINE# http_status = response . status_code #NEWLINE# LOG . debug ( '%(relative_uri)s => code %(http_status)s' , { #NEWLINE# #INDENT# 'relative_uri' : relative_uri , #NEWLINE# 'http_status' : http_status , #NEWLINE# #UNINDENT# } ) #NEWLINE# if check_response_status : #NEWLINE# #INDENT# if ( http_status not in check_response_status ) : #NEWLINE# #INDENT# if ( http_status == 404 ) : #NEWLINE# #INDENT# raise OpenStackApiNotFoundException ( response = response ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( http_status == 401 ) : #NEWLINE# #INDENT# raise OpenStackApiAuthorizationException ( response = response ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise OpenStackApiException ( message = 'Unexpected status code' , response = response ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return response