Example #1
0
    def cluster_create(self, context, values):
        """Create a cluster from the values dictionary."""

        # loading defaults
        merged_values = copy.deepcopy(CLUSTER_DEFAULTS)
        merged_values["tenant_id"] = context.tenant_id

        private_key, public_key = crypto.generate_key_pair()
        merged_values["management_private_key"] = private_key
        merged_values["management_public_key"] = public_key

        cluster_template_id = values.get("cluster_template_id")
        c_tmpl = None

        if cluster_template_id:
            c_tmpl = self.cluster_template_get(context, cluster_template_id)

            del c_tmpl["created_at"]
            del c_tmpl["updated_at"]
            del c_tmpl["id"]

            # updating with cluster_template values
            merged_values.update(c_tmpl)

        # updating with values provided in request
        merged_values.update(values)

        if c_tmpl:
            merged_values["cluster_configs"] = configs.merge_configs(
                c_tmpl.get("cluster_configs"), values.get("cluster_configs")
            )

        merged_values["node_groups"] = self._populate_node_groups(context, merged_values)

        return self.db.cluster_create(context, merged_values)
Example #2
0
    def cluster_create(self, context, values):
        """Create a cluster from the values dictionary."""
        values = copy.deepcopy(values)
        values = _apply_defaults(values, CLUSTER_DEFAULTS)
        values['tenant_id'] = context.tenant_id

        private_key, public_key = crypto.generate_key_pair()
        values['management_private_key'] = private_key
        values['management_public_key'] = public_key

        cluster_template_id = values.get('cluster_template_id')
        if cluster_template_id:
            c_tmpl = self.cluster_template_get(context, cluster_template_id)
            if c_tmpl:
                new_values = c_tmpl.copy()
                del new_values['created_at']
                del new_values['updated_at']
                del new_values['id']
                new_values.update(values)
                new_values['cluster_configs'] = configs.merge_configs(
                    c_tmpl.get('cluster_configs'),
                    values.get('cluster_configs'))

                values = new_values

        self._populate_node_groups(context, values)
        return self.db.cluster_create(context, values)
Example #3
0
    def cluster_create(self, context, values):
        """Create a cluster from the values dictionary."""

        #loading defaults
        merged_values = copy.deepcopy(CLUSTER_DEFAULTS)
        merged_values['tenant_id'] = context.tenant_id

        private_key, public_key = crypto.generate_key_pair()
        merged_values['management_private_key'] = private_key
        merged_values['management_public_key'] = public_key

        cluster_template_id = values.get('cluster_template_id')
        c_tmpl = None

        if cluster_template_id:
            c_tmpl = self.cluster_template_get(context, cluster_template_id)

            del c_tmpl['created_at']
            del c_tmpl['updated_at']
            del c_tmpl['id']

            #updating with cluster_template values
            merged_values.update(c_tmpl)

        #updating with values provided in request
        merged_values.update(values)

        if c_tmpl:
            merged_values['cluster_configs'] = configs.merge_configs(
                c_tmpl.get('cluster_configs'), values.get('cluster_configs'))

        merged_values['node_groups'] = \
            self._populate_node_groups(context, merged_values)

        return self.db.cluster_create(context, merged_values)
Example #4
0
    def configuration(self):
        if hasattr(self, '_all_configs'):
            return self._all_configs

        self._all_configs = configs.merge_configs(
            self.cluster.cluster_configs,
            self.node_configs
        )

        return self._all_configs
Example #5
0
 def to_cluster(self, values):
     return Cluster(
         name=values.pop('name', None) or self.name,
         tenant_id=values.pop('tenant_id'),
         plugin_name=values.pop('plugin_name', None) or self.plugin_name,
         hadoop_version=(values.pop('hadoop_version', None)
                         or self.hadoop_version),
         default_image_id=(values.pop('default_image_id')
                           or self.default_image_id),
         cluster_configs=configs.merge_configs(
             self.cluster_configs, values.pop('cluster_configs', None)),
         cluster_template_id=self.id,
         anti_affinity=(values.pop('anti_affinity', None)
                        or self.anti_affinity),
         description=values.pop('description', None),
         **values)
Example #6
0
 def to_object(self, values, cls):
     values.pop('node_group_template_id', None)
     return cls(
         name=values.pop('name', None) or self.name,
         flavor_id=values.pop('flavor_id', None) or self.flavor_id,
         image_id=values.pop('image_id', None) or self.image_id,
         node_processes=(values.pop('node_processes', None)
                         or self.node_processes),
         node_configs=configs.merge_configs(
             self.node_configs, values.pop('node_configs', None)),
         volumes_per_node=(values.pop('volumes_per_node', None)
                           or self.volumes_per_node),
         volumes_size=(values.pop('volumes_size', None)
                       or self.volumes_size),
         volume_mount_prefix=(values.pop('volume_mount_prefix', None)
                              or self.volume_mount_prefix),
         node_group_template_id=self.id, **values)
Example #7
0
    def _populate_node_group(self, context, node_group):
        node_group_merged = copy.deepcopy(NODE_GROUP_DEFAULTS)

        ng_tmpl_id = node_group.get('node_group_template_id')
        ng_tmpl = None
        if ng_tmpl_id:
            ng_tmpl = self.node_group_template_get(context, ng_tmpl_id)

            self._cleanup_node_group(ng_tmpl)
            node_group_merged.update(ng_tmpl)

        node_group_merged.update(node_group)

        if ng_tmpl:
            node_group_merged['node_configs'] = configs.merge_configs(
                ng_tmpl.get('node_configs'), node_group.get('node_configs'))

        return node_group_merged
Example #8
0
    def _populate_node_group(self, context, node_group):
        node_group_merged = copy.deepcopy(NODE_GROUP_DEFAULTS)

        ng_tmpl_id = node_group.get('node_group_template_id')
        ng_tmpl = None
        if ng_tmpl_id:
            ng_tmpl = self.node_group_template_get(context, ng_tmpl_id)

            self._cleanup_node_group(ng_tmpl)
            node_group_merged.update(ng_tmpl)

        node_group_merged.update(node_group)

        if ng_tmpl:
            node_group_merged['node_configs'] = configs.merge_configs(
                ng_tmpl.get('node_configs'),
                node_group.get('node_configs'))

        return node_group_merged
Example #9
0
    def _populate_node_group(self, context, node_group):
        ng_tmpl_id = node_group.get('node_group_template_id')
        if not ng_tmpl_id:
            return

        ng_tmpl = self.node_group_template_get(context, ng_tmpl_id)
        if not ng_tmpl:
            return

        new_values = ng_tmpl.copy()
        new_values.update(node_group)
        new_values['node_configs'] = configs.merge_configs(
            ng_tmpl.get('node_configs'),
            node_group.get('node_configs'))

        node_group.update(new_values)
        node_group.pop('cluster_template_id', None)
        node_group.pop('created_at', None)
        node_group.pop('updated_at', None)
Example #10
0
    def _populate_node_group(self, context, node_group):
        ng_tmpl_id = node_group.get("node_group_template_id")
        if not ng_tmpl_id:
            node_group.update(_apply_defaults(node_group, NODE_GROUP_DEFAULTS))
            self._cleanup_node_group(node_group)
            return

        ng_tmpl = self.node_group_template_get(context, ng_tmpl_id)
        if not ng_tmpl:
            node_group.update(_apply_defaults(node_group, NODE_GROUP_DEFAULTS))
            self._cleanup_node_group(node_group)
            return

        new_values = _apply_defaults(ng_tmpl, NODE_GROUP_DEFAULTS)
        new_values.update(node_group)
        new_values["node_configs"] = configs.merge_configs(ng_tmpl.get("node_configs"), node_group.get("node_configs"))

        node_group.clear()
        node_group.update(new_values)

        self._cleanup_node_group(node_group)
Example #11
0
    def cluster_create(self, context, values):
        """Create a cluster from the values dictionary."""
        values = copy.deepcopy(values)
        values['tenant_id'] = context.tenant_id

        cluster_template_id = values.get('cluster_template_id')
        if cluster_template_id:
            c_tmpl = self.cluster_template_get(context, cluster_template_id)
            if c_tmpl:
                new_values = c_tmpl.copy()
                del new_values['created_at']
                del new_values['updated_at']
                new_values.update(values)
                new_values['cluster_configs'] = configs.merge_configs(
                    c_tmpl.get('cluster_configs'),
                    values.get('cluster_configs'))

                values = new_values

        self._populate_node_groups(context, values)

        return self.db.cluster_create(context, values)
Example #12
0
    def _populate_node_group(self, context, node_group):
        ng_tmpl_id = node_group.get('node_group_template_id')
        if not ng_tmpl_id:
            node_group.update(_apply_defaults(node_group, NODE_GROUP_DEFAULTS))
            self._cleanup_node_group(node_group)
            return

        ng_tmpl = self.node_group_template_get(context, ng_tmpl_id)
        if not ng_tmpl:
            node_group.update(_apply_defaults(node_group, NODE_GROUP_DEFAULTS))
            self._cleanup_node_group(node_group)
            return

        new_values = _apply_defaults(ng_tmpl, NODE_GROUP_DEFAULTS)
        new_values.update(node_group)
        new_values['node_configs'] = configs.merge_configs(
            ng_tmpl.get('node_configs'), node_group.get('node_configs'))

        node_group.clear()
        node_group.update(new_values)

        self._cleanup_node_group(node_group)
Example #13
0
    def cluster_create(self, context, values):
        """Create a cluster from the values dictionary."""
        values = copy.deepcopy(values)
        values = _apply_defaults(values, CLUSTER_DEFAULTS)
        values['tenant_id'] = context.tenant_id

        cluster_template_id = values.get('cluster_template_id')
        if cluster_template_id:
            c_tmpl = self.cluster_template_get(context, cluster_template_id)
            if c_tmpl:
                new_values = c_tmpl.copy()
                del new_values['created_at']
                del new_values['updated_at']
                del new_values['id']
                new_values.update(values)
                new_values['cluster_configs'] = configs.merge_configs(
                    c_tmpl.get('cluster_configs'),
                    values.get('cluster_configs'))

                values = new_values

        self._populate_node_groups(context, values)
        return self.db.cluster_create(context, values)
Example #14
0
    def cluster_create(self, context, values):
        """Create a cluster from the values dictionary."""
        values = copy.deepcopy(values)
        values = _apply_defaults(values, CLUSTER_DEFAULTS)
        values["tenant_id"] = context.tenant_id

        cluster_template_id = values.get("cluster_template_id")
        if cluster_template_id:
            c_tmpl = self.cluster_template_get(context, cluster_template_id)
            if c_tmpl:
                new_values = c_tmpl.copy()
                del new_values["created_at"]
                del new_values["updated_at"]
                del new_values["id"]
                new_values.update(values)
                new_values["cluster_configs"] = configs.merge_configs(
                    c_tmpl.get("cluster_configs"), values.get("cluster_configs")
                )

                values = new_values

        self._populate_node_groups(context, values)
        return self.db.cluster_create(context, values)
Example #15
0
 def configuration(self):
     return configs.merge_configs(self.cluster.cluster_configs,
                                  self.node_configs)
Example #16
0
 def configuration(self):
     return configs.merge_configs(self.cluster.cluster_configs,
                                  self.node_configs)