Beispiel #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}
Beispiel #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}
Beispiel #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."))

        base_image_name = None
        if template.image_id:
            try:
                base_image_name = saharaclient.image_get(
                    request, template.image_id).name
            except Exception:
                exceptions.handle(
                    request,
                    _("Unable to fetch Base Image with id: %s.") %
                    template.image_id)

        security_groups = helpers.get_security_groups(request,
                                                      template.security_groups)

        if getattr(template, 'boot_from_volume', None) is None:
            show_bfv = False
        else:
            show_bfv = True

        return {
            "template": template,
            "flavor": flavor,
            "floating_ip_pool_name": floating_ip_pool_name,
            "base_image_name": base_image_name,
            "security_groups": security_groups,
            "show_bfv": show_bfv
        }
Beispiel #4
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."))

        base_image_name = None
        if template.image_id:
            try:
                base_image_name = saharaclient.image_get(
                    request, template.image_id).name
            except Exception:
                exceptions.handle(request,
                                  _("Unable to fetch Base Image with id: %s.")
                                  % template.image_id)

        security_groups = helpers.get_security_groups(
            request, template.security_groups)

        if getattr(template, 'boot_from_volume', None) is None:
            show_bfv = False
        else:
            show_bfv = True

        return {"template": template, "flavor": flavor,
                "floating_ip_pool_name": floating_ip_pool_name,
                "base_image_name": base_image_name,
                "security_groups": security_groups,
                "show_bfv": show_bfv}
Beispiel #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}
Beispiel #6
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}