#NEWLINE# def add( self , req , body ) : #NEWLINE# #INDENT# context = req . environ [ 'nova.context' ] #NEWLINE# authorize ( context ) #NEWLINE# nova_context . require_admin_context ( context ) #NEWLINE# if ( not body ) : #NEWLINE# #INDENT# raise exc . HTTPUnprocessableEntity ( ) #NEWLINE# #UNINDENT# network_id = body . get ( 'id' , None ) #NEWLINE# project_id = context . project_id #NEWLINE# try : #NEWLINE# #INDENT# self . network_api . add_network_to_project ( context , project_id , network_id ) #NEWLINE# #UNINDENT# except NotImplementedError : #NEWLINE# #INDENT# msg = _ ( 'VLAN support must be enabled' ) #NEWLINE# raise exc . HTTPNotImplemented ( explanation = msg ) #NEWLINE# #UNINDENT# except ( exception . NoMoreNetworks , exception . NetworkNotFoundForUUID ) as e : #NEWLINE# #INDENT# raise exc . HTTPBadRequest ( explanation = e . format_message ( ) ) #NEWLINE# #UNINDENT# return webob . Response ( status_int = 202 )