Update the policy adaptor and related testcases 17/38317/1
authorAnkitkumar Patel <ankit@research.att.com>
Sun, 25 Mar 2018 23:27:39 +0000 (19:27 -0400)
committerAnkitkumar Patel <ankit@research.att.com>
Sun, 25 Mar 2018 23:31:24 +0000 (19:31 -0400)
Generalized the policy adaptor code by removing homing specific logic.

Issue-ID: OPTFRA-27
Change-Id: I331030a2f3f5c0c17af1a72af9794131555a9217
Signed-off-by: Ankitkumar Patel <ankit@research.att.com>
14 files changed:
.gitignore
config/common_config.yaml
osdf/adapters/policy/interface.py
osdfapp.py
test/config/common_config.yaml
test/placement-tests/policy_response.json [new file with mode: 0644]
test/placement-tests/policy_response_error1.json [new file with mode: 0644]
test/placement-tests/policy_response_error2.json [new file with mode: 0644]
test/placement-tests/request.json
test/placement-tests/request_error1.json [new file with mode: 0644]
test/placement-tests/scopePolicies.json [deleted file]
test/placement-tests/testScoperequest.json
test/placement-tests/test_by_scope.yaml
test/test_PolicyCalls.py

index 864f9ee..e1eb8cd 100644 (file)
@@ -108,3 +108,7 @@ venv.bak/
 
 # mypy
 .mypy_cache/
+
+# pyCharm
+.idea/
+xunit*.xml
index 89678a2..ec7098e 100644 (file)
@@ -29,15 +29,27 @@ service_info:
         vcpeHostName: requestParameters.vcpeHostName
         e2eVpnKey: requestParameters.e2eVpnKey
 
+references:
+    service_name:
+        source: request
+        value: serviceInfo.serviceName
+    subscriber_role:
+        source: SubscriberPolicy
+        value: content.properties.subscriberRole
+
 policy_info:
     placement:
         policy_fetch: by_scope
         policy_scope:
             default_scope: OSDF_R2
-            scope_vcpe: OSDF_R2
-            service_name: placementInfo.serviceModelInfo.modelName
-        policy_subscriber: SubscriberPolicy
-        subscriber_name: placementInfo.subscriberInfo.subscriberName
+            vcpe_scope: OSDF_R2
+            secondary_scopes:
+                -
+                    - get_param: service_name
+                    - SubscriberPolicy
+                -
+                    - get_param: service_name
+                    - get_param: subscriber_role
     default:  # if no explicit service related information is needed
         policy_fetch: by_name
         policy_scope: none
index 02b8ff3..a3b5881 100644 (file)
@@ -25,6 +25,7 @@ from requests import RequestException
 from osdf.operation.exceptions import BusinessException
 from osdf.adapters.local_data.local_policies import get_local_policies
 from osdf.adapters.policy.utils import policy_name_as_regex, retrieve_node
+from osdf.utils.programming_utils import list_flatten, dot_notation
 from osdf.config.base import osdf_config
 from osdf.logging.osdf_logging import audit_log, MH, metrics_log, debug_log
 from osdf.utils.interfaces import RestClient
@@ -44,94 +45,74 @@ def get_by_name(rest_client, policy_name_list, wildcards=True):
     return policy_list
 
 
-def get_subscriber_name(req, pmain):
-    subs_name = retrieve_node(req, pmain['subscriber_name'])
-    if subs_name is None:
-        return "DEFAULT"
-    else:
-        subs_name_uc = subs_name.upper()
-        if subs_name_uc in ("DEFAULT", "NULL", ""):
-            subs_name = "DEFAULT"
-    return subs_name
-
-
-def get_subscriber_role(rest_client, req, pmain, service_name, scope):
-    """Make a request to policy and return subscriberRole
-    :param rest_client: rest client to make call
-    :param req: request object from MSO
-    :param pmain: main config that will have policy path information
-    :param service_name: the type of service to call: e.g. "vCPE
-    :param scope: the scope of policy to call: e.g. "OOF_HAS_vCPE".
-    :return: subscriberRole and provStatus retrieved from Subscriber policy
+def get_by_scope(rest_client, req, config_local, type_service):
+    """ Get policies by scopes as defined in the configuration file.
+    :param rest_client: a rest client object to make a call.
+    :param req: an optimization request.
+    :param config_local: application configuration file.
+    :param type_service: the type of optimization service.
+    :return: a list of policies.
     """
-    subscriber_role = "DEFAULT"
-    prov_status = []
-    subs_name = get_subscriber_name(req, pmain)  # what if there is no subs_name
-    if subs_name == "DEFAULT":
-        return subscriber_role, prov_status
-
-    policy_subs = pmain['policy_subscriber']
-    policy_scope = {"policyName": "{}.*".format(scope),
-                    "configAttributes": {
-                        "serviceType": "{}".format(service_name),
-                        "service": "{}".format(policy_subs)}
-                    }
-    try:
-        policy_list = rest_client.request(json=policy_scope)
-    except RequestException as err:
-        audit_log.warn("Error in fetching policy for {}, {}: ".format(policy_subs, err))
-        return subscriber_role, prov_status
-
-    policies = list(itertools.chain(*policy_list))
-    for x in policies:  
-        if not x['config']:  # some policy has no 'config' field, so it will be empty
-            raise BusinessException("Config not found for policy with name %s" % x['policyName'])
-
-    formatted_policies = [json.loads(x['config']) for x in policies]
-    role, prov = _get_subscriber_role_from_policies(formatted_policies, subs_name, subscriber_role, prov_status)
-    return role, prov
+    policy_list = []
+    references = config_local.get('references', {})
+    pscope = config_local.get('policy_info', {}).get(type_service, {}).get('policy_scope', {})
+    service_name = dot_notation(req, references.get('service_name', {}).get('value', None))
+    primary_scope = pscope['{}_scope'.format(service_name.lower() if service_name else "default")]
+    for sec_scope in pscope.get('secondary_scopes', []):
+        scope_fields, scope_fields_flatten = [], []
+        for field in sec_scope:
+            if 'get_param' in field:
+                scope_fields.append(get_scope_fields(field, references, req, list_flatten(policy_list)))
+            else:
+                scope_fields.append(field)
+        scope_fields_flatten = list_flatten(scope_fields)
+        policy_list.append(policy_api_call(rest_client, primary_scope, scope_fields_flatten))
+    return policy_list
 
 
-def _get_subscriber_role_from_policies(policies, subs_name, default_role, default_prov):
+def get_scope_fields(field, references, req, policy_info):
+    """ Retrieve the values for scope fields from a request and policies as per the configuration
+    and references defined in a configuration file. If the value of a scope field missing in a request or
+    policies, throw an exception since correct policies cannot be retrieved.
+    :param field: details on a scope field from a configuration file.
+    :param references: references defined in a configuration file.
+    :param req: an optimization request.
+    :param policy_info: a list of policies.
+    :return: scope fields retrieved from a request and policies.
     """
-    Get the first subscriber role found in policies
-    :param policies: JSON-loaded policies
-    :param subs_name: subscriber name
-    :param default_val: default role (e.g. "DEFAULT")
-    :param default_prov: default prov_status (e.g. [])
-    :return: role and prov_status
+    if references.get(field.get('get_param', ""), {}).get('source', None) == "request":
+        scope_field = dot_notation(req, references.get(field.get('get_param', ""), {}).get('value', ""))
+        if scope_field:
+            return scope_field
+        raise BusinessException("Field {} is missing a value in a request".format(
+            references.get(field.get('get_param', ""), {}).get('value', "").split('.')[-1]))
+    else:
+        scope_fields = []
+        for policy in policy_info:
+            policy_content = json.loads(policy.get('config', "{}"))
+            if policy_content.get('content', {}).get('policyType', "invalid_policy") == \
+                    references.get(field.get('get_param', ""), {}).get('source', None):
+                scope_fields.append(dot_notation(policy_content,
+                                                 references.get(field.get('get_param', ""), {}).get('value', "")))
+        scope_values = list_flatten(scope_fields)
+        if len(scope_values) > 0:
+            return scope_values
+        raise BusinessException("Field {} is missing a value in all policies of type {}".format(
+            references.get(field.get('get_param', ""), {}).get('value', "").split('.')[-1],
+            references.get(field.get('get_param', ""), {}).get('source', "")))
+
+
+def policy_api_call(rest_client, primary_scope, scope_fields):
+    """ Makes a getConfig API call to the policy system to retrieve policies matching a scope.
+    :param rest_client: rest client object to make a call
+    :param primary_scope: the primary scope of policies, which is a folder in the policy system
+    where policies are stored.
+    :param scope_fields: the secondary scope of policies, which is a collection of domain values.
+    :return: a list of policies matching both primary and secondary scopes.
     """
-    for policy in policies:
-        property_list = policy['content']['property']
-        for prop in property_list:
-            if subs_name in prop['subscriberName']:
-                subs_role_list = prop['subscriberRole']
-                prov_status = prop['provStatus']
-                if isinstance(subs_role_list, list):
-                    return subs_role_list[0], prov_status   # TODO: check what to do otherwise
-    return default_role, default_prov
-
-
-def get_by_scope(rest_client, req, config_local, type_service):
-    policy_list = []
-    pmain = config_local['policy_info'][type_service]
-    pscope = pmain['policy_scope']
-
-    model_name = retrieve_node(req, pscope['service_name'])
-    service_name = model_name
-
-    scope = pscope['scope_{}'.format(service_name.lower())]
-    subscriber_role, prov_status = get_subscriber_role(rest_client, req, pmain, service_name, scope)
-    policy_type_list = pmain['policy_type_{}'.format(service_name.lower())]
-    for policy_type in policy_type_list:
-        policy_scope = {"policyName": "{}.*".format(scope),
-                        "configAttributes": {
-                            "serviceType": "{}".format(service_name),
-                            "service": "{}".format(policy_type),
-                            "subscriberRole": "{}".format(subscriber_role)}
-                        }
-        policy_list.append(rest_client.request(json=policy_scope))
-    return policy_list, prov_status
+    api_call_body = {"policyName": "{}.*".format(primary_scope),
+                     "configAttributes": {"policyScope": "{}".format(scope_fields)}}
+    return rest_client.request(json=api_call_body)
 
 
 def remote_api(req_json, osdf_config, service_type="placement"):
@@ -141,7 +122,6 @@ def remote_api(req_json, osdf_config, service_type="placement"):
     :param service_type: the type of service to call: "placement", "scheduling"
     :return: all related policies and provStatus retrieved from Subscriber policy
     """
-    prov_status = None
     config = osdf_config.deployment
     uid, passwd = config['policyPlatformUsername'], config['policyPlatformPassword']
     pcuid, pcpasswd = config['policyClientUsername'], config['policyClientPassword']
@@ -154,17 +134,16 @@ def remote_api(req_json, osdf_config, service_type="placement"):
         policies = get_by_name(rc, req_json[service_type + "Info"]['policyId'], wildcards=True)
     elif osdf_config.core['policy_info'][service_type]['policy_fetch'] == "by_name_no_wildcards":
         policies = get_by_name(rc, req_json[service_type + "Info"]['policyId'], wildcards=False)
-    else:  # Get policy by scope
-        policies, prov_status = get_by_scope(rc, req_json, osdf_config.core, service_type)
+    else:
+        policies = get_by_scope(rc, req_json, osdf_config.core, service_type)
 
-    # policies in res are list of lists, so flatten them; also only keep config part
     formatted_policies = []
     for x in itertools.chain(*policies):
         if x['config'] is None:
             raise BusinessException("Config not found for policy with name %s" % x['policyName'])
         else:
             formatted_policies.append(json.loads(x['config']))
-    return formatted_policies, prov_status
+    return formatted_policies
 
 
 def local_policies_location(req_json, osdf_config, service_type):
@@ -206,6 +185,6 @@ def get_policies(request_json, service_type):
             to_filter = request_json[service_type + "Info"]['policyId']
         policies = get_local_policies(local_info[0], local_info[1], to_filter)
     else:
-        policies, prov_status = remote_api(request_json, osdf_config, service_type)
+        policies = remote_api(request_json, osdf_config, service_type)
 
     return policies, prov_status
index eb14530..348a88c 100755 (executable)
@@ -93,12 +93,6 @@ def handle_data_error(e):
     return response
 
 
-@app.route("/api/oof/v1/healthcheck", methods=["GET"])
-def do_osdf_health_check():
-    """Simple health check"""
-    return "OK"
-
-
 @app.route("/api/oof/v1/placement", methods=["POST"])
 @auth_basic.login_required
 def do_placement_opt():
@@ -110,17 +104,10 @@ def do_placement_opt():
     req_id = request_json['requestInfo']['requestId']
     g.request_id = req_id
     audit_log.info(MH.received_request(request.url, request.remote_addr, json.dumps(request_json)))
-
     PlacementAPI(request_json).validate()
-
-    # Currently policies are being used only during placement, so only fetch them if placement demands is not empty
-    policies, prov_status = {}, None
-
-    if 'placementDemand' in request_json['placementInfo']['demandInfo']:
-        policies, prov_status = get_policies(request_json, "placement")
-
+    policies = get_policies(request_json, "placement")
     audit_log.info(MH.new_worker_thread(req_id, "[for placement]"))
-    t = Thread(target=process_placement_opt, args=(request_json, policies, osdf_config, prov_status))
+    t = Thread(target=process_placement_opt, args=(request_json, policies, osdf_config, ""))
     t.start()
     audit_log.info(MH.accepted_valid_request(req_id, request))
     return osdf.operation.responses.osdf_response_for_request_accept(
index 1c041d9..6a5f5e1 100644 (file)
@@ -29,15 +29,27 @@ service_info:
         vcpeHostName: requestParameters.vcpeHostName
         e2eVpnKey: requestParameters.e2eVpnKey
 
+references:
+    service_name:
+        source: request
+        value: serviceInfo.serviceName
+    subscriber_role:
+        source: SubscriberPolicy
+        value: content.properties.subscriberRole
+
 policy_info:
     placement:
         policy_fetch: by_scope
         policy_scope:
             default_scope: OSDF_R2
-            scope_vcpe: OSDF_R2
-            service_name: placementInfo.serviceModelInfo.modelName
-        policy_subscriber: SubscriberPolicy
-        subscriber_name: placementInfo.subscriberInfo.subscriberName
+            vcpe_scope: OSDF_R2
+            secondary_scopes:
+                -
+                    - get_param: service_name
+                    - SubscriberPolicy
+                -
+                    - get_param: service_name
+                    - get_param: subscriber_role
     default:  # if no explicit service related information is needed
         policy_fetch: by_name
-        policy_scope: none
+        policy_scope: none
\ No newline at end of file
diff --git a/test/placement-tests/policy_response.json b/test/placement-tests/policy_response.json
new file mode 100644 (file)
index 0000000..ed5b4ab
--- /dev/null
@@ -0,0 +1,182 @@
+[
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"SubscriberPolicy\",\"policyName\":\"oofBeijing.SubscriberPolicy_v1\",\"description\":\"Subscriber Policy\",\"templateVersion\":\"0.0.1\",\"version\":\"oofBeijing\",\"priority\":\"1\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"identity\":\"subscriber\",\"policyScope\":[\"vCPE\",\"subscriber_x\",\"subscriber_y\"],\"properties\":{\"subscriberName\":[\"subscriber_x\",\"subscriber_y\"],\"subscriberRole\":[\"PVT Homing\"],\"provStatus\":[\"CAPPED\"]},\"policyType\":\"SubscriberPolicy\"}}",
+    "policyName": "oofBeijing.Config_MS_SubscriberPolicy_v1.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "SubscriberPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"hpaPolicy\",\"policyName\":\"oofBeijing.hpaPolicy_vGMuxInfra\",\"description\":\"HPA policy for vGMuxInfra\",\"templateVersion\":\"0.0.1\",\"version\":\"1.0\",\"priority\":\"3\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"resources\":\"vGMuxInfra\",\"identity\":\"hpaPolicy_vGMuxInfra\",\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\"],\"policyType\":\"hpaPolicy\",\"flavorFeatures\":[{\"flavorLabel\":\"flavor_label_vm_01\",\"flavorProperties\":[{\"hpa-feature\":\"cpuTopology\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numCpuSockets\",\"hpa-attribute-value\":\"2\",\"operator\":\">=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuSockets\",\"hpa-attribute-value\":\"4\",\"operator\":\"<=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuCores\",\"hpa-attribute-value\":\"2\",\"operator\":\">=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuCores\",\"hpa-attribute-value\":\"4\",\"operator\":\"<=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuThreads\",\"hpa-attribute-value\":\"4\",\"operator\":\">=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuThreads\",\"hpa-attribute-value\":\"8\",\"operator\":\"<=\",\"unit\":\"\"}]},{\"hpa-feature\":\"basicCapabilities\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numVirtualCpu\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"virtualMemSize\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"GB\"}]},{\"hpa-feature\":\"ovsDpdk\",\"mandatory\":\"False\",\"score\":\"3\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"dataProcessingAccelerationLibrary\",\"hpa-attribute-value\":\"ovsDpdk_version\",\"operator\":\"=\",\"unit\":\"\"}]},{\"hpa-feature\":\"cpuInstructionSetExtensions\",\"mandatory\":\"True\",\"architecture\":\"INTEL-64\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"instructionSetExtensions\",\"hpa-attribute-value\":[\"<CPUINST>\",\"<CPUINST>\"],\"operator\":\"ALL\",\"unit\":\"\"}]}]},{\"flavorLabel\":\"flavor_label_vm_02\",\"flavorProperties\":[{\"hpa-feature\":\"cpuPinningy\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"logicalCpuThreadPinningPolicy\",\"hpa-attribute-value\":\"<CPUTHREADPOLICY>\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"logicalCpuPinningPolicy\",\"hpa-attribute-value\":\"<CPUPOLICY>\",\"operator\":\"=\",\"unit\":\"\"}]},{\"hpa-feature\":\"basicCapabilities\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numVirtualCpu\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"virtualMemSize\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"GB\"}]},{\"hpa-feature\":\"localStorage\",\"mandatory\":\"False\",\"score\":\"5\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"diskSize\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"GB\"},{\"hpa-attribute-key\":\"ephemeralDiskSize\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"GB\"},{\"hpa-attribute-key\":\"swapMemSize\",\"hpa-attribute-value\":\"16\",\"operator\":\"=\",\"unit\":\"MB\"}]},{\"hpa-feature\":\"pcie\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"pciCount\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"pciVendorId\",\"hpa-attribute-value\":\"8086\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"pciDeviceId\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"functionType\",\"hpa-attribute-value\":\"<PCITYPEVALUE>\",\"operator\":\"=\",\"unit\":\"\"}]}]},{\"flavorLabel\":\"flavor_label_vm_03\",\"flavorProperties\":[{\"hpa-feature\":\"numa\",\"mandatory\":\"False\",\"score\":\"5\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numaNodes\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numaCpu-0\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numaMem-0\",\"hpa-attribute-value\":\"2048\",\"operator\":\"=\",\"unit\":\"MB\"},{\"hpa-attribute-key\":\"numaCpu-1\",\"hpa-attribute-value\":\"4\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numaMem-1\",\"value\":\"4096\",\"operator\":\"=\",\"unit\":\"MB\"}]},{\"hpa-feature\":\"basicCapabilities\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numVirtualCpu\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"virtualMemSize\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"GB\"}]},{\"hpa-feature\":\"hugePages\",\"mandatory\":\"False\",\"score\":\"7\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"memoryPageSize\",\"hpa-attribute-value\":\"<MEMORYPAGESIZE>\",\"operator\":\"=\",\"unit\":\"\"}]}]}]}}",
+    "policyName": "oofBeijing.Config_MS_hpaPolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "hpaPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"VnfPolicy\",\"policyName\":\"oofBeijing.vnfPolicy_vG\",\"description\":\"vnfPolicy\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"6\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"identity\":\"vnf_vG\",\"policyScope\":[\"vCPE\",\"INTERNATIONAL\",\"ip\",\"vG\"],\"policyType\":\"vnf_policy\",\"resources\":[\"vG\"],\"applicableResources\":\"any\",\"vnfProperties\":[{\"inventoryProvider\":\"aai\",\"serviceType\":\"\",\"inventoryType\":\"cloud\",\"customerId\":\"\"},{\"inventoryProvider\":\"multicloud\",\"serviceType\":\"HNGATEWAY\",\"inventoryType\":\"service\",\"customerId\":\"21014aa2-526b-11e6-beb8-9e71128cae77\"}]}}",
+    "policyName": "oofBeijing.Config_MS_vnfPolicy_vG.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "VnfPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"VnfPolicy\",\"policyName\":\"oofBeijing.vnfPolicy_vGMuxInfra\",\"description\":\"vnfPolicy\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"6\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"identity\":\"vnf_vGMuxInfra\",\"policyScope\":[\"vCPE\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\"],\"policyType\":\"vnf_policy\",\"resources\":[\"vGMuxInfra\"],\"applicableResources\":\"any\",\"vnfProperties\":[{\"inventoryProvider\":\"aai\",\"serviceType\":\"\",\"inventoryType\":\"cloud\",\"customerId\":\"\"},{\"inventoryProvider\":\"multicloud\",\"serviceType\":\"HNGATEWAY\",\"inventoryType\":\"service\",\"customerId\":\"21014aa2-526b-11e6-beb8-9e71128cae77\"}]}}",
+    "policyName": "oofBeijing.Config_MS_vnfPolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "VnfPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"distancePolicy\",\"policyName\":\"oofBeijing.distancePolicy_vG\",\"description\":\"Distance Policy for vG\",\"templateVersion\":\"0.0.1\",\"version\":\"oofBeijing\",\"priority\":\"3\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"distanceProperties\":{\"locationInfo\":\"customer_location\",\"distance\":{\"value\":\"1500\",\"operator\":\"<\",\"unit\":\"km\"}},\"identity\":\"distance-vG\",\"resources\":[\"vG\"],\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vG\"],\"policyType\":\"distancePolicy\",\"applicableResources\":\"any\"}}",
+    "policyName": "oofBeijing.Config_MS_distancePolicy_vG.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "distancePolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"capacityPolicy\",\"policyName\":\"oofBeijing.capacityPolicy_vG\",\"description\":\"Capacity policy for vG\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"5\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"identity\":\"capacity_vG\",\"policyScope\":[\"VCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vG\"],\"resources\":[\"vG\"],\"capacityProperty\":{\"cpu\":{\"value\":2,\"operator\":\">\"},\"memory\":{\"value\":4,\"operator\":\">\",\"unit\":\"GB\"}},\"policyType\":\"capacityPolicy\",\"applicableResources\":\"any\"}}",
+    "policyName": "oofBeijing.Config_MS_capacityPolicy_vG.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "capacityPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"optimizationQueryPolicy\",\"policyName\":\"oofBeijing.queryPolicy_vCPE\",\"description\":\"Optimization query policy for vCPE\",\"templateVersion\":\"0.0.1\",\"version\":\"oofBeijing\",\"priority\":\"3\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"queryProperties\":[{\"attribute\":\"locationId\",\"value\":\"orderInfo.customerLocation\"},{\"attribute\":\"id\",\"value\":\"orderInfo.vpnInfo\"},{\"attribute\":\"upstreamBW\",\"value\":\"orderInfo.vpnInfo\"}],\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\",\"vG\"],\"policyType\":\"optimizationQueryPolicy\"}}",
+    "policyName": "oofBeijing.Config_MS_queryPolicy_vCPE.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "optimizationQueryPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"PlacementOptimizationPolicy\",\"policyName\":\"oofBeijing.PlacementOptimizationPolicy_vGMuxInfra\",\"description\":\"Placement Optimization Policy for vGMuxInfra\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"5\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"objectiveParameter\":{\"parameterAttributes\":[{\"resource\":[\"vGMuxInfra\"],\"customerLocationInfo\":\"customer_loc\",\"parameter\":\"distance\",\"weight\":\"1\",\"operator\":\"product\"},{\"resource\":[\"vG\"],\"customerLocationInfo\":\"customer_loc\",\"parameter\":\"distance\",\"weight\":\"1\",\"operator\":\"product\"}],\"operator\":\"sum\"},\"identity\":\"optimization\",\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\",\"vG\"],\"policyType\":\"placementOptimization\",\"objective\":\"minimize\"}}",
+    "policyName": "oofBeijing.Config_MS_PlacementOptimizationPolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "PlacementOptimizationPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"distancePolicy\",\"policyName\":\"oofBeijing.distancePolicy_vGMuxInfra\",\"description\":\"Distance Policy for vGMuxInfra\",\"templateVersion\":\"0.0.1\",\"version\":\"oofBeijing\",\"priority\":\"3\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"distanceProperties\":{\"locationInfo\":\"customer_location\",\"distance\":{\"value\":\"500\",\"operator\":\"<\",\"unit\":\"km\"}},\"identity\":\"distance-vGMuxInfra\",\"resources\":[\"vGMuxInfra\"],\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\"],\"policyType\":\"distancePolicy\",\"applicableResources\":\"any\"}}",
+    "policyName": "oofBeijing.Config_MS_distancePolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "distancePolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"capacityPolicy\",\"policyName\":\"oofBeijing.capacityPolicy_vGMuxInfra\",\"description\":\"Capacity policy for vGMuxInfra\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"5\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"identity\":\"capacity_vGMuxInfra\",\"policyScope\":[\"VCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\"],\"resources\":[\"vGMuxInfra\"],\"capacityProperty\":{\"cpu\":{\"value\":2,\"operator\":\">\"},\"memory\":{\"value\":4,\"operator\":\">\",\"unit\":\"GB\"}},\"policyType\":\"capacityPolicy\",\"applicableResources\":\"any\"}}",
+    "policyName": "oofBeijing.Config_MS_capacityPolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "capacityPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  }
+]
\ No newline at end of file
diff --git a/test/placement-tests/policy_response_error1.json b/test/placement-tests/policy_response_error1.json
new file mode 100644 (file)
index 0000000..788c5c4
--- /dev/null
@@ -0,0 +1,164 @@
+[
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"hpaPolicy\",\"policyName\":\"oofBeijing.hpaPolicy_vGMuxInfra\",\"description\":\"HPA policy for vGMuxInfra\",\"templateVersion\":\"0.0.1\",\"version\":\"1.0\",\"priority\":\"3\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"resources\":\"vGMuxInfra\",\"identity\":\"hpaPolicy_vGMuxInfra\",\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\"],\"policyType\":\"hpaPolicy\",\"flavorFeatures\":[{\"flavorLabel\":\"flavor_label_vm_01\",\"flavorProperties\":[{\"hpa-feature\":\"cpuTopology\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numCpuSockets\",\"hpa-attribute-value\":\"2\",\"operator\":\">=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuSockets\",\"hpa-attribute-value\":\"4\",\"operator\":\"<=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuCores\",\"hpa-attribute-value\":\"2\",\"operator\":\">=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuCores\",\"hpa-attribute-value\":\"4\",\"operator\":\"<=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuThreads\",\"hpa-attribute-value\":\"4\",\"operator\":\">=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuThreads\",\"hpa-attribute-value\":\"8\",\"operator\":\"<=\",\"unit\":\"\"}]},{\"hpa-feature\":\"basicCapabilities\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numVirtualCpu\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"virtualMemSize\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"GB\"}]},{\"hpa-feature\":\"ovsDpdk\",\"mandatory\":\"False\",\"score\":\"3\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"dataProcessingAccelerationLibrary\",\"hpa-attribute-value\":\"ovsDpdk_version\",\"operator\":\"=\",\"unit\":\"\"}]},{\"hpa-feature\":\"cpuInstructionSetExtensions\",\"mandatory\":\"True\",\"architecture\":\"INTEL-64\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"instructionSetExtensions\",\"hpa-attribute-value\":[\"<CPUINST>\",\"<CPUINST>\"],\"operator\":\"ALL\",\"unit\":\"\"}]}]},{\"flavorLabel\":\"flavor_label_vm_02\",\"flavorProperties\":[{\"hpa-feature\":\"cpuPinningy\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"logicalCpuThreadPinningPolicy\",\"hpa-attribute-value\":\"<CPUTHREADPOLICY>\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"logicalCpuPinningPolicy\",\"hpa-attribute-value\":\"<CPUPOLICY>\",\"operator\":\"=\",\"unit\":\"\"}]},{\"hpa-feature\":\"basicCapabilities\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numVirtualCpu\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"virtualMemSize\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"GB\"}]},{\"hpa-feature\":\"localStorage\",\"mandatory\":\"False\",\"score\":\"5\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"diskSize\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"GB\"},{\"hpa-attribute-key\":\"ephemeralDiskSize\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"GB\"},{\"hpa-attribute-key\":\"swapMemSize\",\"hpa-attribute-value\":\"16\",\"operator\":\"=\",\"unit\":\"MB\"}]},{\"hpa-feature\":\"pcie\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"pciCount\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"pciVendorId\",\"hpa-attribute-value\":\"8086\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"pciDeviceId\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"functionType\",\"hpa-attribute-value\":\"<PCITYPEVALUE>\",\"operator\":\"=\",\"unit\":\"\"}]}]},{\"flavorLabel\":\"flavor_label_vm_03\",\"flavorProperties\":[{\"hpa-feature\":\"numa\",\"mandatory\":\"False\",\"score\":\"5\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numaNodes\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numaCpu-0\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numaMem-0\",\"hpa-attribute-value\":\"2048\",\"operator\":\"=\",\"unit\":\"MB\"},{\"hpa-attribute-key\":\"numaCpu-1\",\"hpa-attribute-value\":\"4\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numaMem-1\",\"value\":\"4096\",\"operator\":\"=\",\"unit\":\"MB\"}]},{\"hpa-feature\":\"basicCapabilities\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numVirtualCpu\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"virtualMemSize\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"GB\"}]},{\"hpa-feature\":\"hugePages\",\"mandatory\":\"False\",\"score\":\"7\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"memoryPageSize\",\"hpa-attribute-value\":\"<MEMORYPAGESIZE>\",\"operator\":\"=\",\"unit\":\"\"}]}]}]}}",
+    "policyName": "oofBeijing.Config_MS_hpaPolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "hpaPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"VnfPolicy\",\"policyName\":\"oofBeijing.vnfPolicy_vG\",\"description\":\"vnfPolicy\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"6\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"identity\":\"vnf_vG\",\"policyScope\":[\"vCPE\",\"INTERNATIONAL\",\"ip\",\"vG\"],\"policyType\":\"vnf_policy\",\"resources\":[\"vG\"],\"applicableResources\":\"any\",\"vnfProperties\":[{\"inventoryProvider\":\"aai\",\"serviceType\":\"\",\"inventoryType\":\"cloud\",\"customerId\":\"\"},{\"inventoryProvider\":\"multicloud\",\"serviceType\":\"HNGATEWAY\",\"inventoryType\":\"service\",\"customerId\":\"21014aa2-526b-11e6-beb8-9e71128cae77\"}]}}",
+    "policyName": "oofBeijing.Config_MS_vnfPolicy_vG.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "VnfPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"VnfPolicy\",\"policyName\":\"oofBeijing.vnfPolicy_vGMuxInfra\",\"description\":\"vnfPolicy\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"6\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"identity\":\"vnf_vGMuxInfra\",\"policyScope\":[\"vCPE\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\"],\"policyType\":\"vnf_policy\",\"resources\":[\"vGMuxInfra\"],\"applicableResources\":\"any\",\"vnfProperties\":[{\"inventoryProvider\":\"aai\",\"serviceType\":\"\",\"inventoryType\":\"cloud\",\"customerId\":\"\"},{\"inventoryProvider\":\"multicloud\",\"serviceType\":\"HNGATEWAY\",\"inventoryType\":\"service\",\"customerId\":\"21014aa2-526b-11e6-beb8-9e71128cae77\"}]}}",
+    "policyName": "oofBeijing.Config_MS_vnfPolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "VnfPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"distancePolicy\",\"policyName\":\"oofBeijing.distancePolicy_vG\",\"description\":\"Distance Policy for vG\",\"templateVersion\":\"0.0.1\",\"version\":\"oofBeijing\",\"priority\":\"3\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"distanceProperties\":{\"locationInfo\":\"customer_location\",\"distance\":{\"value\":\"1500\",\"operator\":\"<\",\"unit\":\"km\"}},\"identity\":\"distance-vG\",\"resources\":[\"vG\"],\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vG\"],\"policyType\":\"distancePolicy\",\"applicableResources\":\"any\"}}",
+    "policyName": "oofBeijing.Config_MS_distancePolicy_vG.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "distancePolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"capacityPolicy\",\"policyName\":\"oofBeijing.capacityPolicy_vG\",\"description\":\"Capacity policy for vG\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"5\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"identity\":\"capacity_vG\",\"policyScope\":[\"VCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vG\"],\"resources\":[\"vG\"],\"capacityProperty\":{\"cpu\":{\"value\":2,\"operator\":\">\"},\"memory\":{\"value\":4,\"operator\":\">\",\"unit\":\"GB\"}},\"policyType\":\"capacityPolicy\",\"applicableResources\":\"any\"}}",
+    "policyName": "oofBeijing.Config_MS_capacityPolicy_vG.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "capacityPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"optimizationQueryPolicy\",\"policyName\":\"oofBeijing.queryPolicy_vCPE\",\"description\":\"Optimization query policy for vCPE\",\"templateVersion\":\"0.0.1\",\"version\":\"oofBeijing\",\"priority\":\"3\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"queryProperties\":[{\"attribute\":\"locationId\",\"value\":\"orderInfo.customerLocation\"},{\"attribute\":\"id\",\"value\":\"orderInfo.vpnInfo\"},{\"attribute\":\"upstreamBW\",\"value\":\"orderInfo.vpnInfo\"}],\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\",\"vG\"],\"policyType\":\"optimizationQueryPolicy\"}}",
+    "policyName": "oofBeijing.Config_MS_queryPolicy_vCPE.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "optimizationQueryPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"PlacementOptimizationPolicy\",\"policyName\":\"oofBeijing.PlacementOptimizationPolicy_vGMuxInfra\",\"description\":\"Placement Optimization Policy for vGMuxInfra\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"5\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"objectiveParameter\":{\"parameterAttributes\":[{\"resource\":[\"vGMuxInfra\"],\"customerLocationInfo\":\"customer_loc\",\"parameter\":\"distance\",\"weight\":\"1\",\"operator\":\"product\"},{\"resource\":[\"vG\"],\"customerLocationInfo\":\"customer_loc\",\"parameter\":\"distance\",\"weight\":\"1\",\"operator\":\"product\"}],\"operator\":\"sum\"},\"identity\":\"optimization\",\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\",\"vG\"],\"policyType\":\"placementOptimization\",\"objective\":\"minimize\"}}",
+    "policyName": "oofBeijing.Config_MS_PlacementOptimizationPolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "PlacementOptimizationPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"distancePolicy\",\"policyName\":\"oofBeijing.distancePolicy_vGMuxInfra\",\"description\":\"Distance Policy for vGMuxInfra\",\"templateVersion\":\"0.0.1\",\"version\":\"oofBeijing\",\"priority\":\"3\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"distanceProperties\":{\"locationInfo\":\"customer_location\",\"distance\":{\"value\":\"500\",\"operator\":\"<\",\"unit\":\"km\"}},\"identity\":\"distance-vGMuxInfra\",\"resources\":[\"vGMuxInfra\"],\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\"],\"policyType\":\"distancePolicy\",\"applicableResources\":\"any\"}}",
+    "policyName": "oofBeijing.Config_MS_distancePolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "distancePolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"capacityPolicy\",\"policyName\":\"oofBeijing.capacityPolicy_vGMuxInfra\",\"description\":\"Capacity policy for vGMuxInfra\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"5\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"identity\":\"capacity_vGMuxInfra\",\"policyScope\":[\"VCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\"],\"resources\":[\"vGMuxInfra\"],\"capacityProperty\":{\"cpu\":{\"value\":2,\"operator\":\">\"},\"memory\":{\"value\":4,\"operator\":\">\",\"unit\":\"GB\"}},\"policyType\":\"capacityPolicy\",\"applicableResources\":\"any\"}}",
+    "policyName": "oofBeijing.Config_MS_capacityPolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "capacityPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  }
+]
\ No newline at end of file
diff --git a/test/placement-tests/policy_response_error2.json b/test/placement-tests/policy_response_error2.json
new file mode 100644 (file)
index 0000000..c302a72
--- /dev/null
@@ -0,0 +1,182 @@
+[
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"SubscriberPolicy\",\"policyName\":\"oofBeijing.SubscriberPolicy_v1\",\"description\":\"Subscriber Policy\",\"templateVersion\":\"0.0.1\",\"version\":\"oofBeijing\",\"priority\":\"1\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"identity\":\"subscriber\",\"policyScope\":[\"vCPE\",\"subscriber_x\",\"subscriber_y\"],\"properties\":{\"subscriberName\":[\"subscriber_x\",\"subscriber_y\"],\"subscriberRole\":[],\"provStatus\":[\"CAPPED\"]},\"policyType\":\"SubscriberPolicy\"}}",
+    "policyName": "oofBeijing.Config_MS_SubscriberPolicy_v1.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "SubscriberPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"hpaPolicy\",\"policyName\":\"oofBeijing.hpaPolicy_vGMuxInfra\",\"description\":\"HPA policy for vGMuxInfra\",\"templateVersion\":\"0.0.1\",\"version\":\"1.0\",\"priority\":\"3\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"resources\":\"vGMuxInfra\",\"identity\":\"hpaPolicy_vGMuxInfra\",\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\"],\"policyType\":\"hpaPolicy\",\"flavorFeatures\":[{\"flavorLabel\":\"flavor_label_vm_01\",\"flavorProperties\":[{\"hpa-feature\":\"cpuTopology\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numCpuSockets\",\"hpa-attribute-value\":\"2\",\"operator\":\">=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuSockets\",\"hpa-attribute-value\":\"4\",\"operator\":\"<=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuCores\",\"hpa-attribute-value\":\"2\",\"operator\":\">=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuCores\",\"hpa-attribute-value\":\"4\",\"operator\":\"<=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuThreads\",\"hpa-attribute-value\":\"4\",\"operator\":\">=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numCpuThreads\",\"hpa-attribute-value\":\"8\",\"operator\":\"<=\",\"unit\":\"\"}]},{\"hpa-feature\":\"basicCapabilities\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numVirtualCpu\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"virtualMemSize\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"GB\"}]},{\"hpa-feature\":\"ovsDpdk\",\"mandatory\":\"False\",\"score\":\"3\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"dataProcessingAccelerationLibrary\",\"hpa-attribute-value\":\"ovsDpdk_version\",\"operator\":\"=\",\"unit\":\"\"}]},{\"hpa-feature\":\"cpuInstructionSetExtensions\",\"mandatory\":\"True\",\"architecture\":\"INTEL-64\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"instructionSetExtensions\",\"hpa-attribute-value\":[\"<CPUINST>\",\"<CPUINST>\"],\"operator\":\"ALL\",\"unit\":\"\"}]}]},{\"flavorLabel\":\"flavor_label_vm_02\",\"flavorProperties\":[{\"hpa-feature\":\"cpuPinningy\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"logicalCpuThreadPinningPolicy\",\"hpa-attribute-value\":\"<CPUTHREADPOLICY>\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"logicalCpuPinningPolicy\",\"hpa-attribute-value\":\"<CPUPOLICY>\",\"operator\":\"=\",\"unit\":\"\"}]},{\"hpa-feature\":\"basicCapabilities\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numVirtualCpu\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"virtualMemSize\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"GB\"}]},{\"hpa-feature\":\"localStorage\",\"mandatory\":\"False\",\"score\":\"5\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"diskSize\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"GB\"},{\"hpa-attribute-key\":\"ephemeralDiskSize\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"GB\"},{\"hpa-attribute-key\":\"swapMemSize\",\"hpa-attribute-value\":\"16\",\"operator\":\"=\",\"unit\":\"MB\"}]},{\"hpa-feature\":\"pcie\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"pciCount\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"pciVendorId\",\"hpa-attribute-value\":\"8086\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"pciDeviceId\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"functionType\",\"hpa-attribute-value\":\"<PCITYPEVALUE>\",\"operator\":\"=\",\"unit\":\"\"}]}]},{\"flavorLabel\":\"flavor_label_vm_03\",\"flavorProperties\":[{\"hpa-feature\":\"numa\",\"mandatory\":\"False\",\"score\":\"5\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numaNodes\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numaCpu-0\",\"hpa-attribute-value\":\"2\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numaMem-0\",\"hpa-attribute-value\":\"2048\",\"operator\":\"=\",\"unit\":\"MB\"},{\"hpa-attribute-key\":\"numaCpu-1\",\"hpa-attribute-value\":\"4\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"numaMem-1\",\"value\":\"4096\",\"operator\":\"=\",\"unit\":\"MB\"}]},{\"hpa-feature\":\"basicCapabilities\",\"mandatory\":\"True\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"numVirtualCpu\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"\"},{\"hpa-attribute-key\":\"virtualMemSize\",\"hpa-attribute-value\":\"6\",\"operator\":\"=\",\"unit\":\"GB\"}]},{\"hpa-feature\":\"hugePages\",\"mandatory\":\"False\",\"score\":\"7\",\"architecture\":\"generic\",\"hpa-feature-attributes\":[{\"hpa-attribute-key\":\"memoryPageSize\",\"hpa-attribute-value\":\"<MEMORYPAGESIZE>\",\"operator\":\"=\",\"unit\":\"\"}]}]}]}}",
+    "policyName": "oofBeijing.Config_MS_hpaPolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "hpaPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"VnfPolicy\",\"policyName\":\"oofBeijing.vnfPolicy_vG\",\"description\":\"vnfPolicy\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"6\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"identity\":\"vnf_vG\",\"policyScope\":[\"vCPE\",\"INTERNATIONAL\",\"ip\",\"vG\"],\"policyType\":\"vnf_policy\",\"resources\":[\"vG\"],\"applicableResources\":\"any\",\"vnfProperties\":[{\"inventoryProvider\":\"aai\",\"serviceType\":\"\",\"inventoryType\":\"cloud\",\"customerId\":\"\"},{\"inventoryProvider\":\"multicloud\",\"serviceType\":\"HNGATEWAY\",\"inventoryType\":\"service\",\"customerId\":\"21014aa2-526b-11e6-beb8-9e71128cae77\"}]}}",
+    "policyName": "oofBeijing.Config_MS_vnfPolicy_vG.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "VnfPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"VnfPolicy\",\"policyName\":\"oofBeijing.vnfPolicy_vGMuxInfra\",\"description\":\"vnfPolicy\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"6\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"identity\":\"vnf_vGMuxInfra\",\"policyScope\":[\"vCPE\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\"],\"policyType\":\"vnf_policy\",\"resources\":[\"vGMuxInfra\"],\"applicableResources\":\"any\",\"vnfProperties\":[{\"inventoryProvider\":\"aai\",\"serviceType\":\"\",\"inventoryType\":\"cloud\",\"customerId\":\"\"},{\"inventoryProvider\":\"multicloud\",\"serviceType\":\"HNGATEWAY\",\"inventoryType\":\"service\",\"customerId\":\"21014aa2-526b-11e6-beb8-9e71128cae77\"}]}}",
+    "policyName": "oofBeijing.Config_MS_vnfPolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "VnfPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"distancePolicy\",\"policyName\":\"oofBeijing.distancePolicy_vG\",\"description\":\"Distance Policy for vG\",\"templateVersion\":\"0.0.1\",\"version\":\"oofBeijing\",\"priority\":\"3\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"distanceProperties\":{\"locationInfo\":\"customer_location\",\"distance\":{\"value\":\"1500\",\"operator\":\"<\",\"unit\":\"km\"}},\"identity\":\"distance-vG\",\"resources\":[\"vG\"],\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vG\"],\"policyType\":\"distancePolicy\",\"applicableResources\":\"any\"}}",
+    "policyName": "oofBeijing.Config_MS_distancePolicy_vG.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "distancePolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"capacityPolicy\",\"policyName\":\"oofBeijing.capacityPolicy_vG\",\"description\":\"Capacity policy for vG\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"5\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"identity\":\"capacity_vG\",\"policyScope\":[\"VCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vG\"],\"resources\":[\"vG\"],\"capacityProperty\":{\"cpu\":{\"value\":2,\"operator\":\">\"},\"memory\":{\"value\":4,\"operator\":\">\",\"unit\":\"GB\"}},\"policyType\":\"capacityPolicy\",\"applicableResources\":\"any\"}}",
+    "policyName": "oofBeijing.Config_MS_capacityPolicy_vG.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "capacityPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"optimizationQueryPolicy\",\"policyName\":\"oofBeijing.queryPolicy_vCPE\",\"description\":\"Optimization query policy for vCPE\",\"templateVersion\":\"0.0.1\",\"version\":\"oofBeijing\",\"priority\":\"3\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"queryProperties\":[{\"attribute\":\"locationId\",\"value\":\"orderInfo.customerLocation\"},{\"attribute\":\"id\",\"value\":\"orderInfo.vpnInfo\"},{\"attribute\":\"upstreamBW\",\"value\":\"orderInfo.vpnInfo\"}],\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\",\"vG\"],\"policyType\":\"optimizationQueryPolicy\"}}",
+    "policyName": "oofBeijing.Config_MS_queryPolicy_vCPE.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "optimizationQueryPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"PlacementOptimizationPolicy\",\"policyName\":\"oofBeijing.PlacementOptimizationPolicy_vGMuxInfra\",\"description\":\"Placement Optimization Policy for vGMuxInfra\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"5\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"objectiveParameter\":{\"parameterAttributes\":[{\"resource\":[\"vGMuxInfra\"],\"customerLocationInfo\":\"customer_loc\",\"parameter\":\"distance\",\"weight\":\"1\",\"operator\":\"product\"},{\"resource\":[\"vG\"],\"customerLocationInfo\":\"customer_loc\",\"parameter\":\"distance\",\"weight\":\"1\",\"operator\":\"product\"}],\"operator\":\"sum\"},\"identity\":\"optimization\",\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\",\"vG\"],\"policyType\":\"placementOptimization\",\"objective\":\"minimize\"}}",
+    "policyName": "oofBeijing.Config_MS_PlacementOptimizationPolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "PlacementOptimizationPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"distancePolicy\",\"policyName\":\"oofBeijing.distancePolicy_vGMuxInfra\",\"description\":\"Distance Policy for vGMuxInfra\",\"templateVersion\":\"0.0.1\",\"version\":\"oofBeijing\",\"priority\":\"3\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"distanceProperties\":{\"locationInfo\":\"customer_location\",\"distance\":{\"value\":\"500\",\"operator\":\"<\",\"unit\":\"km\"}},\"identity\":\"distance-vGMuxInfra\",\"resources\":[\"vGMuxInfra\"],\"policyScope\":[\"vCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\"],\"policyType\":\"distancePolicy\",\"applicableResources\":\"any\"}}",
+    "policyName": "oofBeijing.Config_MS_distancePolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "distancePolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  },
+  {
+    "policyConfigMessage": "Config Retrieved! ",
+    "policyConfigStatus": "CONFIG_RETRIEVED",
+    "type": "JSON",
+    "config": "{\"service\":\"capacityPolicy\",\"policyName\":\"oofBeijing.capacityPolicy_vGMuxInfra\",\"description\":\"Capacity policy for vGMuxInfra\",\"templateVersion\":\"1702.03\",\"version\":\"oofBeijing\",\"priority\":\"5\",\"riskType\":\"test\",\"riskLevel\":\"2\",\"guard\":\"False\",\"content\":{\"identity\":\"capacity_vGMuxInfra\",\"policyScope\":[\"VCPE\",\"US\",\"INTERNATIONAL\",\"ip\",\"vGMuxInfra\"],\"resources\":[\"vGMuxInfra\"],\"capacityProperty\":{\"cpu\":{\"value\":2,\"operator\":\">\"},\"memory\":{\"value\":4,\"operator\":\">\",\"unit\":\"GB\"}},\"policyType\":\"capacityPolicy\",\"applicableResources\":\"any\"}}",
+    "policyName": "oofBeijing.Config_MS_capacityPolicy_vGMuxInfra.1.xml",
+    "policyVersion": "1",
+    "matchingConditions": {
+      "ECOMPName": "SNIRO-Placement",
+      "ONAPName": "SNIRO-Placement",
+      "ConfigName": "",
+      "service": "capacityPolicy",
+      "uuid": "",
+      "Location": ""
+    },
+    "responseAttributes": { },
+    "property": null
+  }
+]
\ No newline at end of file
index c4cb31f..d9b16ca 100644 (file)
@@ -11,6 +11,7 @@
   },
   "placementInfo": {
     "requestParameters": { "customerLatitude": 32.89748, "customerLongitude": -97.040443, "customerName": "xyz" },
+    "subscriberInfo": {"globalSubscriberId": "xxx-xx-xxx", "subscriberName": "subscriber_x"},
     "placementDemands": [
         {
             "resourceModuleName": "vGMuxInfra",
diff --git a/test/placement-tests/request_error1.json b/test/placement-tests/request_error1.json
new file mode 100644 (file)
index 0000000..65a145f
--- /dev/null
@@ -0,0 +1,101 @@
+{
+  "requestInfo": {
+    "transactionId": "xxx-xxx-xxxx",
+    "requestId": "yyy-yyy-yyyy",
+    "callbackUrl": "https://wiki.onap.org:5000/callbackUrl/",
+    "sourceId": "SO",
+    "requestType": "create",
+    "numSolutions": 1,
+    "optimizers": ["placement"],
+    "timeout": 600
+  },
+  "placementInfo": {
+    "requestParameters": { "customerLatitude": 32.89748, "customerLongitude": -97.040443, "customerName": "xyz" },
+    "subscriberInfo": {"globalSubscriberId": "xxx-xx-xxx", "subscriberName": "subscriber_x"},
+    "placementDemands": [
+        {
+            "resourceModuleName": "vGMuxInfra",
+            "serviceResourceId": "vGMuxInfra-xx",
+            "tenantId": "vGMuxInfra-tenant",
+            "resourceModelInfo": {
+                "modelInvariantId": "vGMuxInfra-modelInvariantId",
+                "modelVersionId": "vGMuxInfra-versionId",
+                "modelName": "vGMuxInfra-model",
+                "modelType": "resource",
+                "modelVersion": "1.0",
+                "modelCustomizationName": "vGMuxInfra-customeModelName"
+            }
+        },
+        {
+            "resourceModuleName": "vG",
+            "serviceResourceId": "71d563e8-e714-4393-8f99-cc480144a05e",
+            "tenantId": "vG-tenant",
+            "resourceModelInfo": {
+                "modelInvariantId": "vG-modelInvariantId",
+                "modelVersionId": "vG-versionId",
+                "modelName": "vG-model",
+                "modelType": "resource",
+                "modelVersion": "1.0",
+                "modelCustomizationName": "vG-customeModelName"
+            },
+            "existingCandidates": [
+                {
+                    "identifierType": "serviceInstanceId",
+                    "cloudOwner": "",
+                    "identifiers": ["gjhd-098-fhd-987"]
+                }
+            ],
+            "excludedCandidates": [
+                {
+                    "identifierType": "serviceInstanceId",
+                    "cloudOwner": "",
+                    "identifiers": ["gjhd-098-fhd-987"]
+                },
+                {
+                    "identifierType": "vimId",
+                    "cloudOwner": "vmware",
+                    "identifiers": ["NYMDT67"]
+                }
+            ],
+            "requiredCandidates": [
+                {
+                    "identifierType": "vimId",
+                    "cloudOwner": "amazon",
+                    "identifiers": ["TXAUS219"]
+                }
+            ]
+        }
+    ]
+  },
+  "serviceInfo": {
+    "serviceInstanceId": "d61b2543-5914-4b8f-8e81-81e38575b8ec",
+    "modelInfo": {
+      "modelInvariantId": "vCPE-invariantId",
+      "modelVersionId": "vCPE-versionId",
+      "modelName": "vCPE-model",
+      "modelType": "service",
+      "modelVersion": "1.0",
+      "modelCustomizationName": "vCPE-customeModelName"
+    }
+  },
+  "licenseInfo": {
+      "licenseDemands": [
+        {
+          "resourceModuleName": "vGMuxInfra",
+          "serviceResourceId": "vGMuxInfra-xx",
+          "resourceModelInfo": {
+            "modelInvariantId": "vGMuxInfra-modelInvariantId",
+            "modelVersionId": "vGMuxInfra-versionId",
+            "modelName": "vGMuxInfra-model",
+            "modelType": "resource",
+            "modelVersion": "1.0",
+            "modelCustomizationName": "vGMuxInfra-customeModelName"
+          },
+          "existingLicenses": {
+            "entitlementPoolUUID": ["87257b49-9602-4ca1-9817-094e52bc873b", "43257b49-9602-4fe5-9337-094e52bc9435"],
+            "licenseKeyGroupUUID": ["87257b49-9602-4ca1-9817-094e52bc873b", "43257b49-9602-4fe5-9337-094e52bc9435"]
+          }
+        }
+      ]
+  }
+}
\ No newline at end of file
diff --git a/test/placement-tests/scopePolicies.json b/test/placement-tests/scopePolicies.json
deleted file mode 100644 (file)
index 123c8e2..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-    {\r
-        "policyConfigMessage": "Config Retrieved! ",\r
-        "policyConfigStatus": "CONFIG_RETRIEVED",\r
-        "type": "JSON",\r
-        "config": "{\"service\":\"ResourceRegionPolicy\",\"policyName\":\"bg4702.ResourceRegionPolicy_vhnportal_v1\",\"description\":\"ResourceRegionPolicy@CreatedBy:mh7921\",\"templateVersion\":\"1802V01\",\"version\":\"1802V01\",\"priority\":\"1\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"identity\":\"vhnPortalResourceRegion\",\"policyScope\":{\"serviceType\":[\"DHV\"],\"geoRegion\":[\"US\",\"INTERNATIONAL\"],\"subscriberRole\":[\"FFA Homing\"],\"networkType\":[\"ip\"],\"resourceInstanceType\":[\"Primary Service_Admin\",\"Secondary Service_Admin\"]},\"resourceRegionProperty\":{\"request\":\"{\\\"dhv_service_instance\\\": {\\\"get_param\\\": \\\"SERVICE_INST\\\"}, \\\"service_type\\\": \\\"vHNPortal\\\", \\\"e2evpnkey\\\": {\\\"get_param\\\": \\\"E2EVPNKEY\\\"}}\",\"controller\":\"SDN-C\"},\"type\":\"region_fit\",\"resourceInstanceType\":[\"Primary Service_Admin\",\"Secondary Service_Admin\"]}}",\r
-        "policyName": "bg4702.Config_MS_ResourceRegionPolicy_vhnportal_v1.1.xml",\r
-        "policyVersion": "1",\r
-        "matchingConditions": {\r
-            "serviceType": "DHV",\r
-            "ECOMPName": "SNIRO-Placement",\r
-            "ONAPName": "SNIRO-Placement",\r
-            "geoRegion": "US,INTERNATIONAL",\r
-            "service": "ResourceRegionPolicy",\r
-            "subscriberRole": "FFA Homing",\r
-            "type": "region_fit",\r
-            "networkType": "ip",\r
-            "resourceInstanceType": "Primary Service_Admin,Secondary Service_Admin"\r
-        },\r
-        "responseAttributes": {},\r
-        "property": null\r
-    }
\ No newline at end of file
index 36f0c17..d7bb213 100644 (file)
 {\r
-   "placementInfo": {\r
-      "serviceModelInfo": {\r
-         "modelVersion": "1.0",\r
-         "modelName": "vCPE",\r
-         "modelInvariantId": "250c90b4-42f9-4cd9-9270-fd33a0676f92",\r
-         "modelVersionId": "c233e7f3-bd70-4a2c-a88f-4f5743109e8d",\r
-         "modelType": "service"\r
-      },\r
-      "orderInfo":" {        \"requestParameters\": {            \"e2eVpnKey\": \"VPNL61657\",            \"dhvVendorName\": \"VELOCLOUD\",            \"dhvIPSec2TransportBandwidthUp\": \"10\",            \"vpnList\": [               {                  \"vpnInfo\": {                     \"pvcId\": \"5952413\",                     \"vpnId\": \"61657\"                  }               }           ],         \"dhvSiteEffectiveTransportBandwidth\": \"10\",            \"ucpeHostName\": \"US292IORLFL0102UJZZ01\",          \"commonSiteId\": \"90101124\",           \"dhvIPSec2TransportBandwidthDown\": \"10\",            \"vnfList\": [            {                \"vnfInfo\": {                    \"vnfType\": \"HN\",                    \"veloCloudNominalThroughput\": \"100\",                     \"vnfHostName\": \"US292IORLFL0102UVHN01\",                   \"vnfPartNumber\": \"DHV-VNF-VC-10M\",                    \"vnfManagementOption\": \"ATT\",                  \"vnfSoftwareVersion\": \"2.4.1\"                }             }            ]       }     }",\r
-      "serviceInstanceId": "4701bd3c-b722-4d07-abc0-183ea398fac5",\r
-      "demandInfo": {\r
-         "placementDemand": [\r
-            {\r
-               "tenantName": "",\r
-               "tenantId": "",\r
-               "serviceResourceId": "a297f69d-4d68-4d1f-8b06-be61bddf9e7f",\r
-               "resourceInstanceType": "vVIGaaS",\r
-               "resourceModuleName": "Primary Tunnel_XConn for DHV Testing_1 0",\r
-               "resourceModelInfo": {\r
-                  "modelVersion": "1.0",\r
-                  "modelName": "Tunnel_XConn for DHV Testing_1",\r
-                  "modelInvariantId": "b2ac0b6a-c157-4f27-a226-4fc6c1d5b08c",\r
-                  "modelCustomizationId": "8ade4a5f-a446-4b14-9d12-3ccdd80ef55c",\r
-                  "modelVersionId": "c3c3531a-a0c6-498f-8512-03793f7772fa",\r
-                  "modelType": "allottedResource"\r
-               }\r
-            },\r
-            {\r
-               "tenantName": "",\r
-               "tenantId": "",\r
-               "serviceResourceId": "73190cfb-e9de-4185-8f18-cb339df6b92a",\r
-               "resourceInstanceType": "vVIGaaS",\r
-               "resourceModuleName": "Secondary Tunnel_XConn for DHV Testing_1 1",\r
-               "resourceModelInfo": {\r
-                  "modelVersion": "1.0",\r
-                  "modelName": "Tunnel_XConn for DHV Testing_1",\r
-                  "modelInvariantId": "b2ac0b6a-c157-4f27-a226-4fc6c1d5b08c",\r
-                  "modelCustomizationId": "32b80123-84ea-4bda-82d9-4c70e812b450",\r
-                  "modelVersionId": "c3c3531a-a0c6-498f-8512-03793f7772fa",\r
-                  "modelType": "allottedResource"\r
-               }\r
-            },\r
-            {\r
-               "tenantName": "",\r
-               "tenantId": "",\r
-               "serviceResourceId": "f8489f98-db3d-4e84-9ec7-7f7b17b9857f",\r
-               "resourceInstanceType": "vHNPortalaaS",\r
-               "resourceModuleName": "Primary Service_Admin for DHV Test_1 0",\r
-               "resourceModelInfo": {\r
-                  "modelVersion": "1.0",\r
-                  "modelName": "Service_Admin for DHV Test_1",\r
-                  "modelInvariantId": "a8031455-34bc-4608-b731-973c258822d2",\r
-                  "modelCustomizationId": "bace7e9f-c0e7-4479-93df-aa10d387038b",\r
-                  "modelVersionId": "0e830d97-39fc-4310-a11d-ebab6c71b35e",\r
-                  "modelType": "allottedResource"\r
-               }\r
-            },\r
-            {\r
-               "tenantName": "",\r
-               "tenantId": "",\r
-               "serviceResourceId": "8a8973d4-3a91-4fe6-a846-6f4c282f9005",\r
-               "resourceInstanceType": "vHNPortalaaS",\r
-               "resourceModuleName": "Secondary Service_Admin for DHV Test_1 1",\r
-               "resourceModelInfo": {\r
-                  "modelVersion": "1.0",\r
-                  "modelName": "Service_Admin for DHV Test_1",\r
-                  "modelInvariantId": "a8031455-34bc-4608-b731-973c258822d2",\r
-                  "modelCustomizationId": "cb6d359d-8f83-41b6-b0cc-fb3cdf978e25",\r
-                  "modelVersionId": "0e830d97-39fc-4310-a11d-ebab6c71b35e",\r
-                  "modelType": "allottedResource"\r
-               }\r
-            },\r
-            {\r
-               "tenantName": "",\r
-               "tenantId": "",\r
-               "serviceResourceId": "3f2b0c6d-6867-4369-b597-d929305da414",\r
-               "resourceInstanceType": "vHNGWaaS",\r
-               "resourceModuleName": "Primary IP_Mux_Demux updated_1 0",\r
-               "resourceModelInfo": {\r
-                  "modelVersion": "1.0",\r
-                  "modelName": "IP_Mux_Demux updated_1",\r
-                  "modelInvariantId": "72ad23e8-575d-4bc1-a88d-bb63ca66b85f",\r
-                  "modelCustomizationId": "925db703-945a-4b14-aafa-607c99c32f46",\r
-                  "modelVersionId": "cb760674-1c09-4316-837f-1ee1e816c26f",\r
-                  "modelType": "allottedResource"\r
-               }\r
-            },\r
-            {\r
-               "tenantName": "",\r
-               "tenantId": "",\r
-               "serviceResourceId": "caea369e-90e6-4bf0-9aa4-c80ffb10c77e",\r
-               "resourceInstanceType": "vHNGWaaS",\r
-               "resourceModuleName": "Secondary IP_Mux_Demux updated_1 1",\r
-               "resourceModelInfo": {\r
-                  "modelVersion": "1.0",\r
-                  "modelName": "IP_Mux_Demux updated_1",\r
-                  "modelInvariantId": "72ad23e8-575d-4bc1-a88d-bb63ca66b85f",\r
-                  "modelCustomizationId": "5f5793d7-843c-4f8e-b01d-35ece0b17ead",\r
-                  "modelVersionId": "cb760674-1c09-4316-837f-1ee1e816c26f",\r
-                  "modelType": "allottedResource"\r
-               }\r
+  "requestInfo": {\r
+    "transactionId": "xxx-xxx-xxxx",\r
+    "requestId": "yyy-yyy-yyyy",\r
+    "callbackUrl": "https://wiki.onap.org:5000/callbackUrl/",\r
+    "sourceId": "SO",\r
+    "requestType": "create",\r
+    "numSolutions": 1,\r
+    "optimizers": ["placement"],\r
+    "timeout": 600\r
+  },\r
+  "placementInfo": {\r
+    "requestParameters": { "customerLatitude": 32.89748, "customerLongitude": -97.040443, "customerName": "xyz" },\r
+    "subscriberInfo": {"globalSubscriberId": "xxx-xx-xxx", "subscriberName": "subscriber_x"},\r
+    "placementDemands": [\r
+        {\r
+            "resourceModuleName": "vGMuxInfra",\r
+            "serviceResourceId": "vGMuxInfra-xx",\r
+            "tenantId": "vGMuxInfra-tenant",\r
+            "resourceModelInfo": {\r
+                "modelInvariantId": "vGMuxInfra-modelInvariantId",\r
+                "modelVersionId": "vGMuxInfra-versionId",\r
+                "modelName": "vGMuxInfra-model",\r
+                "modelType": "resource",\r
+                "modelVersion": "1.0",\r
+                "modelCustomizationName": "vGMuxInfra-customeModelName"\r
             }\r
-         ]\r
-      },\r
-      "subscriberInfo": {\r
-         "subscriberCommonSiteId": null,\r
-         "globalSubscriberId": "300NCQ",\r
-         "subscriberName": "Test Customer"\r
-      },\r
-      "policyId": [\r
-         "SNIRO.DistanceToLocationPolicy_vhngw",\r
-         "SNIRO.VNFPolicy_vhngatewayprimary1_v1",\r
-         "SNIRO.ResourceInstancePolicy_hngateway",\r
-         "SNIRO.ResourceRegionPolicy_hngateway_v1",\r
-         "SNIRO.VNFPolicy_vhngatewaysecondary1_v1",\r
-         "SNIRO.ZonePolicy_vhngw",\r
-         "SNIRO.PlacementOptimizationPolicy_dhv_v3",\r
-         "SNIRO.VNFPolicy_vhnportal_primary1_v1",\r
-         "SNIRO.ResourceInstancePolicy_vhnportal_v3",\r
-         "SNIRO.ResourceRegionPolicy_vhnportal_v1",\r
-         "SNIRO.VNFPolicy_vhnportalsecondary1_v1",\r
-         "SNIRO.ZonePolicy_vhnportal",\r
-         "SNIRO.DistanceToLocationPolicy_vvig",\r
-         "SNIRO.InventoryGroupPolicy_vvig",\r
-         "SNIRO.VNFPolicy_vvigprimary1_v1",\r
-         "SNIRO.ResourceInstancePolicy_vvig",\r
-         "SNIRO.VNFPolicy_vvigsecondary1_v1"\r
+        },\r
+        {\r
+            "resourceModuleName": "vG",\r
+            "serviceResourceId": "71d563e8-e714-4393-8f99-cc480144a05e",\r
+            "tenantId": "vG-tenant",\r
+            "resourceModelInfo": {\r
+                "modelInvariantId": "vG-modelInvariantId",\r
+                "modelVersionId": "vG-versionId",\r
+                "modelName": "vG-model",\r
+                "modelType": "resource",\r
+                "modelVersion": "1.0",\r
+                "modelCustomizationName": "vG-customeModelName"\r
+            },\r
+            "existingCandidates": [\r
+                {\r
+                    "identifierType": "serviceInstanceId",\r
+                    "cloudOwner": "",\r
+                    "identifiers": ["gjhd-098-fhd-987"]\r
+                }\r
+            ],\r
+            "excludedCandidates": [\r
+                {\r
+                    "identifierType": "serviceInstanceId",\r
+                    "cloudOwner": "",\r
+                    "identifiers": ["gjhd-098-fhd-987"]\r
+                },\r
+                {\r
+                    "identifierType": "vimId",\r
+                    "cloudOwner": "vmware",\r
+                    "identifiers": ["NYMDT67"]\r
+                }\r
+            ],\r
+            "requiredCandidates": [\r
+                {\r
+                    "identifierType": "vimId",\r
+                    "cloudOwner": "amazon",\r
+                    "identifiers": ["TXAUS219"]\r
+                }\r
+            ]\r
+        }\r
+    ]\r
+  },\r
+  "serviceInfo": {\r
+    "serviceInstanceId": "d61b2543-5914-4b8f-8e81-81e38575b8ec",\r
+    "serviceName": "vCPE",\r
+    "modelInfo": {\r
+      "modelInvariantId": "vCPE-invariantId",\r
+      "modelVersionId": "vCPE-versionId",\r
+      "modelName": "vCPE-model",\r
+      "modelType": "service",\r
+      "modelVersion": "1.0",\r
+      "modelCustomizationName": "vCPE-customeModelName"\r
+    }\r
+  },\r
+  "licenseInfo": {\r
+      "licenseDemands": [\r
+        {\r
+          "resourceModuleName": "vGMuxInfra",\r
+          "serviceResourceId": "vGMuxInfra-xx",\r
+          "resourceModelInfo": {\r
+            "modelInvariantId": "vGMuxInfra-modelInvariantId",\r
+            "modelVersionId": "vGMuxInfra-versionId",\r
+            "modelName": "vGMuxInfra-model",\r
+            "modelType": "resource",\r
+            "modelVersion": "1.0",\r
+            "modelCustomizationName": "vGMuxInfra-customeModelName"\r
+          },\r
+          "existingLicenses": {\r
+            "entitlementPoolUUID": ["87257b49-9602-4ca1-9817-094e52bc873b", "43257b49-9602-4fe5-9337-094e52bc9435"],\r
+            "licenseKeyGroupUUID": ["87257b49-9602-4ca1-9817-094e52bc873b", "43257b49-9602-4fe5-9337-094e52bc9435"]\r
+          }\r
+        }\r
       ]\r
-   },\r
-   "requestInfo": {\r
-      "transactionId": "264e9db9-6d59-4888-9c90-51245d7c811f",\r
-      "sourceId": "mso",\r
-      "requestType": "initial",\r
-      "callbackUrl": "http://127.0.0.1:7001",\r
-      "requestId": "264e9db9-6d59-4888-9c90-51245d7c811f",\r
-      "optimizer": [\r
-         "placement",\r
-         "license"\r
-      ],\r
-      "numSolutions": 1,\r
-      "timeout": 1800\r
-   }\r
-}\r
+  }\r
+}
\ No newline at end of file
index 0b53e5f..2cdd4e4 100644 (file)
@@ -1,20 +1,24 @@
+references:
+    service_name:
+        source: request
+        value: serviceInfo.serviceName
+    subscriber_role:
+        source: SubscriberPolicy
+        value: content.properties.subscriberRole
+
 policy_info:
     placement:
         policy_fetch: by_scope
         policy_scope:
-            default_scope: XXX_1802
-            scope_vcpe: oof_beijing
-            service_name: placementInfo.serviceModelInfo.modelName
-        policy_subscriber: SubscriberPolicy
-        subscriber_name: placementInfo.subscriberInfo.subscriberName
-        policy_type_vcpe:
-            - CloudAttributePolicy
-            - DistanceToLocationPolicy
-            - instanceReservationPolicy
-            - PlacementOptimizationPolicy
-            - ResourceInstancePolicy
-            - VNFPolicy
-            - ZonePolicy
+            default_scope: OSDF_R2
+            vcpe_scope: OSDF_R2
+            secondary_scopes:
+                -
+                    - get_param: service_name
+                    - SubscriberPolicy
+                -
+                    - get_param: service_name
+                    - get_param: subscriber_role
     default:  # if no explicit service related information is needed
         policy_fetch: by_name
         policy_scope: none
index 83cce55..8c0d638 100644 (file)
@@ -25,6 +25,7 @@ from osdf.utils.interfaces import RestClient, json_from_file
 import yaml
 from mock import patch
 from osdf.optimizers.placementopt.conductor import translation
+from osdf.operation.exceptions import BusinessException
 
 
 class TestPolicyCalls(unittest.TestCase):
@@ -44,75 +45,56 @@ class TestPolicyCalls(unittest.TestCase):
     def tearDown(self):
         pass
 
-    def test_get_subscriber_name(self):
-        req_json_obj = json.loads(open("./test/placement-tests/request_mso.json").read())
-        config_core = osdf_config.core
-        pmain = config_core['policy_info']['placement']
-        print(pmain)
-        subs_name = interface.get_subscriber_name(req_json_obj, pmain)
-        print("subscriber_name=", subs_name)
-        self.assertEquals(subs_name, "Avteet_Chayal")
+    def test_policy_api_call(self):
+        req_json_file = "./test/placement-tests/request.json"
+        req_json = json.loads(open(req_json_file).read())
+        policy_response_file = "./test/placement-tests/policy_response.json"
+        policy_response = json.loads(open(policy_response_file).read())
+        with patch('osdf.adapters.policy.interface.policy_api_call', return_value=policy_response):
+            policy_list = interface.remote_api(req_json, osdf_config, service_type="placement")
+            self.assertIsNotNone(policy_list)
 
-    def test_get_subscriber_name_null(self):
-        req_json_file = "./test/placement-tests/request_mso_subs_name_null.json"
-        req_json_obj = json.loads(open(req_json_file).read())
-        config_core = osdf_config.core
-        
-        pmain = config_core['policy_info']['placement']
-        print(pmain)
-        subs_name = interface.get_subscriber_name(req_json_obj, pmain)
-        print("subscriber_name=", subs_name)
-        self.assertEquals(subs_name, "DEFAULT")
-    
-    def test_get_subscriber_name_blank(self):
-        req_json_file = "./test/placement-tests/request_mso_subs_name_blank.json"
-        req_json_obj = json.loads(open(req_json_file).read())
-        config_core = osdf_config.core
-        
-        pmain = config_core['policy_info']['placement']
-        print(pmain)
-        subs_name = interface.get_subscriber_name(req_json_obj, pmain)
-        print("subscriber_name=", subs_name)
-        self.assertEquals(subs_name, "DEFAULT")
-    
-    def test_get_subscriber_name_default(self):
-        req_json_file = "./test/placement-tests/request_mso_subs_name_default.json"
-        req_json_obj = json.loads(open(req_json_file).read())
-        config_core = osdf_config.core
-        
-        pmain = config_core['policy_info']['placement']
-        print(pmain)
-        subs_name = interface.get_subscriber_name(req_json_obj, pmain)
-        print("subscriber_name=", subs_name)
-        self.assertEquals(subs_name, "DEFAULT")
-    
-    def test_get_subscriber_name_none(self):
-        req_json_file = "./test/placement-tests/request_mso_subs_name_none.json"
-        req_json_obj = json.loads(open(req_json_file).read())
-        config_core = osdf_config.core
-        
-        pmain = config_core['policy_info']['placement']
-        print(pmain)
-        subs_name = interface.get_subscriber_name(req_json_obj, pmain)
-        print("subscriber_name=", subs_name)
-        self.assertEquals(subs_name, "DEFAULT")
+    def test_policy_api_call_failed_1(self):
+        req_json_file = "./test/placement-tests/request_error1.json"
+        req_json = json.loads(open(req_json_file).read())
+        policy_response_file = "./test/placement-tests/policy_response.json"
+        policy_response = json.loads(open(policy_response_file).read())
+        with patch('osdf.adapters.policy.interface.policy_api_call', return_value=policy_response):
+            self.assertRaises(BusinessException,
+                              lambda: interface.remote_api(req_json, osdf_config, service_type="placement"))
+
+    def test_policy_api_call_failed_2(self):
+        req_json_file = "./test/placement-tests/request.json"
+        req_json = json.loads(open(req_json_file).read())
+        policy_response_file = "./test/placement-tests/policy_response_error1.json"
+        policy_response = json.loads(open(policy_response_file).read())
+        with patch('osdf.adapters.policy.interface.policy_api_call', return_value=policy_response):
+            self.assertRaises(BusinessException,
+                              lambda: interface.remote_api(req_json, osdf_config, service_type="placement"))
+
+    def test_policy_api_call_failed_3(self):
+        req_json_file = "./test/placement-tests/request.json"
+        req_json = json.loads(open(req_json_file).read())
+        policy_response_file = "./test/placement-tests/policy_response_error2.json"
+        policy_response = json.loads(open(policy_response_file).read())
+        with patch('osdf.adapters.policy.interface.policy_api_call', return_value=policy_response):
+            self.assertRaises(BusinessException,
+                              lambda: interface.remote_api(req_json, osdf_config, service_type="placement"))
     
     def test_get_by_scope(self):
         req_json_file = "./test/placement-tests/testScoperequest.json"
-        allPolicies = "./test/placement-tests/scopePolicies.json"
+        all_policies = "./test/placement-tests/policy_response.json"
         req_json_obj = json.loads(open(req_json_file).read())
-        req_json_obj2 = json.loads(open(allPolicies).read())
-        yamlFile = "./test/placement-tests/test_by_scope.yaml"
-        
-        with open(yamlFile) as yamlFile2:
-            policy_config_file = yaml.load(yamlFile2)
-            with patch('osdf.adapters.policy.interface.get_subscriber_role',
-                       return_value=('FFA Homing', [])) as mock_open:
-                with patch('osdf.utils.interfaces.RestClient.request', return_value=req_json_obj2):
-                    policiesList = interface.get_by_scope(RestClient, req_json_obj, policy_config_file, 'placement')
-                    self.assertTrue(policiesList, 'is null')
-                    self.assertRaises(Exception)
-    
+        req_json_obj2 = json.loads(open(all_policies).read())
+        yaml_file = "./test/placement-tests/test_by_scope.yaml"
+
+        with open(yaml_file) as yaml_file2:
+            policy_config_file = yaml.load(yaml_file2)
+            with patch('osdf.utils.interfaces.RestClient.request', return_value=req_json_obj2):
+                policies_list = interface.get_by_scope(RestClient, req_json_obj, policy_config_file, 'placement')
+                self.assertTrue(policies_list, 'is null')
+                self.assertRaises(Exception)
+
     def test_gen_demands(self):
         actionsList = []
         genDemandslist = []