(self, baymodel)
return BayModel.convert_with_links(new_baymodel)
Create a new Baymodel.

        :param baymodel: a Baymodel within the request body.
Create a new Baymodel.
Create a new Baymodel .
def post(self, baymodel):
        """Create a new Baymodel.

        :param baymodel: a Baymodel within the request body.
        """
        context = pecan.request.context
        policy.enforce(context, 'baymodel:create',
                       action='baymodel:create')
        baymodel_dict = baymodel.as_dict()
        cli = clients.OpenStackClients(context)
        attr_validator.validate_os_resources(context, baymodel_dict)
        image_data = attr_validator.validate_image(cli,
                                                   baymodel_dict['image_id'])
        baymodel_dict['cluster_distro'] = image_data['os_distro']
        baymodel_dict['project_id'] = context.project_id
        baymodel_dict['user_id'] = context.user_id
        # check permissions for making baymodel public
        if baymodel_dict['public']:
            if not policy.enforce(context, "baymodel:publish", None,
                                  do_raise=False):
                raise exception.ClusterTemplatePublishDenied()

        # NOTE(yuywz): We will generate a random human-readable name for
        # baymodel if the name is not specified by user.
        arg_name = baymodel_dict.get('name')
        name = arg_name or self._generate_name_for_baymodel(context)
        baymodel_dict['name'] = name

        new_baymodel = objects.ClusterTemplate(context, **baymodel_dict)
        new_baymodel.create()
        # Set the HTTP Location Header
        pecan.response.location = link.build_url('baymodels',
                                                 new_baymodel.uuid)
        return BayModel.convert_with_links(new_baymodel)
def post ( self , baymodel ) : context = pecan . request . context policy . enforce ( context , 'baymodel:create' , action = 'baymodel:create' ) baymodel_dict = baymodel . as_dict ( ) cli = clients . OpenStackClients ( context ) attr_validator . validate_os_resources ( context , baymodel_dict ) image_data = attr_validator . validate_image ( cli , baymodel_dict [ 'image_id' ] ) baymodel_dict [ 'cluster_distro' ] = image_data [ 'os_distro' ] baymodel_dict [ 'project_id' ] = context . project_id baymodel_dict [ 'user_id' ] = context . user_id # check permissions for making baymodel public if baymodel_dict [ 'public' ] : if not policy . enforce ( context , "baymodel:publish" , None , do_raise = False ) : raise exception . ClusterTemplatePublishDenied ( ) # NOTE(yuywz): We will generate a random human-readable name for # baymodel if the name is not specified by user. arg_name = baymodel_dict . get ( 'name' ) name = arg_name or self . _generate_name_for_baymodel ( context ) baymodel_dict [ 'name' ] = name new_baymodel = objects . ClusterTemplate ( context , * * baymodel_dict ) new_baymodel . create ( ) # Set the HTTP Location Header pecan . response . location = link . build_url ( 'baymodels' , new_baymodel . uuid ) return BayModel . convert_with_links ( new_baymodel )