#NEWLINE# def create( self , req , body ) : #NEWLINE# #INDENT# 'Create a new VSA.' #NEWLINE# context = req . environ [ 'nova.context' ] #NEWLINE# if ( ( not body ) or ( 'vsa' not in vc_type ) ) : #NEWLINE# #INDENT# LOG . debug ( _ ( 'No body provided' ) , context = context ) #NEWLINE# return faults . Fault ( exc . HTTPUnprocessableEntity ( ) ) #NEWLINE# #UNINDENT# vsa = body [ 'vsa' ] #NEWLINE# display_name = vsa . get ( 'displayName' ) #NEWLINE# vc_type = vsa . get ( 'vcType' , FLAGS . default_vsa_instance_type ) #NEWLINE# try : #NEWLINE# #INDENT# instance_type = instance_types . get_instance_type_by_name ( vc_type ) #NEWLINE# #UNINDENT# except exception . NotFound : #NEWLINE# #INDENT# return faults . Fault ( exc . HTTPNotFound ( ) ) #NEWLINE# #UNINDENT# LOG . audit ( _ ( 'Create VSA %(display_name)s of type %(vc_type)s' ) , locals ( ) , context = context ) #NEWLINE# args = dict ( display_name = display_name , display_description = vsa . get ( 'displayDescription' ) , instance_type = instance_type , storage = vsa . get ( 'storage' ) , shared = vsa . get ( 'shared' ) , availability_zone = vsa . get ( 'placement' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . get ( 'AvailabilityZone' ) ) #NEWLINE# vsa = self . vsa_api . create ( context , ** args ) #NEWLINE# instances = self . _get_instances_by_vsa_id ( context , vsa . get ( 'id' ) ) #NEWLINE# return { #NEWLINE# #INDENT# 'vsa' : _vsa_view ( context , vsa , True , instances ) , #NEWLINE# #UNINDENT# }