Esempio n. 1
0
    def get_context_data(self, request):
        cluster_id = self.tab_group.kwargs['cluster_id']
        try:
            sahara = saharaclient.client(request)
            cluster = sahara.clusters.get(cluster_id)
            for ng in cluster.node_groups:
                if ng["flavor_id"]:
                    ng["flavor_name"] = (nova.flavor_get(
                        request, ng["flavor_id"]).name)
                if ng["floating_ip_pool"]:
                    ng["floating_ip_pool_name"] = (
                        self._get_floating_ip_pool_name(
                            request, ng["floating_ip_pool"]))

                if ng.get("node_group_template_id", None):
                    ng["node_group_template"] = saharaclient.safe_call(
                        sahara.node_group_templates.get,
                        ng["node_group_template_id"])

                ng["security_groups_full"] = helpers.get_security_groups(
                    request, ng["security_groups"])
        except Exception:
            cluster = {}
            exceptions.handle(request, _("Unable to get node group details."))

        return {"cluster": cluster}
Esempio n. 2
0
    def get_context_data(self, request):
        cluster_id = self.tab_group.kwargs['cluster_id']
        try:
            sahara = saharaclient.client(request)
            cluster = sahara.clusters.get(cluster_id)
            for ng in cluster.node_groups:
                if ng["flavor_id"]:
                    ng["flavor_name"] = (
                        nova.flavor_get(request, ng["flavor_id"]).name)
                if ng["floating_ip_pool"]:
                    ng["floating_ip_pool_name"] = (
                        self._get_floating_ip_pool_name(
                            request, ng["floating_ip_pool"]))

                if ng.get("node_group_template_id", None):
                    ng["node_group_template"] = saharaclient.safe_call(
                        sahara.node_group_templates.get,
                        ng["node_group_template_id"])

                ng["security_groups_full"] = helpers.get_security_groups(
                    request, ng["security_groups"])
        except Exception:
            cluster = {}
            exceptions.handle(request,
                              _("Unable to get node group details."))

        return {"cluster": cluster}
Esempio n. 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 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}
Esempio n. 4
0
 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}
Esempio n. 5
0
 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}
Esempio n. 6
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
        }