Пример #1
0
 def action(self, request, obj_id):
     if self.suspended:
         api.server_resume(request, obj_id)
         self.current_past_action = RESUME
     else:
         api.server_suspend(request, obj_id)
         self.current_past_action = SUSPEND
Пример #2
0
 def action(self, request, obj_id):
     if self.suspended:
         api.server_resume(request, obj_id)
         self.current_past_action = RESUME
     else:
         api.server_suspend(request, obj_id)
         self.current_past_action = SUSPEND
Пример #3
0
    def test_resume_instance(self):
        server = self.servers.first()
        server.status = "SUSPENDED"
        self.mox.StubOutWithMock(api, 'server_resume')
        self.mox.StubOutWithMock(api, 'server_list')
        api.server_list(IsA(http.HttpRequest)).AndReturn(self.servers.list())
        api.server_resume(IsA(http.HttpRequest), unicode(server.id))
        self.mox.ReplayAll()

        formData = {'action': 'instances__suspend__%s' % server.id}
        res = self.client.post(INDEX_URL, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
    def test_resume_instance(self):
        server = self.servers.first()
        server.status = "SUSPENDED"
        self.mox.StubOutWithMock(api, 'server_resume')
        self.mox.StubOutWithMock(api, 'server_list')
        api.server_list(IsA(http.HttpRequest)).AndReturn(self.servers.list())
        api.server_resume(IsA(http.HttpRequest), unicode(server.id))
        self.mox.ReplayAll()

        formData = {'action': 'instances__suspend__%s' % server.id}
        res = self.client.post(INDEX_URL, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
Пример #5
0
    def test_resume_instance_exception(self):
        server = self.servers.first()
        server.status = "SUSPENDED"

        api.flavor_list(IsA(http.HttpRequest)).AndReturn(self.flavors.list())
        api.server_list(IsA(http.HttpRequest)).AndReturn(self.servers.list())
        api.server_resume(IsA(http.HttpRequest), unicode(server.id)).AndRaise(self.exceptions.nova)

        self.mox.ReplayAll()

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

        self.assertRedirectsNoFollow(res, INDEX_URL)
Пример #6
0
    def test_resume_instance_exception(self):
        server = self.servers.first()
        server.status = "SUSPENDED"

        api.flavor_list(IsA(http.HttpRequest)).AndReturn(self.flavors.list())
        api.server_list(IsA(http.HttpRequest)).AndReturn(self.servers.list())
        api.server_resume(IsA(http.HttpRequest),
                          unicode(server.id)).AndRaise(self.exceptions.nova)

        self.mox.ReplayAll()

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

        self.assertRedirectsNoFollow(res, INDEX_URL)
Пример #7
0
 def action(self, request, obj_id):
     if getattr(self, 'suspended', False):
         api.server_suspend(request, obj_id)
     else:
         api.server_resume(request, obj_id)
Пример #8
0
 def action(self, request, obj_id):
     if getattr(self, 'suspended', False):
         api.server_suspend(request, obj_id)
     else:
         api.server_resume(request, obj_id)