(self, cluster_id, nodegroup)
return NodeGroup.convert(new_obj)
Create NodeGroup.

        :param nodegroup: a json document to create this NodeGroup.
Create NodeGroup.
Create NodeGroup .
def post(self, cluster_id, nodegroup):
        """Create NodeGroup.

        :param nodegroup: a json document to create this NodeGroup.
        """

        context = pecan.request.context
        policy.enforce(context, 'nodegroup:create', action='nodegroup:create')

        cluster = api_utils.get_resource('Cluster', cluster_id)
        # Before we start, we need to check that the cluster has an
        # api_address. If not, just fail.
        if 'api_address' not in cluster or not cluster.api_address:
            raise exception.ClusterAPIAddressUnavailable()
        cluster_ngs = [ng.name for ng in cluster.nodegroups]
        if nodegroup.name in cluster_ngs:
            raise exception.NodeGroupAlreadyExists(name=nodegroup.name,
                                                   cluster_id=cluster.name)
        _validate_node_count(nodegroup)

        if nodegroup.role == "master":
            # Currently we don't support adding master nodegroups.
            # Keep this until we start supporting it.
            raise exception.CreateMasterNodeGroup()
        if nodegroup.image_id is None or nodegroup.image_id == wtypes.Unset:
            nodegroup.image_id = cluster.cluster_template.image_id
        if nodegroup.flavor_id is None or nodegroup.flavor_id == wtypes.Unset:
            nodegroup.flavor_id = cluster.flavor_id
        if nodegroup.labels is None or nodegroup.labels == wtypes.Unset:
            nodegroup.labels = cluster.labels
        else:
            # If labels are provided check if the user wishes to merge
            # them with the values from the cluster.
            if nodegroup.merge_labels:
                labels = cluster.labels
                labels.update(nodegroup.labels)
                nodegroup.labels = labels

        nodegroup_dict = nodegroup.as_dict()
        nodegroup_dict['cluster_id'] = cluster.uuid
        nodegroup_dict['project_id'] = context.project_id

        new_obj = objects.NodeGroup(context, **nodegroup_dict)
        new_obj.uuid = uuid.uuid4()
        pecan.request.rpcapi.nodegroup_create_async(cluster, new_obj)
        return NodeGroup.convert(new_obj)
def post ( self , cluster_id , nodegroup ) : context = pecan . request . context policy . enforce ( context , 'nodegroup:create' , action = 'nodegroup:create' ) cluster = api_utils . get_resource ( 'Cluster' , cluster_id ) # Before we start, we need to check that the cluster has an # api_address. If not, just fail. if 'api_address' not in cluster or not cluster . api_address : raise exception . ClusterAPIAddressUnavailable ( ) cluster_ngs = [ ng . name for ng in cluster . nodegroups ] if nodegroup . name in cluster_ngs : raise exception . NodeGroupAlreadyExists ( name = nodegroup . name , cluster_id = cluster . name ) _validate_node_count ( nodegroup ) if nodegroup . role == "master" : # Currently we don't support adding master nodegroups. # Keep this until we start supporting it. raise exception . CreateMasterNodeGroup ( ) if nodegroup . image_id is None or nodegroup . image_id == wtypes . Unset : nodegroup . image_id = cluster . cluster_template . image_id if nodegroup . flavor_id is None or nodegroup . flavor_id == wtypes . Unset : nodegroup . flavor_id = cluster . flavor_id if nodegroup . labels is None or nodegroup . labels == wtypes . Unset : nodegroup . labels = cluster . labels else : # If labels are provided check if the user wishes to merge # them with the values from the cluster. if nodegroup . merge_labels : labels = cluster . labels labels . update ( nodegroup . labels ) nodegroup . labels = labels nodegroup_dict = nodegroup . as_dict ( ) nodegroup_dict [ 'cluster_id' ] = cluster . uuid nodegroup_dict [ 'project_id' ] = context . project_id new_obj = objects . NodeGroup ( context , * * nodegroup_dict ) new_obj . uuid = uuid . uuid4 ( ) pecan . request . rpcapi . nodegroup_create_async ( cluster , new_obj ) return NodeGroup . convert ( new_obj )