#NEWLINE# @ translate_volume_exception #NEWLINE# def initialize_connection( self , context , volume_id , connector ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# connection_info = cinderclient ( context ) . volumes . initialize_connection ( volume_id , connector ) #NEWLINE# connection_info [ 'connector' ] = connector #NEWLINE# return connection_info #NEWLINE# #UNINDENT# except cinder_exception . ClientException as ex : #NEWLINE# #INDENT# with excutils . save_and_reraise_exception ( ) : #NEWLINE# #INDENT# LOG . error ( _LE ( 'Initialize connection failed for volume %(vol)s on host %(host)s. Error: %(msg)s Code: %(code)s. Attempting to terminate connection.' ) , { #NEWLINE# #INDENT# 'vol' : volume_id , #NEWLINE# 'host' : connector . get ( 'host' ) , #NEWLINE# 'msg' : six . text_type ( ex ) , #NEWLINE# 'code' : ex . code , #NEWLINE# #UNINDENT# } ) #NEWLINE# try : #NEWLINE# #INDENT# self . terminate_connection ( context , volume_id , connector ) #NEWLINE# #UNINDENT# except Exception as exc : #NEWLINE# #INDENT# LOG . error ( _LE ( 'Connection between volume %(vol)s and host %(host)s might have succeeded, but attempt to terminate connection has failed. Validate the connection and determine if manual cleanup is needed. Error: %(msg)s Code: %(code)s.' ) , { #NEWLINE# #INDENT# 'vol' : volume_id , #NEWLINE# 'host' : connector . get ( 'host' ) , #NEWLINE# 'msg' : six . text_type ( exc ) , #NEWLINE# 'code' : exc . code , #NEWLINE# #UNINDENT# } )