X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=multivimbroker%2Fmultivimbroker%2Fpub%2Futils%2Fsyscomm.py;h=7afb9660e12a6a5a1f912cd5af0595ed398e3966;hb=9e91e644956951197e321b1b2a3cd2ec03a74ef0;hp=65039ae080507c6e4abca80dd7169142f5e1a5f9;hpb=3288950ae32c9476539933d92774757fea1c6f55;p=multicloud%2Fframework.git diff --git a/multivimbroker/multivimbroker/pub/utils/syscomm.py b/multivimbroker/multivimbroker/pub/utils/syscomm.py index 65039ae..7afb966 100644 --- a/multivimbroker/multivimbroker/pub/utils/syscomm.py +++ b/multivimbroker/multivimbroker/pub/utils/syscomm.py @@ -1,4 +1,5 @@ # Copyright (c) 2017 Wind River Systems, Inc. +# Copyright (c) 2017-2018 VMware, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +16,7 @@ import os import re import multivimbroker.pub.exceptions as exceptions -from multivimbroker.pub.msapi.extsys import get_vim_by_id +from multivimbroker.pub.msapi import extsys def fun_name(): @@ -35,6 +36,25 @@ def getHeadersKeys(response): return [header for header in response.keys() if header not in hopbyhop] +# trim out 'HTTP_' prefix part and replace "_" wiht "-". +def originHeaders(request): + headers = {} + for key, value in request.META.items(): + if key.startswith('HTTP_') and key != 'HTTP_HOST': + 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 + + def findMultivimDriver(vim=None): json_file = os.path.join(os.path.dirname(__file__), '../config/provider-plugin.json') @@ -50,6 +70,22 @@ def findMultivimDriver(vim=None): def getMultivimDriver(vimid, full_path=""): multcloud = "multicloud" - vim = get_vim_by_id(vimid) + vim = extsys.get_vim_by_id(vimid) multclouddriver = findMultivimDriver(vim=vim) return re.sub(multcloud, multclouddriver, 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