Esempio n. 1
0
 def handle(self, request, data):
     instance_id = data["instance"]
     try:
         server = api.server_reboot(request, instance_id)
         messages.success(request, "Instance rebooting")
     except api_exceptions.ApiException, e:
         LOG.exception('ApiException while rebooting instance "%s"' % instance_id)
         messages.error(request, _("Unable to reboot instance: %s") % e.message)
 def handle(self, request, data):
     instance_id = data['instance']
     try:
         server = api.server_reboot(request, instance_id)
         messages.success(request, "Instance rebooting")
     except api_exceptions.ApiException, e:
         messages.error(request,
                    'Unable to reboot instance: %s' % e.message)
Esempio n. 3
0
    def test_reboot_instance(self):
        formData = {'method': 'RebootInstance',
                    'instance': self.servers[0].id,
                    }

        self.mox.StubOutWithMock(api, 'server_reboot')
        api.server_reboot(IsA(http.HttpRequest), unicode(self.servers[0].id))

        self.mox.ReplayAll()

        res = self.client.post(reverse('dash_instances',
                                       args=[self.TEST_TENANT]),
                               formData)

        self.assertRedirectsNoFollow(res, reverse('dash_instances',
                                                  args=[self.TEST_TENANT]))

        self.mox.VerifyAll()
 def handle(self, request, data):
     instance_id = data['instance']
     try:
         server = api.server_reboot(request, instance_id)
         messages.success(request, "Instance rebooting")
     except api_exceptions.ApiException, e:
         LOG.error('ApiException while rebooting instance "%s"' %
                   instance_id, exc_info=True)
         messages.error(request,
                    'Unable to reboot instance: %s' % e.message)
Esempio n. 5
0
 def handle(self, request, data):
     instance_id = data['instance']
     try:
         server = api.server_reboot(request, instance_id)
         messages.success(request, _("Instance rebooting"))
     except api_exceptions.ApiException, e:
         LOG.exception(
             _('ApiException while rebooting instance "%s"') % instance_id)
         messages.error(request,
                        _('Unable to reboot instance: %s') % e.message)
    def test_server_reboot(self):
        INSTANCE_ID = "2"
        HARDNESS = "diamond"

        self.mox.StubOutWithMock(api, "server_get")

        server = self.mox.CreateMock(OSCompute.Server)
        server.reboot(OSCompute.servers.REBOOT_HARD).AndReturn(TEST_RETURN)
        api.server_get(IsA(http.HttpRequest), INSTANCE_ID).AndReturn(server)

        server = self.mox.CreateMock(OSCompute.Server)
        server.reboot(HARDNESS).AndReturn(TEST_RETURN)
        api.server_get(IsA(http.HttpRequest), INSTANCE_ID).AndReturn(server)

        self.mox.ReplayAll()

        ret_val = api.server_reboot(self.request, INSTANCE_ID)
        self.assertIsNone(ret_val)

        ret_val = api.server_reboot(self.request, INSTANCE_ID, hardness=HARDNESS)
        self.assertIsNone(ret_val)

        self.mox.VerifyAll()
Esempio n. 7
0
    def test_reboot_instance_exception(self):
        formData = {'method': 'RebootInstance',
                    'instance': self.servers[0].id,
                    }

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

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

        self.mox.ReplayAll()

        res = self.client.post(reverse('dash_instances',
                                       args=[self.TEST_TENANT]),
                               formData)

        self.assertRedirectsNoFollow(res, reverse('dash_instances',
                                                  args=[self.TEST_TENANT]))

        self.mox.VerifyAll()