Add multi-tenant support for capacity_check API 61/84461/3
authorXiaohua Zhang <xiaohua.zhang@windriver.com>
Mon, 8 Apr 2019 04:46:18 +0000 (04:46 +0000)
committerXiaohua Zhang <xiaohua.zhang@windriver.com>
Mon, 8 Apr 2019 06:43:33 +0000 (06:43 +0000)
Change-Id: Id7f33327f88d1d687dfe8e2646a43f6d0b51b605
Issue-ID: MULTICLOUD-568
Signed-off-by: Xiaohua Zhang <xiaohua.zhang@windriver.com>
multivimbroker/multivimbroker/forwarder/views.py
multivimbroker/multivimbroker/tests/test_check_capacity.py

index 19e69f0..0219dd4 100644 (file)
@@ -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:
index d7a7cae..64691e7 100644 (file)
@@ -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.")