Example #1
0
    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:
            template = {}
            exceptions.handle(request,
                              _("Unable to fetch node group 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}
Example #2
0
    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}
Example #3
0
 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:
         template = {}
         exceptions.handle(request, _("Unable to fetch node group template."))
     return {"template": template}
Example #4
0
    def __init__(self, request, context_seed, entry_point, *args, **kwargs):
        template_id = context_seed["template_id"]
        template = saharaclient.nodegroup_template_get(request, template_id)
        self._set_configs_to_copy(template.node_configs)

        plugin = template.plugin_name
        hadoop_version = 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)

        for step in self.steps:
            if not isinstance(step, create_flow.GeneralConfig):
                continue
            fields = step.action.fields

            fields["nodegroup_name"].initial = template.name + "-copy"
            fields["description"].initial = template.description
            fields["flavor"].initial = template.flavor_id
            fields["availability_zone"].initial = template.availability_zone

            storage = "cinder_volume" if template.volumes_per_node > 0 \
                else "ephemeral_drive"
            volumes_per_node = template.volumes_per_node
            volumes_size = template.volumes_size
            fields["storage"].initial = storage
            fields["volumes_per_node"].initial = volumes_per_node
            fields["volumes_size"].initial = volumes_size

            if template.floating_ip_pool:
                fields['floating_ip_pool'].initial = template.floating_ip_pool

            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 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
            fields["processes"].initial = processes_dict
Example #5
0
 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}
Example #6
0
 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
Example #7
0
 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:
         template = {}
         exceptions.handle(request,
                           _("Unable to fetch node group template."))
     return {"template": template}
Example #8
0
 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)
Example #9
0
 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}
Example #10
0
 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)
Example #11
0
 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
Example #12
0
 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:
         template = {}
         exceptions.handle(request,
                           _("Unable to fetch node group template."))
     try:
         flavor = nova.flavor_get(request, template.flavor_id)
     except Exception:
         flavor = {}
         exceptions.handle(request,
                           _("Unable to fetch flavor for template."))
     return {"template": template, "flavor": flavor}
Example #13
0
    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:
            template = {}
            exceptions.handle(request, _("Unable to fetch node group 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."))

        return {"template": template, "flavor": flavor, "floating_ip_pool_name": floating_ip_pool_name}
Example #14
0
    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
        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
        snp_fields["processes"].initial = processes_dict