Fix server action resource call
Currently, action resource call of nova server doesn't work correctly in case where action API doesn't have response body. This patch fixes this issue. Change-Id: I016f74507f7d5b5792c77879969bdc271c25f829 Closes-Bug: #1528145
This commit is contained in:
parent
2574e9585a
commit
b37bced0e7
|
@ -86,16 +86,12 @@ class Server(resource.Resource):
|
|||
|
||||
return body
|
||||
|
||||
def action(self, session, body, has_response=False):
|
||||
def action(self, session, body):
|
||||
"""Preform server actions given the message body."""
|
||||
url = utils.urljoin(self.base_path, self.id, 'action')
|
||||
if has_response:
|
||||
resp = session.post(url, endpoint_filter=self.service, json=body)
|
||||
else:
|
||||
headers = {'Accept': ''}
|
||||
resp = session.post(
|
||||
url, endpoint_filter=self.service, json=body, headers=headers)
|
||||
return resp.json()
|
||||
headers = {'Accept': ''}
|
||||
session.post(
|
||||
url, endpoint_filter=self.service, json=body, headers=headers)
|
||||
|
||||
def change_password(self, session, new_password):
|
||||
"""Change the administrator password to the given password."""
|
||||
|
|
|
@ -45,7 +45,7 @@ class TestServer(testtools.TestCase):
|
|||
def setUp(self):
|
||||
super(TestServer, self).setUp()
|
||||
self.resp = mock.Mock()
|
||||
self.resp.body = ''
|
||||
self.resp.body = None
|
||||
self.resp.json = mock.Mock(return_value=self.resp.body)
|
||||
self.sess = mock.Mock()
|
||||
self.sess.post = mock.Mock(return_value=self.resp)
|
||||
|
|
Loading…
Reference in New Issue