def get_context_data(self, request): template_id = self.tab_group.kwargs['template_id'] try: template = saharaclient.nodegroup_template_get( request, template_id) except Exception as e: template = {} LOG.error( "Unable to fetch node group template details: %s" % str(e)) return {"template": template} try: flavor = nova.flavor_get(request, template.flavor_id) except Exception: flavor = {} exceptions.handle(request, _("Unable to fetch flavor for template.")) floating_ip_pool_name = None if template.floating_ip_pool: try: floating_ip_pool_name = self._get_floating_ip_pool_name( request, template.floating_ip_pool) except Exception: exceptions.handle(request, _("Unable to fetch floating ip pools.")) security_groups = helpers.get_security_groups( request, template.security_groups) return {"template": template, "flavor": flavor, "floating_ip_pool_name": floating_ip_pool_name, "security_groups": security_groups}
def get_object(self): ngt_id = self.kwargs["template_id"] try: return saharaclient.nodegroup_template_get(self.request, ngt_id) except Exception: msg = _('Unable to retrieve details for ' 'node group template "%s".') % ngt_id redirect = reverse("horizon:project:data_processing." "nodegroup_templates:nodegroup-templates") exceptions.handle(self.request, msg, redirect=redirect)
def get_context_data(self, request): template_id = self.tab_group.kwargs['template_id'] try: template = saharaclient.nodegroup_template_get( request, template_id) except Exception as e: template = {} LOG.error( "Unable to fetch node group template details: %s" % str(e)) return {"template": template}
def get_context_data(self, request): template_id = self.tab_group.kwargs['template_id'] try: template = saharaclient.nodegroup_template_get( request, template_id) except Exception as e: template = {} LOG.error("Unable to fetch node group template details: %s" % str(e)) return {"template": template}
def get_object(self, *args, **kwargs): if not hasattr(self, "_object"): template_id = self.kwargs['template_id'] try: template = saharaclient.nodegroup_template_get(self.request, template_id) except Exception: template = None exceptions.handle(self.request, _("Unable to fetch template object.")) 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.nodegroup_template_get( self.request, template_id) except Exception: template = None exceptions.handle(self.request, _("Unable to fetch template object.")) self._object = template return self._object
def get_context_data(self, request): template_id = self.tab_group.kwargs['template_id'] try: template = saharaclient.nodegroup_template_get( request, template_id) except Exception as e: template = {} LOG.error("Unable to fetch node group template details: %s" % str(e)) return {"template": template} try: flavor = nova.flavor_get(request, template.flavor_id) except Exception: flavor = {} exceptions.handle(request, _("Unable to fetch flavor for template.")) floating_ip_pool_name = None if template.floating_ip_pool: try: floating_ip_pool_name = self._get_floating_ip_pool_name( request, template.floating_ip_pool) except Exception: exceptions.handle(request, _("Unable to fetch floating ip pools.")) security_groups = helpers.get_security_groups(request, template.security_groups) return { "template": template, "flavor": flavor, "floating_ip_pool_name": floating_ip_pool_name, "security_groups": security_groups }
def __init__(self, request, context_seed, entry_point, *args, **kwargs): self.template_id = context_seed["template_id"] self.template = saharaclient.nodegroup_template_get( request, self.template_id) self._set_configs_to_copy(self.template.node_configs) plugin = self.template.plugin_name hadoop_version = self.template.hadoop_version request.GET = request.GET.copy() request.GET.update({ "plugin_name": plugin, "hadoop_version": hadoop_version }) super(CopyNodegroupTemplate, self).__init__(request, context_seed, entry_point, *args, **kwargs) g_fields = None s_fields = None for step in self.steps: if isinstance(step, create_flow.GeneralConfig): g_fields = step.action.fields if isinstance(step, create_flow.SecurityConfig): s_fields = step.action.fields g_fields["nodegroup_name"].initial = self.template.name + "-copy" g_fields["description"].initial = self.template.description g_fields["flavor"].initial = self.template.flavor_id if hasattr(self.template, "availability_zone"): g_fields["availability_zone"].initial = ( self.template.availability_zone) if hasattr(self.template, "volumes_availability_zone"): g_fields["volumes_availability_zone"].initial = \ self.template.volumes_availability_zone storage = "cinder_volume" if self.template.volumes_per_node > 0 \ else "ephemeral_drive" volumes_per_node = self.template.volumes_per_node volumes_size = self.template.volumes_size g_fields["storage"].initial = storage g_fields["volumes_per_node"].initial = volumes_per_node g_fields["volumes_size"].initial = volumes_size g_fields["volumes_availability_zone"].initial = \ self.template.volumes_availability_zone if self.template.floating_ip_pool: g_fields['floating_ip_pool'].initial = ( self.template.floating_ip_pool) s_fields["security_autogroup"].initial = ( self.template.auto_security_group) if self.template.security_groups: s_fields["security_groups"].initial = dict([ (sg, sg) for sg in self.template.security_groups ]) processes_dict = dict() try: plugin_details = saharaclient.plugin_get_version_details( request, plugin, hadoop_version) plugin_node_processes = plugin_details.node_processes except Exception: plugin_node_processes = dict() exceptions.handle(request, _("Unable to fetch plugin details.")) for process in self.template.node_processes: # need to know the service _service = None for service, processes in plugin_node_processes.items(): if process in processes: _service = service break processes_dict["%s:%s" % (_service, process)] = process g_fields["processes"].initial = processes_dict
def __init__(self, request, context_seed, entry_point, *args, **kwargs): self.template_id = context_seed["template_id"] self.template = saharaclient.nodegroup_template_get(request, self.template_id) self._set_configs_to_copy(self.template.node_configs) plugin = self.template.plugin_name hadoop_version = self.template.hadoop_version request.GET = request.GET.copy() request.GET.update({"plugin_name": plugin, "hadoop_version": hadoop_version}) super(CopyNodegroupTemplate, self).__init__(request, context_seed, entry_point, *args, **kwargs) g_fields = None snp_fields = None s_fields = None for step in self.steps: if isinstance(step, create_flow.GeneralConfig): g_fields = step.action.fields if isinstance(step, create_flow.SecurityConfig): s_fields = step.action.fields if isinstance(step, create_flow.SelectNodeProcesses): snp_fields = step.action.fields g_fields["nodegroup_name"].initial = self.template.name + "-copy" g_fields["description"].initial = self.template.description g_fields["flavor"].initial = self.template.flavor_id if hasattr(self.template, "availability_zone"): g_fields["availability_zone"].initial = self.template.availability_zone if hasattr(self.template, "volumes_availability_zone"): g_fields["volumes_availability_zone"].initial = self.template.volumes_availability_zone storage = "cinder_volume" if self.template.volumes_per_node > 0 else "ephemeral_drive" volumes_per_node = self.template.volumes_per_node volumes_size = self.template.volumes_size volume_type = self.template.volume_type volume_local_to_instance = self.template.volume_local_to_instance g_fields["storage"].initial = storage g_fields["volumes_per_node"].initial = volumes_per_node g_fields["volumes_size"].initial = volumes_size g_fields["volumes_availability_zone"].initial = self.template.volumes_availability_zone g_fields["volume_type"].initial = volume_type g_fields["volume_local_to_instance"].initial = volume_local_to_instance g_fields["proxygateway"].initial = self.template.is_proxy_gateway g_fields["use_autoconfig"].initial = self.template.use_autoconfig if self.template.floating_ip_pool: g_fields["floating_ip_pool"].initial = self.template.floating_ip_pool s_fields["security_autogroup"].initial = self.template.auto_security_group if self.template.security_groups: s_fields["security_groups"].initial = dict([(sg, sg) for sg in self.template.security_groups]) processes_dict = dict() try: plugin_details = saharaclient.plugin_get_version_details(request, plugin, hadoop_version) plugin_node_processes = plugin_details.node_processes except Exception: plugin_node_processes = dict() exceptions.handle(request, _("Unable to fetch plugin details.")) for process in self.template.node_processes: # need to know the service _service = None for service, processes in plugin_node_processes.items(): if process in processes: _service = service break processes_dict["%s:%s" % (_service, process)] = process snp_fields["processes"].initial = processes_dict