Pass headers for multi-tenant support
[multicloud/framework.git] / multivimbroker / multivimbroker / pub / utils / syscomm.py
index 9e96d2e..7afb966 100644 (file)
@@ -44,6 +44,14 @@ def originHeaders(request):
             headers[key[5:].replace('_', '-')] = value
         elif key in ('CONTENT_TYPE', 'CONTENT_LENGTH'):
             headers[key.replace('_', '-')] = value
+        elif key.lower() in ('project', 'project_id', 'project_name',
+                             'tenant', 'tenant_id', 'tenant_name'):
+            # support API to specify project other than the default one
+            headers[key] = value
+        # elif key.lower() in ('x-auth-token',
+        #                      'http_x_auth_token', 'x_auth_token'):
+        #     # pass the token to plugins
+        #     headers["X-Auth-Token"] = value
     return headers
 
 
@@ -68,16 +76,16 @@ def getMultivimDriver(vimid, full_path=""):
 
 
 def getVIMTypes():
-        # Fix here unless we have plugin registry
-        json_file = os.path.join(os.path.dirname(__file__),
-                                 '../config/provider-plugin.json')
-        with open(json_file, "r") as f:
-            plugins = json.load(f)
-        ret = []
-        for k, v in plugins.items():
-            item = {}
-            item["vim_type"] = v.get("vim_type")
-            item["versions"] = [k for k in v.get('versions', {})]
-            ret.append(item)
-
-        return ret
+    # Fix here unless we have plugin registry
+    json_file = os.path.join(os.path.dirname(__file__),
+                             '../config/provider-plugin.json')
+    with open(json_file, "r") as f:
+        plugins = json.load(f)
+    ret = []
+    for k, v in plugins.items():
+        item = {}
+        item["vim_type"] = v.get("vim_type")
+        item["versions"] = [k for k in v.get('versions', {})]
+        ret.append(item)
+
+    return ret