def handle(self, request, data): try: cinder.volume_snapshot_reset_state(request, self.initial["snapshot_id"], data["status"]) choices = dict(STATUS_CHOICES) choice = choices[data["status"]] messages.success(request, _("Successfully updated volume snapshot" ' status: "%s".') % choice) return True except Exception: exceptions.handle(request, _("Unable to update volume snapshot status.")) return False
def handle(self, request, data): try: cinder.volume_snapshot_reset_state(request, self.initial['snapshot_id'], data['status']) choices = dict(STATUS_CHOICES) choice = choices[data['status']] messages.success(request, _('Successfully updated volume snapshot' ' status: "%s".') % choice) return True except Exception: exceptions.handle(request, _('Unable to update volume snapshot status.')) return False
def test_update_snapshot_status(self): snapshot = self.cinder_volume_snapshots.first() state = 'error' cinder.volume_snapshot_get(IsA(http.HttpRequest), snapshot.id) \ .AndReturn(snapshot) cinder.volume_snapshot_reset_state(IsA(http.HttpRequest), snapshot.id, state) self.mox.ReplayAll() formData = {'status': state} url = reverse('horizon:admin:snapshots:update_status', args=(snapshot.id, )) res = self.client.post(url, formData) self.assertNoFormErrors(res)
def handle(self, request, data): try: cinder.volume_snapshot_reset_state(request, self.initial['snapshot_id'], data['status']) choices = dict(STATUS_CHOICES) choice = choices[data['status']] messages.success(request, _('Successfully updated volume snapshot' ' status: "%s".') % choice) return True except Exception: redirect = reverse("horizon:admin:snapshots:index") exceptions.handle(request, _('Unable to update volume snapshot status.'), redirect=redirect)
def test_update_snapshot_status(self): snapshot = self.cinder_volume_snapshots.first() state = 'error' cinder.volume_snapshot_get(IsA(http.HttpRequest), snapshot.id) \ .AndReturn(snapshot) cinder.volume_snapshot_reset_state(IsA(http.HttpRequest), snapshot.id, state) self.mox.ReplayAll() formData = {'status': state} url = reverse('horizon:admin:volumes:snapshots:update_status', args=(snapshot.id,)) res = self.client.post(url, formData) self.assertNoFormErrors(res)