aboutsummaryrefslogtreecommitdiffstats
path: root/osdf/adapters/policy/interface.py
diff options
context:
space:
mode:
authorRuoyu Ying <ruoyu.ying@intel.com>2020-04-10 05:55:25 +0800
committerRuoyu Ying <ruoyu.ying@intel.com>2020-04-10 06:04:50 +0800
commit44c3c51b585b40f432cea350c6ddd9e504998afc (patch)
tree12e056d469f726a19757361d2239cb23575625c4 /osdf/adapters/policy/interface.py
parentec68a8ff4cb494867f72a3fa17ab481b2c38e119 (diff)
Fix bugs in policy retrevial
Fix bugs in the payload sent to policy query Issue-ID: OPTFRA-731 Signed-off-by: Ruoyu Ying <ruoyu.ying@intel.com> Change-Id: I7ed833e4daf2eb08c6bf4b998fd61d4182246677 Signed-off-by: Ruoyu Ying <ruoyu.ying@intel.com>
Diffstat (limited to 'osdf/adapters/policy/interface.py')
-rw-r--r--osdf/adapters/policy/interface.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/osdf/adapters/policy/interface.py b/osdf/adapters/policy/interface.py
index 9ace75e..e38af50 100644
--- a/osdf/adapters/policy/interface.py
+++ b/osdf/adapters/policy/interface.py
@@ -64,8 +64,8 @@ def get_by_scope(rest_client, req, config_local, type_service):
for scopes in pscope:
for key in scopes.keys():
for field in scopes[key]:
- scope_fields[key] = set(list_flatten([get_scope_fields(field, references, req, policies)
- if 'get_param' in field else field]))
+ scope_fields[key] = list_flatten([get_scope_fields(field, references, req, policies)
+ if 'get_param' in field else field])
if scope_fields.get('resources') and len(scope_fields['resources']) > 1:
for s in scope_fields['resources']:
scope_fields['resources'] = [s]
@@ -122,7 +122,7 @@ def policy_api_call(rest_client, scope_fields):
"ONAPComponent": "OOF_Component",
"ONAPInstance": "OOF_Component_Instance",
"action": "optimize",
- "resources": "{}".format(scope_fields)}
+ "resources": scope_fields}
return rest_client.request(json=api_call_body)
def remote_api(req_json, osdf_config, service_type="placement"):
@@ -133,9 +133,10 @@ def remote_api(req_json, osdf_config, service_type="placement"):
:return: all related policies and provStatus retrieved from Subscriber policy
"""
config = osdf_config.deployment
+ headers = {"Content-type: application/json"}
uid, passwd = config['policyPlatformUsername'], config['policyPlatformPassword']
url = config['policyPlatformUrl']
- rc = RestClient(userid=uid, passwd=passwd, url=url, log_func=debug_log.debug)
+ rc = RestClient(userid=uid, passwd=passwd, headers=headers, url=url, log_func=debug_log.debug)
if osdf_config.core['policy_info'][service_type]['policy_fetch'] == "by_name":
policies = get_by_name(rc, req_json[service_type + "Info"]['policyId'], wildcards=True)