diff options
author | Ethan Lynn <ethanlynnl@vmware.com> | 2018-03-29 18:51:44 -0700 |
---|---|---|
committer | Ethan Lynn <ethanlynnl@vmware.com> | 2018-03-29 18:52:53 -0700 |
commit | 6063ba3dcad5e0c38b11759563e517018ae3bc55 (patch) | |
tree | 0825998c1c1f0032bf15969489ebe348612b81d8 /multivimbroker | |
parent | ff40a0cee1f8de73d8d764cc97495f6615c3d1eb (diff) |
Fix check_vim_capacity
Fix check_vim_capacity
Change-Id: If0daf58f32ecf509abd5923708b335a29ce91582
Issue-ID: MULTICLOUD-166
Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
Diffstat (limited to 'multivimbroker')
-rw-r--r-- | multivimbroker/multivimbroker/forwarder/views.py | 6 | ||||
-rw-r--r-- | multivimbroker/multivimbroker/tests/test_check_capacity.py | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/multivimbroker/multivimbroker/forwarder/views.py b/multivimbroker/multivimbroker/forwarder/views.py index c66a6f1..4f6e6ef 100644 --- a/multivimbroker/multivimbroker/forwarder/views.py +++ b/multivimbroker/multivimbroker/forwarder/views.py @@ -113,11 +113,11 @@ class CheckCapacity(BaseServer): for vim in body.get("VIMs", []): url = request.get_full_path().replace( "check_vim_capacity", "%s/capacity_check" % vim) - resp = self.send(vim, url, newbody, "POST") - if resp.status_code != status.HTTP_200_OK: + resp = self.send(vim, url, str(newbody), "POST") + if int(resp.status_code) != status.HTTP_200_OK: continue try: - resp_body = json.loads(resp.body) + resp_body = json.loads(resp.content) except ValueError: continue if not resp_body.get("result", False): diff --git a/multivimbroker/multivimbroker/tests/test_check_capacity.py b/multivimbroker/multivimbroker/tests/test_check_capacity.py index 60035e0..d7a7cae 100644 --- a/multivimbroker/multivimbroker/tests/test_check_capacity.py +++ b/multivimbroker/multivimbroker/tests/test_check_capacity.py @@ -40,10 +40,10 @@ class CheckCapacityTest(unittest.TestCase): "/v0/check_vim_capacity") with mock.patch.object(self.view, "send") as send: plugin_resp = mock.Mock() - plugin_resp.body = """{ + plugin_resp.content = """{ "result": true }""" - plugin_resp.status_code = status.HTTP_200_OK + plugin_resp.status_code = str(status.HTTP_200_OK) send.return_value = plugin_resp resp = self.view.post(req) @@ -66,10 +66,10 @@ class CheckCapacityTest(unittest.TestCase): "/v0/check_vim_capacity") with mock.patch.object(self.view, "send") as send: plugin_resp = mock.Mock() - plugin_resp.body = """{ + plugin_resp.content = """{ "result": false }""" - plugin_resp.status_code = status.HTTP_200_OK + plugin_resp.status_code = str(status.HTTP_200_OK) send.return_value = plugin_resp resp = self.view.post(req) |