From acbf18f98440e52e55cfe85ff75845081b7c9165 Mon Sep 17 00:00:00 2001 From: Xiaohua Zhang Date: Mon, 8 Apr 2019 04:46:18 +0000 Subject: Add multi-tenant support for capacity_check API Change-Id: Id7f33327f88d1d687dfe8e2646a43f6d0b51b605 Issue-ID: MULTICLOUD-568 Signed-off-by: Xiaohua Zhang --- multivimbroker/multivimbroker/forwarder/views.py | 6 ++++-- multivimbroker/multivimbroker/tests/test_check_capacity.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'multivimbroker') 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.") -- cgit 1.2.3-korg