def get_context_data(self, request): template_id = self.tab_group.kwargs['template_id'] try: template = saharaclient.cluster_template_get(request, template_id) except Exception as e: template = {} LOG.error("Unable to fetch cluster template details: %s" % str(e)) return {"template": template}
def save_cluster_template_info(request, ct_id, path): ct_info = sahara.cluster_template_get(request, ct_id).to_dict() path = u.join_path(path, "clusterTemplate.json") node_groups_template_ids = [] _node_groups = ct_info['node_groups'] for ng in _node_groups: node_groups_template_ids.append(ng['node_group_template_id']) u.save_to_json(path, ct_info) return node_groups_template_ids
def get_object(self): ct_id = self.kwargs["template_id"] try: return saharaclient.cluster_template_get(self.request, ct_id) except Exception: msg = _('Unable to retrieve details for ' 'cluster template "%s".') % ct_id redirect = self.get_redirect_url() exceptions.handle(self.request, msg, redirect=redirect)
def get_context_data(self, request): template_id = self.tab_group.kwargs['template_id'] try: template = saharaclient.cluster_template_get(request, template_id) except Exception as e: template = {} LOG.error("Unable to fetch cluster template details: %s" % str(e)) if saharaclient.VERSIONS.active == '2': template.hadoop_version = template.plugin_version return {"template": template}
def get_object(self, *args, **kwargs): if not hasattr(self, "_object"): template_id = self.kwargs['template_id'] try: template = saharaclient.cluster_template_get( self.request, template_id) except Exception: template = {} exceptions.handle(self.request, _("Unable to fetch cluster template.")) self._object = template return self._object
def get_object(self, *args, **kwargs): if not hasattr(self, "_object"): template_id = self.kwargs['template_id'] try: template = saharaclient.cluster_template_get(self.request, template_id) except Exception: template = {} exceptions.handle(self.request, _("Unable to fetch cluster template.")) self._object = template return self._object
def get_context_data(self, request): template_id = self.tab_group.kwargs['template_id'] try: template = saharaclient.cluster_template_get(request, template_id) for ng in template.node_groups: if not ng["flavor_id"]: continue ng["flavor_name"] = ( nova.flavor_get(request, ng["flavor_id"]).name) ng["node_group_template"] = saharaclient.safe_call( saharaclient.nodegroup_template_get, request, ng.get("node_group_template_id", None)) ng["security_groups_full"] = helpers.get_security_groups( request, ng.get("security_groups")) except Exception: template = {} exceptions.handle(request, _("Unable to fetch node group details.")) return {"template": template}
def recovery_ct(request, ct, node_groups): ct_ngs = get_ct_ng(node_groups) ct = sahara.cluster_template_create( request, name=ct['name'] + uuidutils.generate_uuid()[0:7], plugin_name=ct['plugin_name'], hadoop_version=ct['hadoop_version'], description=ct['description'], cluster_configs=ct['cluster_configs'], node_groups=ct_ngs, anti_affinity=ct['anti_affinity'], net_id=None, use_autoconfig=ct['use_autoconfig'], shares=ct['shares'], is_public=ct['is_public'], is_protected=ct['is_protected'], domain_name=ct['domain_name']).to_dict() ct = sahara.cluster_template_get(request, ct['id']).to_dict() return ct
def get_context_data(self, request): template_id = self.tab_group.kwargs['template_id'] try: template = saharaclient.cluster_template_get(request, template_id) for ng in template.node_groups: if not ng["flavor_id"]: continue ng["flavor_name"] = (nova.flavor_get(request, ng["flavor_id"]).name) ng["node_group_template"] = saharaclient.safe_call( saharaclient.nodegroup_template_get, request, ng.get("node_group_template_id", None)) ng["security_groups_full"] = helpers.get_security_groups( request, ng.get("security_groups")) except Exception: template = {} exceptions.handle(request, _("Unable to fetch node group details.")) return {"template": template}
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) if saharaclient.VERSIONS.active == '2': version_attr = 'plugin_version' else: version_attr = 'hadoop_version' hadoop_version = getattr(self.template, version_attr) request.GET = request.GET.copy() request.GET.update({ "plugin_name": self.template.plugin_name, version_attr: 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 = utils.serialize( 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['use_autoconfig'].initial = ( self.template.use_autoconfig) fields["description"].initial = self.template.description elif isinstance(step, create_flow.SelectClusterShares): fields = step.action.fields fields["shares"].initial = (self._get_share_defaults( fields["shares"].choices)) fields['is_public'].initial = (self.template.is_public) fields['is_protected'].initial = ( self.template.is_protected) elif isinstance(step, create_flow.SelectDnsDomains): fields = step.action.fields fields["domain_name"].initial = self.template.domain_name except Exception: exceptions.handle(request, _("Unable to fetch template to copy."))
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['use_autoconfig'].initial = ( self.template.use_autoconfig) fields["description"].initial = self.template.description elif isinstance(step, create_flow.SelectClusterShares): fields = step.action.fields fields["shares"].initial = ( self._get_share_defaults(fields["shares"].choices) ) fields['is_public'].initial = ( self.template.is_public) fields['is_protected'].initial = ( self.template.is_protected) except Exception: exceptions.handle(request, _("Unable to fetch template to copy."))