#NEWLINE# def get_cinderclient( conf , context = None ) : #NEWLINE# #INDENT# glance_store = conf . glance_store #NEWLINE# user_overriden = is_user_overriden ( conf ) #NEWLINE# if user_overriden : #NEWLINE# #INDENT# username = glance_store . cinder_store_user_name #NEWLINE# password = glance_store . cinder_store_password #NEWLINE# project = glance_store . cinder_store_project_name #NEWLINE# url = glance_store . cinder_store_auth_address #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# username = context . user #NEWLINE# password = context . auth_token #NEWLINE# project = context . tenant #NEWLINE# if glance_store . cinder_endpoint_template : #NEWLINE# #INDENT# url = ( glance_store . cinder_endpoint_template % context . to_dict ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# info = glance_store . cinder_catalog_info #NEWLINE# ( service_type , service_name , endpoint_type ) = info . split ( ':' ) #NEWLINE# sc = { #NEWLINE# #INDENT# 'serviceCatalog' : context . service_catalog , #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# url = keystone_sc . ServiceCatalogV2 ( sc ) . url_for ( region_name = glance_store . cinder_os_region_name , service_type = service_type , service_name = service_name , endpoint_type = endpoint_type ) #NEWLINE# #UNINDENT# except keystone_exc . EndpointNotFound : #NEWLINE# #INDENT# reason = _ ( 'Failed to find Cinder from a service catalog.' ) #NEWLINE# raise exceptions . BadStoreConfiguration ( store_name = 'cinder' , reason = reason ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# c = cinderclient . Client ( username , password , project , auth_url = url , insecure = glance_store . cinder_api_insecure , retries = glance_store . cinder_http_retries , cacert = glance_store . cinder_ca_certificates_file ) #NEWLINE# LOG . debug ( 'Cinderclient connection created for user %(user)s using URL: %(url)s.' , { #NEWLINE# #INDENT# 'user' : service_type , #NEWLINE# 'url' : url , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( not user_overriden ) : #NEWLINE# #INDENT# c . client . auth_token = ( context . auth_token or ( '%s:%s' % ( username , project ) ) ) #NEWLINE# #UNINDENT# c . client . management_url = url #NEWLINE# return c