Пример #1
0
    def test_instance_update_post_api_exception(self):
        SERVER = self.servers[0]

        self.mox.StubOutWithMock(api, 'server_get')
        self.mox.StubOutWithMock(api, 'server_update')

        api.server_get(IsA(http.HttpRequest), unicode(SERVER.id)) \
                      .AndReturn(self.servers[0])
        exception = nova_exceptions.ClientException(500)
        api.server_update(IsA(http.HttpRequest), str(SERVER.id), SERVER.name) \
                          .AndRaise(exception)

        self.mox.ReplayAll()

        formData = {
            'method': 'UpdateInstance',
            'instance': SERVER.id,
            'name': SERVER.name,
            'tenant_id': self.TEST_TENANT
        }
        url = reverse('horizon:nova:instances_and_volumes:instances:update',
                      args=[SERVER.id])
        res = self.client.post(url, formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)
Пример #2
0
    def test_instance_update_post_api_exception(self):
        INSTANCE_ID = self.servers[0].id
        NAME = 'myname'
        formData = {'method': 'UpdateInstance',
                    'instance': INSTANCE_ID,
                    'name': NAME,
                    'tenant_id': self.TEST_TENANT}

        self.mox.StubOutWithMock(api, 'server_get')
        api.server_get(IsA(http.HttpRequest),
                           unicode(INSTANCE_ID)).AndReturn(self.servers[0])

        exception = api_exceptions.ApiException('apiException')
        self.mox.StubOutWithMock(api, 'server_update')
        api.server_update(IsA(http.HttpRequest),
                          str(INSTANCE_ID), NAME).\
                          AndRaise(exception)

        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:nova:instances:update',
                                       args=[INSTANCE_ID]),
                               formData)

        self.assertRedirectsNoFollow(res,
                                     reverse('horizon:nova:instances:index'))

        self.mox.VerifyAll()
Пример #3
0
    def test_instance_update_post_api_exception(self):
        INSTANCE_ID = self.servers[0].id
        NAME = 'myname'
        formData = {
            'method': 'UpdateInstance',
            'instance': INSTANCE_ID,
            'name': NAME,
            'tenant_id': self.TEST_TENANT
        }

        self.mox.StubOutWithMock(api, 'server_get')
        api.server_get(IsA(http.HttpRequest),
                       unicode(INSTANCE_ID)).AndReturn(self.servers[0])

        exception = api_exceptions.ApiException('apiException')
        self.mox.StubOutWithMock(api, 'server_update')
        api.server_update(IsA(http.HttpRequest),
                          str(INSTANCE_ID), NAME).\
                          AndRaise(exception)

        self.mox.ReplayAll()

        res = self.client.post(
            reverse('horizon:nova:instances_and_volumes:instances:update',
                    args=[INSTANCE_ID]), formData)

        self.assertRedirectsNoFollow(
            res, reverse('horizon:nova:instances_and_volumes:instances:index'))
Пример #4
0
    def handle(self, request, data):
        try:
            api.server_update(request, data['instance'], data['name'])
            messages.success(request,
                             _('Instance "%s" updated.') % data['name'])
        except:
            exceptions.handle(request, _('Unable to update instance.'))

        return shortcuts.redirect('horizon:nova:instances_and_volumes:index')
Пример #5
0
 def handle(self, request, data):
     tenant_id = data['tenant_id']
     try:
         api.server_update(request, data['instance'], data['name'])
         messages.success(request,
                          _("Instance '%s' updated") % data['name'])
     except api_exceptions.ApiException, e:
         messages.error(request,
                        _('Unable to update instance: %s') % e.message)
Пример #6
0
    def handle(self, request, data):
        try:
            api.server_update(request, data['instance'], data['name'])
            messages.success(request,
                             _('Instance "%s" updated.') % data['name'])
        except:
            exceptions.handle(request, _('Unable to update instance.'))

        return shortcuts.redirect('horizon:nova:instances:index')
Пример #7
0
 def handle(self, request, data):
     tenant_id = data['tenant_id']
     try:
         api.server_update(request,
                           data['instance'],
                           data['name'])
         messages.success(request, _("Instance '%s' updated") %
                                   data['name'])
     except api_exceptions.ApiException, e:
         messages.error(request,
                    _('Unable to update instance: %s') % e.message)
Пример #8
0
    def test_instance_update_post(self):
        server = self.servers.first()

        self.mox.StubOutWithMock(api, "server_get")
        self.mox.StubOutWithMock(api, "server_update")
        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.server_update(IsA(http.HttpRequest), server.id, server.name)
        self.mox.ReplayAll()

        formData = {"method": "UpdateInstance", "instance": server.id, "name": server.name, "tenant_id": self.tenant.id}
        url = reverse("horizon:nova:instances_and_volumes:instances:update", args=[server.id])
        res = self.client.post(url, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
Пример #9
0
    def test_instance_update_post_api_exception(self):
        server = self.servers.first()

        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.server_update(IsA(http.HttpRequest), server.id, server.name).AndRaise(self.exceptions.nova)

        self.mox.ReplayAll()

        formData = {"method": "UpdateInstance", "instance": server.id, "name": server.name, "tenant_id": self.tenant.id}
        url = reverse("horizon:project:instances:update", args=[server.id])
        res = self.client.post(url, formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)
Пример #10
0
    def test_instance_update_post(self):
        server = self.servers.first()

        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.server_update(IsA(http.HttpRequest), server.id, server.name)

        self.mox.ReplayAll()

        formData = {'method': 'UpdateInstance',
                    'instance': server.id,
                    'name': server.name,
                    'tenant_id': self.tenant.id}
        url = reverse('horizon:nova:instances:update',
                      args=[server.id])
        res = self.client.post(url, formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)
Пример #11
0
    def test_instance_update_post(self):
        server = self.servers.first()

        self.mox.StubOutWithMock(api, 'server_get')
        self.mox.StubOutWithMock(api, 'server_update')
        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.server_update(IsA(http.HttpRequest), server.id, server.name)
        self.mox.ReplayAll()

        formData = {'method': 'UpdateInstance',
                    'instance': server.id,
                    'name': server.name,
                    'tenant_id': self.tenant.id}
        url = reverse('horizon:nova:instances_and_volumes:instances:update',
                      args=[server.id])
        res = self.client.post(url, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
Пример #12
0
    def test_instance_update_post_api_exception(self):
        server = self.servers.first()

        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.server_update(IsA(http.HttpRequest), server.id, server.name) \
                          .AndRaise(self.exceptions.nova)

        self.mox.ReplayAll()

        formData = {'method': 'UpdateInstance',
                    'instance': server.id,
                    'name': server.name,
                    'tenant_id': self.tenant.id}
        url = reverse('horizon:nova:instances:update',
                      args=[server.id])
        res = self.client.post(url, formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)
Пример #13
0
    def test_instance_update_post_api_exception(self):
        server = self.servers.first()

        self.mox.StubOutWithMock(api, 'server_get')
        self.mox.StubOutWithMock(api, 'server_update')
        api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
        api.server_update(IsA(http.HttpRequest), server.id, server.name) \
                          .AndRaise(self.exceptions.nova)
        self.mox.ReplayAll()

        formData = {
            'method': 'UpdateInstance',
            'instance': server.id,
            'name': server.name,
            'tenant_id': self.tenant.id
        }
        url = reverse('horizon:nova:instances_and_volumes:instances:update',
                      args=[server.id])
        res = self.client.post(url, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
Пример #14
0
 def handle(self, request, data):
     try:
         server = api.server_update(request, data['instance'], data['name'])
         messages.success(request,
                          _('Instance "%s" updated.') % data['name'])
         return server
     except:
         redirect = reverse("horizon:project:instances:index")
         exceptions.handle(request,
                           _('Unable to update instance.'),
                           redirect=redirect)
Пример #15
0
 def handle(self, request, data):
     try:
         server = api.server_update(request, data['instance'], data['name'])
         messages.success(request,
                          _('Instance "%s" updated.') % data['name'])
         return server
     except:
         redirect = reverse("horizon:project:instances:index")
         exceptions.handle(request,
                           _('Unable to update instance.'),
                           redirect=redirect)
Пример #16
0
    def test_instance_update_post_api_exception(self):
        SERVER = self.servers[0]

        self.mox.StubOutWithMock(api, 'server_get')
        self.mox.StubOutWithMock(api, 'server_update')

        api.server_get(IsA(http.HttpRequest), unicode(SERVER.id)) \
                      .AndReturn(self.servers[0])
        exception = nova_exceptions.ClientException(500)
        api.server_update(IsA(http.HttpRequest), str(SERVER.id), SERVER.name) \
                          .AndRaise(exception)

        self.mox.ReplayAll()

        formData = {'method': 'UpdateInstance',
                    'instance': SERVER.id,
                    'name': SERVER.name,
                    'tenant_id': self.TEST_TENANT}
        url = reverse('horizon:nova:instances_and_volumes:instances:update',
                      args=[SERVER.id])
        res = self.client.post(url, formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)
Пример #17
0
    def test_instance_update_post(self):
        INSTANCE_ID = self.servers[0].id
        NAME = 'myname'
        formData = {'method': 'UpdateInstance',
                    'instance': self.servers[0].id,
                    'name': NAME,
                    'tenant_id': self.TEST_TENANT}

        self.mox.StubOutWithMock(api, 'server_get')
        api.server_get(IsA(http.HttpRequest),
                           unicode(INSTANCE_ID)).AndReturn(self.servers[0])

        self.mox.StubOutWithMock(api, 'server_update')
        api.server_update(IsA(http.HttpRequest),
                          str(INSTANCE_ID), NAME)

        self.mox.ReplayAll()

        res = self.client.post(
                reverse('horizon:nova:instances_and_volumes:instances:update',
                        args=[INSTANCE_ID]), formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)