Fix bugs in policy retrevial 76/105676/1
authorRuoyu Ying <ruoyu.ying@intel.com>
Thu, 9 Apr 2020 21:55:25 +0000 (05:55 +0800)
committerRuoyu Ying <ruoyu.ying@intel.com>
Thu, 9 Apr 2020 22:04:50 +0000 (06:04 +0800)
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>
config/osdf_config.yaml
osdf/adapters/policy/interface.py

index eba89e0..4f2f6b6 100755 (executable)
@@ -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
index 9ace75e..e38af50 100644 (file)
@@ -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)