#NEWLINE# def _v1_auth( self , token_url ) : #NEWLINE# #INDENT# creds = resp_body . creds #NEWLINE# headers = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# headers [ 'X-Auth-User' ] = creds [ 'username' ] #NEWLINE# headers [ 'X-Auth-Key' ] = creds [ 'password' ] #NEWLINE# tenant = creds . get ( 'tenant' ) #NEWLINE# if tenant : #NEWLINE# #INDENT# headers [ 'X-Auth-Tenant' ] = tenant #NEWLINE# #UNINDENT# ( resp , resp_body ) = self . _do_request ( token_url , 'GET' , headers = headers ) #NEWLINE# def _management_url( self , resp ) : #NEWLINE# #INDENT# for url_header in ( 'x-image-management-url' , 'x-server-management-url' , 'x-glance' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return resp [ url_header ] #NEWLINE# #UNINDENT# except KeyError as e : #NEWLINE# #INDENT# not_found = e #NEWLINE# #UNINDENT# #UNINDENT# raise not_found #NEWLINE# #UNINDENT# if ( resp . status in ( 200 , 204 ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . management_url = _management_url ( self , resp ) #NEWLINE# self . auth_token = resp [ 'x-auth-token' ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise exception . AuthorizationFailure ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( resp . status == 305 ) : #NEWLINE# #INDENT# raise exception . AuthorizationRedirect ( resp [ 'location' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( resp . status == 400 ) : #NEWLINE# #INDENT# raise exception . AuthBadRequest ( url = token_url ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( resp . status == 401 ) : #NEWLINE# #INDENT# raise exception . NotAuthorized ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( resp . status == 404 ) : #NEWLINE# #INDENT# raise exception . AuthUrlNotFound ( url = token_url ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( _ ( ( 'Unexpected response: %s' % resp . status ) ) )