Ejemplo n.º 1
0
def save_images_tag(request, image_ids, path):
    path = u.join_path(path, "images.json")
    images = []
    for image_id in image_ids:
        image_info = sahara.image_get(request, image_id).to_dict()
        images.append(image_info)
    images_info = {"images": images}
    u.save_to_json(path, images_info)
Ejemplo n.º 2
0
 def get_object(self):
     try:
         image = saharaclient.image_get(self.request,
                                        self.kwargs["image_id"])
     except Exception:
         image = None
         msg = _("Unable to fetch the image details")
         exceptions.handle(self.request, msg)
     return image
Ejemplo n.º 3
0
 def get_object(self):
     try:
         image = saharaclient.image_get(self.request,
                                        self.kwargs["image_id"])
     except Exception:
         image = None
         msg = _("Unable to fetch the image details")
         exceptions.handle(self.request, msg)
     return image
Ejemplo n.º 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
        }
Ejemplo n.º 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}

        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}
Ejemplo n.º 6
0
    def handle(self, request, data):
        try:
            image_id = data['image_id']
            user_name = data['user_name']
            desc = data['description']
            saharaclient.image_update(request, image_id, user_name, desc)

            image_tags = json.loads(data["tags_list"])
            saharaclient.image_tags_update(request, image_id, image_tags)
            updated_image = saharaclient.image_get(request, image_id)
            messages.success(request, _("Successfully updated image."))
            return updated_image
        except Exception:
            exceptions.handle(request, _("Failed to update image."))
            return False
Ejemplo n.º 7
0
    def handle(self, request, data):
        try:
            image_id = data['image_id']
            user_name = data['user_name']
            desc = data['description']
            saharaclient.image_update(request, image_id, user_name, desc)

            image_tags = json.loads(data["tags_list"])
            saharaclient.image_tags_update(request, image_id, image_tags)
            updated_image = saharaclient.image_get(request, image_id)
            messages.success(request,
                             _("Successfully updated image."))
            return updated_image
        except Exception:
            exceptions.handle(request,
                              _("Failed to update image."))
            return False