summaryrefslogtreecommitdiffstats
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
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>
-rwxr-xr-xconfig/osdf_config.yaml4
-rw-r--r--osdf/adapters/policy/interface.py9
2 files changed, 7 insertions, 6 deletions
diff --git a/config/osdf_config.yaml b/config/osdf_config.yaml
index eba89e0..4f2f6b6 100755
--- a/config/osdf_config.yaml
+++ b/config/osdf_config.yaml
@@ -18,7 +18,7 @@ conductorMaxRetries: 30 # if we don't get something in 30 minutes, give up
conductorMinorVersion: 0
# Policy Platform -- requires Authorization
-policyPlatformUrl: https://policy-xacml-pdp:6969/policy/pdpx/decision/v1 # Policy Dev platform URL
+policyPlatformUrl: https://policy-xacml-pdp:6969/policy/pdpx/v1/decision # Policy Dev platform URL
# URL for policy model uploading
policyPlatformUrlModelUpload: https://policy.api.simpledemo.onap.org:8081/policy/api/v1/policytypes
pathPolicyModelUpload: ../../models/policy/placement/tosca_upload/
@@ -54,4 +54,4 @@ pciHMSUsername: test
pciHMSPassword: passwd
#key
-appkey: os35@rrtky400fdntc#001t5 \ No newline at end of file
+appkey: os35@rrtky400fdntc#001t5
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)