(self, cluster_template)
return ClusterTemplate.convert_with_links(new_cluster_template)
Create a new ClusterTemplate.

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

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

        if (cluster_template.docker_storage_driver in ('devicemapper',
                                                       'overlay')):
            warnings.warn(self._devicemapper_overlay_deprecation_note,
                          DeprecationWarning)
            LOG.warning(self._devicemapper_overlay_deprecation_note)

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

        new_cluster_template = objects.ClusterTemplate(context,
                                                       **cluster_template_dict)
        new_cluster_template.create()
        # Set the HTTP Location Header
        pecan.response.location = link.build_url('clustertemplates',
                                                 new_cluster_template.uuid)
        return ClusterTemplate.convert_with_links(new_cluster_template)
def post ( self , cluster_template ) : context = pecan . request . context policy . enforce ( context , 'clustertemplate:create' , action = 'clustertemplate:create' ) cluster_template_dict = cluster_template . as_dict ( ) cli = clients . OpenStackClients ( context ) attr_validator . validate_os_resources ( context , cluster_template_dict ) image_data = attr_validator . validate_image ( cli , cluster_template_dict [ 'image_id' ] ) cluster_template_dict [ 'cluster_distro' ] = image_data [ 'os_distro' ] cluster_template_dict [ 'project_id' ] = context . project_id cluster_template_dict [ 'user_id' ] = context . user_id # check permissions for making cluster_template public or hidden if cluster_template_dict [ 'public' ] or cluster_template_dict [ 'hidden' ] : if not policy . enforce ( context , "clustertemplate:publish" , None , do_raise = False ) : raise exception . ClusterTemplatePublishDenied ( ) if ( cluster_template . docker_storage_driver in ( 'devicemapper' , 'overlay' ) ) : warnings . warn ( self . _devicemapper_overlay_deprecation_note , DeprecationWarning ) LOG . warning ( self . _devicemapper_overlay_deprecation_note ) # NOTE(yuywz): We will generate a random human-readable name for # cluster_template if the name is not specified by user. arg_name = cluster_template_dict . get ( 'name' ) name = arg_name or self . _generate_name_for_cluster_template ( context ) cluster_template_dict [ 'name' ] = name new_cluster_template = objects . ClusterTemplate ( context , * * cluster_template_dict ) new_cluster_template . create ( ) # Set the HTTP Location Header pecan . response . location = link . build_url ( 'clustertemplates' , new_cluster_template . uuid ) return ClusterTemplate . convert_with_links ( new_cluster_template )