Example #1
0
    def test_update_volume_status(self):
        volume = self.volumes.first()
        formData = {"status": "error"}

        cinder.volume_get(IsA(http.HttpRequest), volume.id).AndReturn(volume)
        cinder.volume_reset_state(IsA(http.HttpRequest), volume.id, formData["status"])
        self.mox.ReplayAll()

        res = self.client.post(reverse("horizon:admin:volumes:volumes:update_status", args=(volume.id,)), formData)
        self.assertNoFormErrors(res)
Example #2
0
    def test_update_volume_status(self):
        volume = self.volumes.first()
        formData = {'status': 'error'}

        cinder.volume_get(IsA(http.HttpRequest), volume.id).AndReturn(volume)
        cinder.volume_reset_state(IsA(http.HttpRequest), volume.id,
                                  formData['status'])
        self.mox.ReplayAll()

        res = self.client.post(
            reverse('horizon:admin:volumes:volumes:update_status',
                    args=(volume.id, )), formData)
        self.assertNoFormErrors(res)
Example #3
0
    def handle(self, request, data):
        # Obtain the localized status for including in the message
        for choice in self.fields["status"].choices:
            if choice[0] == data["status"]:
                new_status = choice[1]
                break
        else:
            new_status = data["status"]

        try:
            cinder.volume_reset_state(request, self.initial["volume_id"], data["status"])
            messages.success(request, _('Successfully updated volume status to "%s".') % new_status)
            return True
        except Exception:
            redirect = reverse("horizon:admin:volumes:index")
            exceptions.handle(request, _('Unable to update volume status to "%s".') % new_status, redirect=redirect)
Example #4
0
    def handle(self, request, data):
        # Obtain the localized status for including in the message
        for choice in self.fields['status'].choices:
            if choice[0] == data['status']:
                new_status = choice[1]
                break
        else:
            new_status = data['status']

        try:
            cinder.volume_reset_state(request, self.initial['volume_id'],
                                      data['status'])
            messages.success(
                request,
                _('Successfully updated volume status to "%s".') % new_status)
            return True
        except Exception:
            exceptions.handle(
                request,
                _('Unable to update volume status to "%s".') % new_status)
            return False
Example #5
0
    def handle(self, request, data):
        # Obtain the localized status for including in the message
        for choice in self.fields['status'].choices:
            if choice[0] == data['status']:
                new_status = choice[1]
                break
        else:
            new_status = data['status']

        try:
            cinder.volume_reset_state(request,
                                      self.initial['volume_id'],
                                      data['status'])
            messages.success(request,
                             _('Successfully updated volume status to "%s".') %
                             new_status)
            return True
        except Exception:
            exceptions.handle(request,
                              _('Unable to update volume status to "%s".') %
                             new_status)
            return False