#NEWLINE# def find_secret( self , usage_type , usage_id ) : #NEWLINE# #INDENT# "Find a secret.\n\n        usage_type: one of 'iscsi', 'ceph', 'rbd' or 'volume'\n        usage_id: name of resource in secret\n        " #NEWLINE# if ( usage_type == 'iscsi' ) : #NEWLINE# #INDENT# usage_type_const = libvirt . VIR_SECRET_USAGE_TYPE_ISCSI #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( usage_type in ( 'rbd' , 'ceph' ) ) : #NEWLINE# #INDENT# usage_type_const = libvirt . VIR_SECRET_USAGE_TYPE_CEPH #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( e == 'volume' ) : #NEWLINE# #INDENT# usage_type_const = libvirt . VIR_SECRET_USAGE_TYPE_VOLUME #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# msg = _ ( 'Invalid usage_type: %s' ) #NEWLINE# raise exception . NovaException ( ( msg % usage_type ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# conn = self . get_connection ( ) #NEWLINE# return conn . secretLookupByUsage ( usage_type_const , usage_id ) #NEWLINE# #UNINDENT# except libvirt . libvirtError as e : #NEWLINE# #INDENT# if ( e . get_error_code ( ) == libvirt . VIR_ERR_NO_SECRET ) : #NEWLINE# #INDENT# return None