def __init__(self, request, context_seed, entry_point, *args, **kwargs): self.cluster_template_id = context_seed["template_id"] try: self.template = saharaclient.cluster_template_get( request, self.cluster_template_id) self._set_configs_to_copy(self.template.cluster_configs) request.GET = request.GET.copy() request.GET.update({"plugin_name": self.template.plugin_name, "hadoop_version": self.template.hadoop_version, "aa_groups": self.template.anti_affinity}) super(CopyClusterTemplate, self).__init__(request, context_seed, entry_point, *args, **kwargs) # Initialize node groups. # TODO(rdopieralski) The same (or very similar) code appears # multiple times in this dashboard. It should be refactored to # a function. for step in self.steps: if isinstance(step, create_flow.ConfigureNodegroups): ng_action = step.action template_ngs = self.template.node_groups if 'forms_ids' in request.POST: continue ng_action.groups = [] for i, templ_ng in enumerate(template_ngs): group_name = "group_name_%d" % i template_id = "template_id_%d" % i count = "count_%d" % i serialized = "serialized_%d" % i # save the original node group with all its fields in # case the template id is missing serialized_val = base64.urlsafe_b64encode( json.dumps(wf_helpers.clean_node_group(templ_ng))) ng = { "name": templ_ng["name"], "count": templ_ng["count"], "id": i, "deletable": "true", "serialized": serialized_val } if "node_group_template_id" in templ_ng: ng["template_id"] = templ_ng[ "node_group_template_id"] ng_action.groups.append(ng) wf_helpers.build_node_group_fields( ng_action, group_name, template_id, count, serialized) elif isinstance(step, create_flow.GeneralConfig): fields = step.action.fields fields["cluster_template_name"].initial = ( self.template.name + "-copy") fields["description"].initial = self.template.description except Exception: exceptions.handle(request, _("Unable to fetch template to copy."))
def __init__(self, request, context_seed, entry_point, *args, **kwargs): template_id = context_seed["template_id"] try: template = saharaclient.cluster_template_get(request, template_id) self._set_configs_to_copy(template.cluster_configs) request.GET = request.GET.copy() request.GET.update({ "plugin_name": template.plugin_name, "hadoop_version": template.hadoop_version, "aa_groups": template.anti_affinity }) super(CopyClusterTemplate, self).__init__(request, context_seed, entry_point, *args, **kwargs) # Initialize node groups. # TODO(rdopieralski) The same (or very similar) code appears # multiple times in this dashboard. It should be refactored to # a function. for step in self.steps: if isinstance(step, create_flow.ConfigureNodegroups): ng_action = step.action template_ngs = template.node_groups if 'forms_ids' in request.POST: continue ng_action.groups = [] for i, templ_ng in enumerate(template_ngs): group_name = "group_name_%d" % i template_id = "template_id_%d" % i count = "count_%d" % i serialized = "serialized_%d" % i # save the original node group with all its fields in # case the template id is missing serialized_val = base64.urlsafe_b64encode( json.dumps(wf_helpers.clean_node_group(templ_ng))) ng = { "name": templ_ng["name"], "count": templ_ng["count"], "id": i, "deletable": "true", "serialized": serialized_val } if "node_group_template_id" in templ_ng: ng["template_id"] = templ_ng[ "node_group_template_id"] ng_action.groups.append(ng) wf_helpers.build_node_group_fields( ng_action, group_name, template_id, count, serialized) elif isinstance(step, create_flow.GeneralConfig): fields = step.action.fields fields["cluster_template_name"].initial = (template.name + "-copy") fields["description"].initial = template.description except Exception: exceptions.handle(request, _("Unable to fetch template to copy."))
def __init__(self, request, context_seed, entry_point, *args, **kwargs): ScaleCluster._cls_registry = set([]) self.success_message = _("Scaled cluster successfully started.") cluster_id = context_seed["cluster_id"] try: cluster = saharaclient.cluster_get(request, cluster_id) plugin = cluster.plugin_name hadoop_version = cluster.hadoop_version # Initialize deletable node groups. deletable = dict() for group in cluster.node_groups: deletable[group["name"]] = "false" request.GET = request.GET.copy() request.GET.update({ "cluster_id": cluster_id, "plugin_name": plugin, "hadoop_version": hadoop_version, "deletable": deletable }) super(ScaleCluster, self).__init__(request, context_seed, entry_point, *args, **kwargs) # Initialize node groups. for step in self.steps: if not isinstance(step, clt_create_flow.ConfigureNodegroups): continue ng_action = step.action template_ngs = cluster.node_groups if 'forms_ids' in request.POST: continue ng_action.groups = [] for i, templ_ng in enumerate(template_ngs): group_name = "group_name_%d" % i template_id = "template_id_%d" % i count = "count_%d" % i serialized = "serialized_%d" % i serialized_val = base64.urlsafe_b64encode(json.dumps( workflow_helpers.clean_node_group(templ_ng))) ng_action.groups.append({ "name": templ_ng["name"], "template_id": templ_ng["node_group_template_id"], "count": templ_ng["count"], "id": i, "deletable": "false", "serialized": serialized_val }) workflow_helpers.build_node_group_fields(ng_action, group_name, template_id, count, serialized) except Exception: exceptions.handle(request, _("Unable to fetch cluster to scale"))