#NEWLINE# def get_attachment_name( request , attachment ) : #NEWLINE# #INDENT# server_id = attachment . get ( 'server_id' , None ) #NEWLINE# if ( ( 'instance' in attachment ) and attachment [ 'instance' ] ) : #NEWLINE# #INDENT# name = attachment [ 'instance' ] . name #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# server = api . nova . server_get ( request , server_id ) #NEWLINE# name = server . name #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# name = None #NEWLINE# exceptions . handle ( request , _ ( 'Unable to retrieve attachment information.' ) ) #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# url = reverse ( 'horizon:project:instances:detail' , args = ( server_id , ) ) #NEWLINE# instance = ( '<a href="%s">%s</a>' % ( url , html . escape ( name ) ) ) #NEWLINE# #UNINDENT# except NoReverseMatch : #NEWLINE# #INDENT# instance = name #NEWLINE# #UNINDENT# return instance