def handle(self, request, context): try: node_groups = [] configs_dict = whelpers.parse_configs_from_context(context, self.defaults) ids = json.loads(context["ng_forms_ids"]) for id in ids: name = context["ng_group_name_" + str(id)] template_id = context["ng_template_id_" + str(id)] count = context["ng_count_" + str(id)] ng = {"name": name, "node_group_template_id": template_id, "count": count} node_groups.append(ng) plugin, hadoop_version = whelpers.get_plugin_and_hadoop_version(request) # TODO(nkonovalov): Fix client to support default_image_id saharaclient.cluster_template_create( request, context["general_cluster_template_name"], plugin, hadoop_version, context["general_description"], configs_dict, node_groups, context["anti_affinity_info"], ) return True except api_base.APIException as e: self.error_description = str(e) return False except Exception: exceptions.handle(request, _("Cluster template creation failed")) return False
def handle(self, request, context): try: node_groups = [] configs_dict = whelpers.parse_configs_from_context(context, self.defaults) ids = json.loads(context['ng_forms_ids']) for id in ids: name = context['ng_group_name_' + str(id)] template_id = context['ng_template_id_' + str(id)] count = context['ng_count_' + str(id)] raw_ng = context.get("ng_serialized_" + str(id)) if raw_ng and raw_ng != 'null': ng = json.loads(base64.urlsafe_b64decode(str(raw_ng))) else: ng = dict() ng["name"] = name ng["count"] = count if template_id and template_id != u'None': ng["node_group_template_id"] = template_id node_groups.append(ng) plugin, hadoop_version = whelpers.\ get_plugin_and_hadoop_version(request) # TODO(nkonovalov): Fix client to support default_image_id saharaclient.cluster_template_create( request, context["general_cluster_template_name"], plugin, hadoop_version, context["general_description"], configs_dict, node_groups, context["anti_affinity_info"], ) hlps = helpers.Helpers(request) if hlps.is_from_guide(): request.session["guide_cluster_template_name"] = ( context["general_cluster_template_name"]) self.success_url = ( "horizon:project:data_processing.wizard:cluster_guide") return True except api_base.APIException as e: self.error_description = str(e) return False except Exception: exceptions.handle(request, _("Cluster template creation failed")) return False
def handle(self, request, context): try: node_groups = [] configs_dict = whelpers.parse_configs_from_context(context, self.defaults) ids = json.loads(context['ng_forms_ids']) for id in ids: name = context['ng_group_name_' + str(id)] template_id = context['ng_template_id_' + str(id)] count = context['ng_count_' + str(id)] ng = {"name": name, "node_group_template_id": template_id, "count": count} node_groups.append(ng) plugin, hadoop_version = whelpers.\ get_plugin_and_hadoop_version(request) # TODO(nkonovalov): Fix client to support default_image_id saharaclient.cluster_template_create( request, context["general_cluster_template_name"], plugin, hadoop_version, context["general_description"], configs_dict, node_groups, context["anti_affinity_info"], ) return True except api_base.APIException as e: self.error_description = str(e) return False except Exception: exceptions.handle(request, _("Cluster template creation failed")) return False