summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnkitkumar Patel <ankit@research.att.com>2018-03-25 19:27:39 -0400
committerAnkitkumar Patel <ankit@research.att.com>2018-03-25 19:31:24 -0400
commitbc1d288ac29c3c9bf968cea5ac2d95b8bcd67eae (patch)
treee7dc43bd3bc59ab1855263c4a61832966283025c
parented70b5c6d6589e4e1ce80229612ea5b680736c4c (diff)
Update the policy adaptor and related testcases
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>
-rw-r--r--.gitignore4
-rw-r--r--config/common_config.yaml20
-rw-r--r--osdf/adapters/policy/interface.py157
-rwxr-xr-xosdfapp.py17
-rw-r--r--test/config/common_config.yaml22
-rw-r--r--test/placement-tests/policy_response.json182
-rw-r--r--test/placement-tests/policy_response_error1.json164
-rw-r--r--test/placement-tests/policy_response_error2.json182
-rw-r--r--test/placement-tests/request.json1
-rw-r--r--test/placement-tests/request_error1.json101
-rw-r--r--test/placement-tests/scopePolicies.json21
-rw-r--r--test/placement-tests/testScoperequest.json240
-rw-r--r--test/placement-tests/test_by_scope.yaml30
-rw-r--r--test/test_PolicyCalls.py110
14 files changed, 899 insertions, 352 deletions
diff --git a/.gitignore b/.gitignore
index 864f9ee..e1eb8cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -108,3 +108,7 @@ venv.bak/
# mypy
.mypy_cache/
+
+# pyCharm
+.idea/
+xunit*.xml
diff --git a/config/common_config.yaml b/config/common_config.yaml
index 89678a2..ec7098e 100644
--- a/config/common_config.yaml
+++ b/config/common_config.yaml
@@ -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
diff --git a/osdf/adapters/policy/interface.py b/osdf/adapters/policy/interface.py
index 02b8ff3..a3b5881 100644
--- a/osdf/adapters/policy/interface.py
+++ b/osdf/adapters/policy/interface.py
@@ -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
diff --git a/osdfapp.py b/osdfapp.py
index eb14530..348a88c 100755
--- a/osdfapp.py
+++ b/osdfapp.py
@@ -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(
diff --git a/test/config/common_config.yaml b/test/config/common_config.yaml
index 1c041d9..6a5f5e1 100644
--- a/test/config/common_config.yaml
+++ b/test/config/common_config.yaml
@@ -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
index 0000000..ed5b4ab
--- /dev/null
+++ b/test/placement-tests/policy_response.json
@@ -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
index 0000000..788c5c4
--- /dev/null
+++ b/test/placement-tests/policy_response_error1.json
@@ -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
index 0000000..c302a72
--- /dev/null
+++ b/test/placement-tests/policy_response_error2.json
@@ -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
diff --git a/test/placement-tests/request.json b/test/placement-tests/request.json
index c4cb31f..d9b16ca 100644
--- a/test/placement-tests/request.json
+++ b/test/placement-tests/request.json
@@ -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
index 0000000..65a145f
--- /dev/null
+++ b/test/placement-tests/request_error1.json
@@ -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
index 123c8e2..0000000
--- a/test/placement-tests/scopePolicies.json
+++ /dev/null
@@ -1,21 +0,0 @@
- {
- "policyConfigMessage": "Config Retrieved! ",
- "policyConfigStatus": "CONFIG_RETRIEVED",
- "type": "JSON",
- "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\"]}}",
- "policyName": "bg4702.Config_MS_ResourceRegionPolicy_vhnportal_v1.1.xml",
- "policyVersion": "1",
- "matchingConditions": {
- "serviceType": "DHV",
- "ECOMPName": "SNIRO-Placement",
- "ONAPName": "SNIRO-Placement",
- "geoRegion": "US,INTERNATIONAL",
- "service": "ResourceRegionPolicy",
- "subscriberRole": "FFA Homing",
- "type": "region_fit",
- "networkType": "ip",
- "resourceInstanceType": "Primary Service_Admin,Secondary Service_Admin"
- },
- "responseAttributes": {},
- "property": null
- } \ No newline at end of file
diff --git a/test/placement-tests/testScoperequest.json b/test/placement-tests/testScoperequest.json
index 36f0c17..d7bb213 100644
--- a/test/placement-tests/testScoperequest.json
+++ b/test/placement-tests/testScoperequest.json
@@ -1,144 +1,102 @@
{
- "placementInfo": {
- "serviceModelInfo": {
- "modelVersion": "1.0",
- "modelName": "vCPE",
- "modelInvariantId": "250c90b4-42f9-4cd9-9270-fd33a0676f92",
- "modelVersionId": "c233e7f3-bd70-4a2c-a88f-4f5743109e8d",
- "modelType": "service"
- },
- "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\" } } ] } }",
- "serviceInstanceId": "4701bd3c-b722-4d07-abc0-183ea398fac5",
- "demandInfo": {
- "placementDemand": [
- {
- "tenantName": "",
- "tenantId": "",
- "serviceResourceId": "a297f69d-4d68-4d1f-8b06-be61bddf9e7f",
- "resourceInstanceType": "vVIGaaS",
- "resourceModuleName": "Primary Tunnel_XConn for DHV Testing_1 0",
- "resourceModelInfo": {
- "modelVersion": "1.0",
- "modelName": "Tunnel_XConn for DHV Testing_1",
- "modelInvariantId": "b2ac0b6a-c157-4f27-a226-4fc6c1d5b08c",
- "modelCustomizationId": "8ade4a5f-a446-4b14-9d12-3ccdd80ef55c",
- "modelVersionId": "c3c3531a-a0c6-498f-8512-03793f7772fa",
- "modelType": "allottedResource"
- }
- },
- {
- "tenantName": "",
- "tenantId": "",
- "serviceResourceId": "73190cfb-e9de-4185-8f18-cb339df6b92a",
- "resourceInstanceType": "vVIGaaS",
- "resourceModuleName": "Secondary Tunnel_XConn for DHV Testing_1 1",
- "resourceModelInfo": {
- "modelVersion": "1.0",
- "modelName": "Tunnel_XConn for DHV Testing_1",
- "modelInvariantId": "b2ac0b6a-c157-4f27-a226-4fc6c1d5b08c",
- "modelCustomizationId": "32b80123-84ea-4bda-82d9-4c70e812b450",
- "modelVersionId": "c3c3531a-a0c6-498f-8512-03793f7772fa",
- "modelType": "allottedResource"
- }
- },
- {
- "tenantName": "",
- "tenantId": "",
- "serviceResourceId": "f8489f98-db3d-4e84-9ec7-7f7b17b9857f",
- "resourceInstanceType": "vHNPortalaaS",
- "resourceModuleName": "Primary Service_Admin for DHV Test_1 0",
- "resourceModelInfo": {
- "modelVersion": "1.0",
- "modelName": "Service_Admin for DHV Test_1",
- "modelInvariantId": "a8031455-34bc-4608-b731-973c258822d2",
- "modelCustomizationId": "bace7e9f-c0e7-4479-93df-aa10d387038b",
- "modelVersionId": "0e830d97-39fc-4310-a11d-ebab6c71b35e",
- "modelType": "allottedResource"
- }
- },
- {
- "tenantName": "",
- "tenantId": "",
- "serviceResourceId": "8a8973d4-3a91-4fe6-a846-6f4c282f9005",
- "resourceInstanceType": "vHNPortalaaS",
- "resourceModuleName": "Secondary Service_Admin for DHV Test_1 1",
- "resourceModelInfo": {
- "modelVersion": "1.0",
- "modelName": "Service_Admin for DHV Test_1",
- "modelInvariantId": "a8031455-34bc-4608-b731-973c258822d2",
- "modelCustomizationId": "cb6d359d-8f83-41b6-b0cc-fb3cdf978e25",
- "modelVersionId": "0e830d97-39fc-4310-a11d-ebab6c71b35e",
- "modelType": "allottedResource"
- }
- },
- {
- "tenantName": "",
- "tenantId": "",
- "serviceResourceId": "3f2b0c6d-6867-4369-b597-d929305da414",
- "resourceInstanceType": "vHNGWaaS",
- "resourceModuleName": "Primary IP_Mux_Demux updated_1 0",
- "resourceModelInfo": {
- "modelVersion": "1.0",
- "modelName": "IP_Mux_Demux updated_1",
- "modelInvariantId": "72ad23e8-575d-4bc1-a88d-bb63ca66b85f",
- "modelCustomizationId": "925db703-945a-4b14-aafa-607c99c32f46",
- "modelVersionId": "cb760674-1c09-4316-837f-1ee1e816c26f",
- "modelType": "allottedResource"
- }
- },
- {
- "tenantName": "",
- "tenantId": "",
- "serviceResourceId": "caea369e-90e6-4bf0-9aa4-c80ffb10c77e",
- "resourceInstanceType": "vHNGWaaS",
- "resourceModuleName": "Secondary IP_Mux_Demux updated_1 1",
- "resourceModelInfo": {
- "modelVersion": "1.0",
- "modelName": "IP_Mux_Demux updated_1",
- "modelInvariantId": "72ad23e8-575d-4bc1-a88d-bb63ca66b85f",
- "modelCustomizationId": "5f5793d7-843c-4f8e-b01d-35ece0b17ead",
- "modelVersionId": "cb760674-1c09-4316-837f-1ee1e816c26f",
- "modelType": "allottedResource"
- }
+ "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"
}
- ]
- },
- "subscriberInfo": {
- "subscriberCommonSiteId": null,
- "globalSubscriberId": "300NCQ",
- "subscriberName": "Test Customer"
- },
- "policyId": [
- "SNIRO.DistanceToLocationPolicy_vhngw",
- "SNIRO.VNFPolicy_vhngatewayprimary1_v1",
- "SNIRO.ResourceInstancePolicy_hngateway",
- "SNIRO.ResourceRegionPolicy_hngateway_v1",
- "SNIRO.VNFPolicy_vhngatewaysecondary1_v1",
- "SNIRO.ZonePolicy_vhngw",
- "SNIRO.PlacementOptimizationPolicy_dhv_v3",
- "SNIRO.VNFPolicy_vhnportal_primary1_v1",
- "SNIRO.ResourceInstancePolicy_vhnportal_v3",
- "SNIRO.ResourceRegionPolicy_vhnportal_v1",
- "SNIRO.VNFPolicy_vhnportalsecondary1_v1",
- "SNIRO.ZonePolicy_vhnportal",
- "SNIRO.DistanceToLocationPolicy_vvig",
- "SNIRO.InventoryGroupPolicy_vvig",
- "SNIRO.VNFPolicy_vvigprimary1_v1",
- "SNIRO.ResourceInstancePolicy_vvig",
- "SNIRO.VNFPolicy_vvigsecondary1_v1"
+ },
+ {
+ "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",
+ "serviceName": "vCPE",
+ "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"]
+ }
+ }
]
- },
- "requestInfo": {
- "transactionId": "264e9db9-6d59-4888-9c90-51245d7c811f",
- "sourceId": "mso",
- "requestType": "initial",
- "callbackUrl": "http://127.0.0.1:7001",
- "requestId": "264e9db9-6d59-4888-9c90-51245d7c811f",
- "optimizer": [
- "placement",
- "license"
- ],
- "numSolutions": 1,
- "timeout": 1800
- }
-}
+ }
+} \ No newline at end of file
diff --git a/test/placement-tests/test_by_scope.yaml b/test/placement-tests/test_by_scope.yaml
index 0b53e5f..2cdd4e4 100644
--- a/test/placement-tests/test_by_scope.yaml
+++ b/test/placement-tests/test_by_scope.yaml
@@ -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
diff --git a/test/test_PolicyCalls.py b/test/test_PolicyCalls.py
index 83cce55..8c0d638 100644
--- a/test/test_PolicyCalls.py
+++ b/test/test_PolicyCalls.py
@@ -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 = []