@webob.dec.wsgify
@util.require_content('application/json')
def create_resource_provider(req):
 context = req.environ['placement.context']
 data = util.extract_json(req.body, POST_RESOURCE_PROVIDER_SCHEMA)
 try:
  uuid = data.get('uuid', uuidutils.generate_uuid())
  resource_provider = objects.ResourceProvider(context, name=data['name'], uuid=uuid)
  resource_provider.create()
 except db_exc.DBDuplicateEntry as exc:
  raise webob.exc.HTTPConflict((_('Conflicting resource provider already exists: %(error)s') % {'error': exc}), json_formatter=util.json_error_formatter)
 except exception.ObjectActionError as exc:
  raise webob.exc.HTTPBadRequest((_('Unable to create resource provider %(rp_uuid)s: %(error)s') % {'rp_uuid': uuid, 'error': exc}), json_formatter=util.json_error_formatter)
 req.response.location = util.resource_provider_url(req.environ, resource_provider)
 req.response.status = 201
 req.response.content_type = None
 return req.response

@ webob . dec . wsgify @ util . require_content ( 'application/json' ) def create_resource_provider ( req ) : context = req . environ [ 'placement.context' ] data = util . extract_json ( req . body , POST_RESOURCE_PROVIDER_SCHEMA ) try : uuid = data . get ( 'uuid' , uuidutils . generate_uuid ( ) ) resource_provider = objects . ResourceProvider ( context , name = data [ 'name' ] , uuid = uuid ) resource_provider . create ( ) except db_exc . DBDuplicateEntry as exc : raise webob . exc . HTTPConflict ( ( _ ( 'Conflicting resource provider already exists: %(error)s' ) % { 'error' : exc } ) , json_formatter = util . json_error_formatter ) except exception . ObjectActionError as exc : raise webob . exc . HTTPBadRequest ( ( _ ( 'Unable to create resource provider %(rp_uuid)s: %(error)s' ) % { 'rp_uuid' : uuid , 'error' : exc } ) , json_formatter = util . json_error_formatter ) req . response . location = util . resource_provider_url ( req . environ , resource_provider ) req . response . status = 201 req . response . content_type = None return req . response
post to create a resource provider .