diff options
author | Xiaohua Zhang <xiaohua.zhang@windriver.com> | 2019-04-08 04:46:18 +0000 |
---|---|---|
committer | Xiaohua Zhang <xiaohua.zhang@windriver.com> | 2019-04-08 06:43:33 +0000 |
commit | acbf18f98440e52e55cfe85ff75845081b7c9165 (patch) | |
tree | 1bc57e3423d98284fbb8d0431402c602f5d32993 | |
parent | 9e91e644956951197e321b1b2a3cd2ec03a74ef0 (diff) |
Add multi-tenant support for capacity_check API
Change-Id: Id7f33327f88d1d687dfe8e2646a43f6d0b51b605
Issue-ID: MULTICLOUD-568
Signed-off-by: Xiaohua Zhang <xiaohua.zhang@windriver.com>
-rw-r--r-- | multivimbroker/multivimbroker/forwarder/views.py | 6 | ||||
-rw-r--r-- | multivimbroker/multivimbroker/tests/test_check_capacity.py | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/multivimbroker/multivimbroker/forwarder/views.py b/multivimbroker/multivimbroker/forwarder/views.py index 19e69f0..0219dd4 100644 --- a/multivimbroker/multivimbroker/forwarder/views.py +++ b/multivimbroker/multivimbroker/forwarder/views.py @@ -114,7 +114,8 @@ 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, json.dumps(newbody), "POST") + resp = self.send(vim, url, json.dumps(newbody), "POST", + headers=originHeaders(request)) if int(resp.status_code) != status.HTTP_200_OK: continue try: @@ -224,7 +225,8 @@ class APIv1CheckCapacity(CheckCapacity): "check_vim_capacity", "%s/%s/capacity_check" % (cloud_owner, cloud_region_id)) vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) - resp = self.send(vimid, url, json.dumps(newbody), "POST") + resp = self.send(vimid, url, json.dumps(newbody), "POST", + headers=originHeaders(request)) if int(resp.status_code) != status.HTTP_200_OK: continue try: diff --git a/multivimbroker/multivimbroker/tests/test_check_capacity.py b/multivimbroker/multivimbroker/tests/test_check_capacity.py index d7a7cae..64691e7 100644 --- a/multivimbroker/multivimbroker/tests/test_check_capacity.py +++ b/multivimbroker/multivimbroker/tests/test_check_capacity.py @@ -38,6 +38,7 @@ class CheckCapacityTest(unittest.TestCase): }""" req.get_full_path.return_value = ("http://msb.onap.org/api/multicloud" "/v0/check_vim_capacity") + req.META.items.return_value = [("Project", "projectname1")] with mock.patch.object(self.view, "send") as send: plugin_resp = mock.Mock() plugin_resp.content = """{ @@ -64,6 +65,8 @@ class CheckCapacityTest(unittest.TestCase): }""" req.get_full_path.return_value = ("http://msb.onap.org/api/multicloud" "/v0/check_vim_capacity") + req.META.items.return_value = [("Project", "projectname1")] + with mock.patch.object(self.view, "send") as send: plugin_resp = mock.Mock() plugin_resp.content = """{ @@ -84,6 +87,7 @@ class CheckCapacityTest(unittest.TestCase): req.body = "hello world" req.get_full_path.return_value = ("http://msb.onap.org/api/multicloud" "/v0/check_vim_capacity") + req.META.items.return_value = [("Project", "projectname1")] expect_body = { "error": ("Invalidate request body " "No JSON object could be decoded.") |