Ejemplo n.º 1
0
 def handle(self, request, data):
     try:
         cinder.volume_migrate(request, self.initial["volume_id"], data["host"], data["force_host_copy"])
         messages.success(request, _("Successfully sent the request to migrate volume: %s") % data["name"])
         return True
     except Exception:
         redirect = reverse("horizon:admin:volumes:volumes_tab")
         exceptions.handle(request, _("Failed to migrate volume."), redirect=redirect)
Ejemplo n.º 2
0
    def test_volume_migrate_post_api_exception(self):
        volume = self.cinder_volumes.get(name="v2_volume")
        host = self.cinder_pools.first().name

        cinder.volume_get(IsA(http.HttpRequest), volume.id).AndReturn(volume)
        cinder.pool_list(IsA(http.HttpRequest)).AndReturn(self.cinder_pools.list())
        cinder.volume_migrate(IsA(http.HttpRequest), volume.id, host, False).AndRaise(self.exceptions.cinder)

        self.mox.ReplayAll()

        url = reverse("horizon:admin:volumes:volumes:migrate", args=[volume.id])
        res = self.client.post(url, {"host": host, "volume_id": volume.id})
        self.assertRedirectsNoFollow(res, INDEX_URL)
Ejemplo n.º 3
0
 def handle(self, request, data):
     try:
         cinder.volume_migrate(request, self.initial['volume_id'],
                               data['host'], data['force_host_copy'])
         messages.success(
             request,
             _('Successfully sent the request to migrate volume: %s') %
             data['name'])
         return True
     except Exception:
         redirect = reverse("horizon:admin:volumes:index")
         exceptions.handle(request,
                           _("Failed to migrate volume."),
                           redirect=redirect)
Ejemplo n.º 4
0
 def handle(self, request, data):
     try:
         cinder.volume_migrate(request,
                               self.initial['volume_id'],
                               data['host'],
                               data['force_host_copy'])
         messages.success(
             request,
             _('Successfully sent the request to migrate volume: %s')
             % data['name'])
         return True
     except Exception:
         redirect = reverse("horizon:admin:volumes:index")
         exceptions.handle(request, _("Failed to migrate volume."),
                           redirect=redirect)
Ejemplo n.º 5
0
    def test_volume_migrate_post_api_exception(self):
        volume = self.cinder_volumes.get(name='v2_volume')
        host = self.cinder_pools.first().name

        cinder.volume_get(IsA(http.HttpRequest), volume.id) \
            .AndReturn(volume)
        cinder.pool_list(IsA(http.HttpRequest)) \
            .AndReturn(self.cinder_pools.list())
        cinder.volume_migrate(IsA(http.HttpRequest),
                              volume.id,
                              host,
                              False) \
            .AndRaise(self.exceptions.cinder)

        self.mox.ReplayAll()

        url = reverse('horizon:admin:volumes:migrate', args=[volume.id])
        res = self.client.post(url, {'host': host, 'volume_id': volume.id})
        self.assertRedirectsNoFollow(res, INDEX_URL)
Ejemplo n.º 6
0
    def test_volume_migrate_post(self):
        volume = self.cinder_volumes.get(name='v2_volume')
        host = self.pools.first().name

        cinder.volume_get(IsA(http.HttpRequest), volume.id) \
            .AndReturn(volume)
        cinder.pool_list(IsA(http.HttpRequest)) \
            .AndReturn(self.pools.list())
        cinder.volume_migrate(IsA(http.HttpRequest),
                              volume.id,
                              host,
                              False) \
            .AndReturn(None)

        self.mox.ReplayAll()

        url = reverse('horizon:admin:volumes:volumes:migrate',
                      args=[volume.id])
        res = self.client.post(url, {'host': host, 'volume_id': volume.id})
        self.assertNoFormErrors(res)
        self.assertRedirectsNoFollow(res, INDEX_URL)