#NEWLINE# @ wsgi . action ( 'os-getSPICEConsole' ) #NEWLINE# def get_spice_console( self , req , id , body ) : #NEWLINE# #INDENT# 'Get spice connection information to access a server.' #NEWLINE# context = req . environ [ 'nova.context' ] #NEWLINE# authorize ( context ) #NEWLINE# console_type = body [ 'os-getSPICEConsole' ] . get ( 'type' ) #NEWLINE# instance = common . get_instance ( self . compute_api , context , console_type ) #NEWLINE# try : #NEWLINE# #INDENT# output = self . compute_api . get_spice_console ( context , instance , console_type ) #NEWLINE# #UNINDENT# except ( exception . ConsoleTypeUnavailable , exception . ConsoleTypeInvalid ) as e : #NEWLINE# #INDENT# raise webob . exc . HTTPBadRequest ( explanation = e . format_message ( ) ) #NEWLINE# #UNINDENT# except exception . InstanceNotFound as e : #NEWLINE# #INDENT# raise webob . exc . HTTPNotFound ( explanation = e . format_message ( ) ) #NEWLINE# #UNINDENT# except exception . InstanceNotReady as e : #NEWLINE# #INDENT# raise webob . exc . HTTPConflict ( explanation = e . format_message ( ) ) #NEWLINE# #UNINDENT# except NotImplementedError : #NEWLINE# #INDENT# msg = _ ( 'Unable to get spice console, functionality not implemented' ) #NEWLINE# raise webob . exc . HTTPNotImplemented ( explanation = msg ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'console' : { #NEWLINE# #INDENT# 'type' : console_type , #NEWLINE# 'url' : output [ 'url' ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# }