예제 #1
0
    def test_terminate_instance_exception(self):
        formData = {
            'method': 'TerminateInstance',
            'instance': self.servers[0].id,
        }

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

        exception = api_exceptions.ApiException('ApiException',
                                                message='apiException')
        self.mox.StubOutWithMock(api, 'server_delete')
        api.server_delete(IsA(http.HttpRequest),
                          self.servers[0]).AndRaise(exception)

        self.mox.StubOutWithMock(messages, 'error')
        messages.error(IsA(http.HttpRequest), IsA(unicode))

        self.mox.ReplayAll()

        res = self.client.post(
            reverse('horizon:nova:instances_and_volumes:instances:index'),
            formData)

        self.assertRedirectsNoFollow(
            res, reverse('horizon:nova:instances_and_volumes:instances:index'))
예제 #2
0
파일: tests.py 프로젝트: katzj/horizon
    def test_terminate_instance_exception(self):
        formData = {'method': 'TerminateInstance',
                    'instance': self.servers[0].id,
                    }

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

        exception = api_exceptions.ApiException('ApiException',
                                                message='apiException')
        self.mox.StubOutWithMock(api, 'server_delete')
        api.server_delete(IsA(http.HttpRequest),
                          self.servers[0]).AndRaise(exception)

        self.mox.StubOutWithMock(messages, 'error')
        messages.error(IsA(http.HttpRequest), IsA(unicode))

        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:nova:instances:index'),
                               formData)

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

        self.mox.VerifyAll()
예제 #3
0
    def handle(self, request, data):
        instance_id = data['instance']
        instance = api.server_get(request, instance_id)

        try:
            api.server_delete(request, instance)
        except api_exceptions.ApiException, e:
            LOG.exception(_('ApiException while terminating instance "%s"') %
                      instance_id)
            messages.error(request,
                           _('Unable to terminate %(inst)s: %(message)s') %
                           {"inst": instance_id, "message": e.message})
예제 #4
0
파일: tests.py 프로젝트: zhang-hua/horizon
    def test_terminate_instance(self):
        server = self.servers.first()

        api.server_list(IsA(http.HttpRequest)).AndReturn(self.servers.list())
        api.flavor_list(IgnoreArg()).AndReturn(self.flavors.list())
        api.server_delete(IsA(http.HttpRequest), server.id)

        self.mox.ReplayAll()

        formData = {'action': 'instances__terminate__%s' % server.id}
        res = self.client.post(INDEX_URL, formData)

        self.assertRedirectsNoFollow(res, INDEX_URL)
예제 #5
0
    def test_terminate_instance_exception(self):
        server = self.servers.first()
        self.mox.StubOutWithMock(api, 'server_list')
        self.mox.StubOutWithMock(api, 'flavor_list')
        self.mox.StubOutWithMock(api, 'server_delete')
        api.server_list(IsA(http.HttpRequest)).AndReturn(self.servers.list())
        api.flavor_list(IgnoreArg()).AndReturn(self.flavors.list())
        exc = nova_exceptions.ClientException(500)
        api.server_delete(IsA(http.HttpRequest), server.id).AndRaise(exc)
        self.mox.ReplayAll()

        formData = {'action': 'instances__terminate__%s' % server.id}
        res = self.client.post(INDEX_URL, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
    def test_terminate_instance_exception(self):
        server = self.servers.first()
        self.mox.StubOutWithMock(api, 'server_list')
        self.mox.StubOutWithMock(api, 'flavor_list')
        self.mox.StubOutWithMock(api, 'server_delete')
        api.server_list(IsA(http.HttpRequest)).AndReturn(self.servers.list())
        api.flavor_list(IgnoreArg()).AndReturn(self.flavors.list())
        exc = nova_exceptions.ClientException(500)
        api.server_delete(IsA(http.HttpRequest), server.id).AndRaise(exc)
        self.mox.ReplayAll()

        formData = {'action': 'instances__terminate__%s' % server.id}
        res = self.client.post(INDEX_URL, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
예제 #7
0
파일: tests.py 프로젝트: haluomao/horizon
    def test_terminate_instance_exception(self):
        server = self.servers.first()
        self.mox.StubOutWithMock(api, "server_list")
        self.mox.StubOutWithMock(api, "flavor_list")
        self.mox.StubOutWithMock(api, "server_delete")
        self.mox.StubOutWithMock(api, "volume_list")
        api.volume_list(IsA(http.HttpRequest)).AndReturn(self.volumes.list())
        api.server_list(IsA(http.HttpRequest)).AndReturn(self.servers.list())
        api.flavor_list(IgnoreArg()).AndReturn(self.flavors.list())
        api.server_delete(IsA(http.HttpRequest), server.id).AndRaise(self.exceptions.nova)
        self.mox.ReplayAll()

        formData = {"action": "instances__terminate__%s" % server.id}
        res = self.client.post(INDEX_URL, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
예제 #8
0
파일: forms.py 프로젝트: termie/horizon
    def handle(self, request, data):
        instance_id = data['instance']
        instance = api.server_get(request, instance_id)

        try:
            api.server_delete(request, instance)
        except api_exceptions.ApiException, e:
            LOG.exception(
                _('ApiException while terminating instance "%s"') %
                instance_id)
            messages.error(
                request,
                _('Unable to terminate %(inst)s: %(message)s') % {
                    "inst": instance_id,
                    "message": e.message
                })
예제 #9
0
    def test_terminate_instance(self):
        formData = {'method': 'TerminateInstance',
                    'instance': self.servers[0].id,
                    }

        self.mox.StubOutWithMock(api, 'server_get')
        api.server_get(IsA(http.HttpRequest),
                       str(self.servers[0].id)).AndReturn(self.servers[0])
        self.mox.StubOutWithMock(api, 'server_delete')
        api.server_delete(IsA(http.HttpRequest),
                          self.servers[0])

        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:nova:instances:index'),
                               formData)

        self.assertRedirectsNoFollow(res,
                                     reverse('horizon:nova:instances:index'))
예제 #10
0
    def test_terminate_instance(self):
        formData = {'method': 'TerminateInstance',
                    'instance': self.servers[0].id,
                    }

        self.mox.StubOutWithMock(api, 'server_get')
        api.server_get(IsA(http.HttpRequest),
                       str(self.servers[0].id)).AndReturn(self.servers[0])
        self.mox.StubOutWithMock(api, 'server_delete')
        api.server_delete(IsA(http.HttpRequest),
                          self.servers[0])

        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:nova:instances:index'),
                               formData)

        self.assertRedirectsNoFollow(res,
                                     reverse('horizon:nova:instances:index'))
예제 #11
0
파일: tables.py 프로젝트: mshabdiz/horizon
 def action(self, request, obj_id):
     api.server_delete(request, obj_id)
예제 #12
0
 def action(self, request, obj_id):
     api.server_delete(request, obj_id)