Пример #1
0
    def __init__(self, request, *args, **kwargs):
        super(ConfigureNodegroupsAction, self). \
            __init__(request, *args, **kwargs)

        savanna = savannaclient.client(request)

        plugin, hadoop_version = whelpers.\
            get_plugin_and_hadoop_version(request)

        self.templates = savanna.node_group_templates.find(
            plugin_name=plugin,
            hadoop_version=hadoop_version)

        deletable = request.REQUEST.get("deletable", dict())

        if 'forms_ids' in request.POST:
            self.groups = []
            for id in json.loads(request.POST['forms_ids']):
                group_name = "group_name_" + str(id)
                template_id = "template_id_" + str(id)
                count = "count_" + str(id)
                self.groups.append({"name": request.POST[group_name],
                                    "template_id": request.POST[template_id],
                                    "count": request.POST[count],
                                    "id": id,
                                    "deletable": deletable.get(
                                        request.POST[group_name], "true")})

                whelpers.build_node_group_fields(self,
                                                 group_name,
                                                 template_id,
                                                 count)
Пример #2
0
    def __init__(self, request, context_seed, entry_point, *args, **kwargs):
        ScaleCluster._cls_registry = set([])

        savanna = savannaclient.client(request)

        cluster_id = context_seed["cluster_id"]
        cluster = savanna.clusters.get(cluster_id)

        self.success_message = "Scaling Cluster %s successfully started" \
                               % cluster.name

        plugin = cluster.plugin_name
        hadoop_version = cluster.hadoop_version

        #init deletable nodegroups
        deletable = dict()
        for group in cluster.node_groups:
            deletable[group["name"]] = "false"

        request.GET = request.GET.copy()
        request.GET.update({"cluster_id": cluster_id})
        request.GET.update({"plugin_name": plugin})
        request.GET.update({"hadoop_version": hadoop_version})
        request.GET.update({"deletable": deletable})

        super(ScaleCluster, self).__init__(request, context_seed,
                                           entry_point, *args,
                                           **kwargs)

        #init Node Groups

        for step in self.steps:
            if isinstance(step, clt_create_flow.ConfigureNodegroups):
                ng_action = step.action
                template_ngs = cluster.node_groups

                if 'forms_ids' not in request.POST:
                    ng_action.groups = []
                    for id in range(0, len(template_ngs), 1):
                        group_name = "group_name_" + str(id)
                        template_id = "template_id_" + str(id)
                        count = "count_" + str(id)
                        templ_ng = template_ngs[id]
                        ng_action.groups.append(
                            {"name": templ_ng["name"],
                             "template_id": templ_ng["node_group_template_id"],
                             "count": templ_ng["count"],
                             "id": id,
                             "deletable": "false"})

                        whelpers.build_node_group_fields(ng_action,
                                                         group_name,
                                                         template_id,
                                                         count)
Пример #3
0
    def __init__(self, request, context_seed, entry_point, *args, **kwargs):
        savanna = savannaclient(request)

        template_id = context_seed["template_id"]
        template = savanna.cluster_templates.get(template_id)
        self._set_configs_to_copy(template.cluster_configs)

        request.GET = request.GET.copy()
        request.GET.update({"plugin_name": template.plugin_name})
        request.GET.update({"hadoop_version": template.hadoop_version})
        request.GET.update({"aa_groups": template.anti_affinity})

        super(CopyClusterTemplate, self).__init__(request, context_seed,
                                                  entry_point, *args,
                                                  **kwargs)

        #init Node Groups

        for step in self.steps:
            if isinstance(step, create_flow.ConfigureNodegroups):
                ng_action = step.action
                template_ngs = template.node_groups

                if 'forms_ids' not in request.POST:
                    ng_action.groups = []
                    for id in range(0, len(template_ngs), 1):
                        group_name = "group_name_" + str(id)
                        template_id = "template_id_" + str(id)
                        count = "count_" + str(id)
                        templ_ng = template_ngs[id]
                        ng_action.groups.append(
                            {"name": templ_ng["name"],
                             "template_id": templ_ng["node_group_template_id"],
                             "count": templ_ng["count"],
                             "id": id,
                             "deletable": "true"})

                        build_node_group_fields(ng_action,
                                                group_name,
                                                template_id,
                                                count)

            elif isinstance(step, create_flow.GeneralConfig):
                fields = step.action.fields

                fields["cluster_template_name"].initial = \
                    template.name + "-copy"

                fields["description"].initial = template.description