Ejemplo n.º 1
0
    def handle(self, request, data):
        index = "horizon:hpcloud:containers:index"
        orig_container = data['orig_container_name']
        orig_object = data['orig_object_name']
        new_container = data['new_container_name']
        new_object = data['new_object_name']
        path = data['path']
        if path and not path.endswith("/"):
            path = path + "/"
        new_path = "%s%s" % (path, new_object)

        # Now copy the object itself.
        try:
            api.swift.swift_copy_object(request, orig_container, orig_object,
                                        new_container, new_path)
            dest = "%s/%s" % (new_container, path)
            vals = {
                "dest": dest.rstrip("/"),
                "orig": orig_object.split("/")[-1],
                "new": new_object
            }
            messages.success(
                request,
                _('Copied "%(orig)s" to "%(dest)s" as "%(new)s".') % vals)
            return True
        except exceptions.HorizonException as exc:
            messages.error(request, exc)
            raise exceptions.Http302(
                reverse(index, args=[tables.wrap_delimiter(orig_container)]))
        except Exception:
            redirect = reverse(index,
                               args=[tables.wrap_delimiter(orig_container)])
            exceptions.handle(request,
                              _("Unable to copy object."),
                              redirect=redirect)
Ejemplo n.º 2
0
    def handle(self, request, data):
        index = "horizon:hpcloud:containers:index"
        orig_container = data['orig_container_name']
        orig_object = data['orig_object_name']
        new_container = data['new_container_name']
        new_object = data['new_object_name']
        path = data['path']
        if path and not path.endswith("/"):
            path = path + "/"
        new_path = "%s%s" % (path, new_object)

        # Now copy the object itself.
        try:
            api.swift.swift_copy_object(request,
                                        orig_container,
                                        orig_object,
                                        new_container,
                                        new_path)
            dest = "%s/%s" % (new_container, path)
            vals = {"dest": dest.rstrip("/"),
                    "orig": orig_object.split("/")[-1],
                    "new": new_object}
            messages.success(request,
                             _('Copied "%(orig)s" to "%(dest)s" as "%(new)s".')
                             % vals)
            return True
        except exceptions.HorizonException as exc:
            messages.error(request, exc)
            raise exceptions.Http302(reverse(index,
                args=[tables.wrap_delimiter(orig_container)]))
        except Exception:
            redirect = reverse(index,
                               args=[tables.wrap_delimiter(orig_container)])
            exceptions.handle(request,
                              _("Unable to copy object."),
                              redirect=redirect)
Ejemplo n.º 3
0
 def get_success_url(self):
     new_container_name = self.request.POST['new_container_name']
     return reverse(self.success_url,
                    args=(tables.wrap_delimiter(new_container_name),
                          tables.wrap_delimiter(
                              self.request.POST.get('path', ''))))
Ejemplo n.º 4
0
 def get_success_url(self):
     new_container_name = self.request.POST['new_container_name']
     return reverse(self.success_url,
                    args=(tables.wrap_delimiter(new_container_name),
                          tables.wrap_delimiter(
                              self.request.POST.get('path', ''))))