diff options
Diffstat (limited to 'test')
196 files changed, 8577 insertions, 870 deletions
diff --git a/test/adapters/dcae/des_response.json b/test/adapters/dcae/des_response.json new file mode 100644 index 0000000..c8595eb --- /dev/null +++ b/test/adapters/dcae/des_response.json @@ -0,0 +1,47 @@ +{ + "result": [ + { + "additionalMeasurements": [ + { + "hashMap":{ + "networkId":"plmnid1", + "InterEnbOutAtt_X2HO":"300", + "InterEnbOutSucc_X2HO":"290" + }, + "name":"Chn0004" + }, + { + "hashMap":{ + "InterEnbOutAtt_X2HO":"250", + "InterEnbOutSucc_X2HO":"170" + }, + "name":"Chn0001" + } + ] + }, + { + "additionalMeasurements": [ + { + "hashMap":{ + "networkId":"plmnid1", + "InterEnbOutAtt_X2HO":"300", + "InterEnbOutSucc_X2HO":"290" + }, + "name":"Chn0004" + }, + { + "hashMap":{ + "InterEnbOutAtt_X2HO":"250", + "InterEnbOutSucc_X2HO":"170" + }, + "name":"Chn0001" + } + ] + } + ], + "request": { + "cell_id": "Chn0002", + "interval": 2 + }, + "result_count": 2 +}
\ No newline at end of file diff --git a/test/adapters/dcae/test_des.py b/test/adapters/dcae/test_des.py new file mode 100644 index 0000000..6e2520a --- /dev/null +++ b/test/adapters/dcae/test_des.py @@ -0,0 +1,71 @@ +# ------------------------------------------------------------------------- +# Copyright (C) 2020 Wipro Limited. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# + +import mock +from mock import patch +from requests import RequestException +from requests.exceptions import HTTPError +import unittest +from osdf.adapters.dcae import des +from osdf.adapters.dcae.des import DESException +import osdf.config.loader as config_loader +from osdf.utils.interfaces import json_from_file +from osdf.utils.programming_utils import DotDict + + +class TestDes(unittest.TestCase): + + def setUp(self): + self.config_spec = { + "deployment": "config/osdf_config.yaml", + "core": "config/common_config.yaml" + } + self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec)) + + def tearDown(self): + pass + + def test_extract_data(self): + response_file = 'test/adapters/dcae/des_response.json' + response_json = json_from_file(response_file) + + des_config = self.osdf_config.core['PCI']['DES'] + service_id = des_config['service_id'] + data = des_config['filter'] + expected = response_json['result'] + response = mock.MagicMock() + response.status_code = 200 + response.ok = True + response.json.return_value = response_json + self.patcher_req = patch('requests.request', return_value=response) + self.Mock_req = self.patcher_req.start() + self.assertEqual(expected, des.extract_data(service_id, data)) + self.patcher_req.stop() + + response = mock.MagicMock() + response.status_code = 404 + response.raise_for_status.side_effect = HTTPError("404") + self.patcher_req = patch('requests.request', return_value=response) + self.Mock_req = self.patcher_req.start() + self.assertRaises(DESException, des.extract_data, service_id, data) + self.patcher_req.stop() + + self.patcher_req = patch('requests.request', side_effect=RequestException("error")) + self.Mock_req = self.patcher_req.start() + self.assertRaises(DESException, des.extract_data, service_id, data) + self.patcher_req.stop() diff --git a/test/apps/nxi_termination/_init_.py b/test/apps/nxi_termination/_init_.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/apps/nxi_termination/_init_.py diff --git a/test/apps/nxi_termination/aai_exception_response.json b/test/apps/nxi_termination/aai_exception_response.json new file mode 100644 index 0000000..56f61df --- /dev/null +++ b/test/apps/nxi_termination/aai_exception_response.json @@ -0,0 +1,4 @@ +{ + "status-code": 404, + "status-response": "NOT FOUND" +}
\ No newline at end of file diff --git a/test/apps/nxi_termination/aai_response.json b/test/apps/nxi_termination/aai_response.json new file mode 100644 index 0000000..b7ef43b --- /dev/null +++ b/test/apps/nxi_termination/aai_response.json @@ -0,0 +1,64 @@ +{"service-instance": [{ + "service-instance-id": "1a636c4d-5e76-427e-bfd6-241a947224b0", + "service-instance-name": "nssi_test_0211", + "service-type": "embb", + "service-role": "nssi", + "environment-context": "cn", + "model-invariant-id": "21d57d4b-52ad-4d3c-a798-248b5bb9124a", + "model-version-id": "bfba363e-e39c-4bd9-a9d5-1371c28f4d22", + "resource-version": "1581418601616", + "orchestration-status": "active", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4115d3c8-dd59-45d6-b09d-e756dee9b518", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4115d3c8-dd59-45d6-b09d-e756dee9b518" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_test_0211" + } + ] + } + ] + }, + "slice-profiles": { + "slice-profile": [ + { + "profile-id": "cdad9f49-4201-4e3a-aac1-b0f27902c299", + "latency": 20, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 100, + "exp-data-rate-DL": 100, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "reliability": 99.999, + "resource-version": "1581418602494" + } + ] + } +}]} diff --git a/test/apps/nxi_termination/exception_response1.json b/test/apps/nxi_termination/exception_response1.json new file mode 100644 index 0000000..cde603f --- /dev/null +++ b/test/apps/nxi_termination/exception_response1.json @@ -0,0 +1,7 @@ +{ + "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestStatus": "failure", + "reason": "Error response recieved from AAI for the request" + +}
\ No newline at end of file diff --git a/test/apps/nxi_termination/failure_relationship_list.json b/test/apps/nxi_termination/failure_relationship_list.json new file mode 100644 index 0000000..392f4db --- /dev/null +++ b/test/apps/nxi_termination/failure_relationship_list.json @@ -0,0 +1,66 @@ +[ + { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v23/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/d88b6ce6-19be-439d-8553-4f9d6cce0494/allotted-resources/allotted-resource/07138106-f535-413b-b002-40ba24f95937", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "07138106-f535-413b-b002-40ba24f95937" + }, + { + "relationship-key": "allotted-resource.id", + "relationship-value": "07138106-f535-413b-b002-40ba24f95937" + } + ], + "related-to-property": [ + { + "property-key": "allotted-resource.description" + }, + { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_coe" + } + ] + }, + { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v23/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/d88b6ce6-19be-439d-8553-4f9d6cce0494/allotted-resources/allotted-resource/07138106-f535-413b-b002-40ba24f95937", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "d290f1ee-6c54-4b01-90e6-d701748f0851" + }, + { + "relationship-key": "allotted-resource.id", + "relationship-value": "d290f1ee-6c54-4b01-90e6-d701748f0851" + } + ], + "related-to-property": [ + { + "property-key": "allotted-resource.description" + }, + { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_terminate" + } + ] + } +]
\ No newline at end of file diff --git a/test/apps/nxi_termination/failure_relationship_list2.json b/test/apps/nxi_termination/failure_relationship_list2.json new file mode 100644 index 0000000..624448a --- /dev/null +++ b/test/apps/nxi_termination/failure_relationship_list2.json @@ -0,0 +1,52 @@ +[ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4115d3c8-dd59-45d6-b09d-e756dee9b518", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4115d3c8-dd59-45d6-b09d-e756dee9b567" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_test_0211" + } + ] + }, + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4115d3c8-dd59-45d6-b09d-e756dee9b518", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "4115d3c8-dd59-45d6-b09d-e756dee9b567" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "nsi_test_0211" + } + ] + } + ]
\ No newline at end of file diff --git a/test/apps/nxi_termination/failure_service_profiles.json b/test/apps/nxi_termination/failure_service_profiles.json new file mode 100644 index 0000000..d10a818 --- /dev/null +++ b/test/apps/nxi_termination/failure_service_profiles.json @@ -0,0 +1,24 @@ +[ + { + "profile-id": "cdad9f49-4201-4e3a-aac1-b0f27902c29", + "latency": 20, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 100, + "exp-data-rate-DL": 100, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "reliability": 99.999, + "resource-version": "1581418602494" + } +] + + diff --git a/test/apps/nxi_termination/failure_service_profiles2.json b/test/apps/nxi_termination/failure_service_profiles2.json new file mode 100644 index 0000000..1740758 --- /dev/null +++ b/test/apps/nxi_termination/failure_service_profiles2.json @@ -0,0 +1,42 @@ +[ + { + "profile-id": "cdad9f49-4201-4e3a-aac1-b0f27902c299", + "latency": 20, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 100, + "exp-data-rate-DL": 100, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "reliability": 99.999, + "resource-version": "1581418602494" + }, + { + "profile-id": "abcd9f49-4201-4e3a-aac1-b0f27902c299", + "latency": 20, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 100, + "exp-data-rate-DL": 100, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "reliability": 99.999, + "resource-version": "1581418602494" + } +] diff --git a/test/apps/nxi_termination/invalid_request.json b/test/apps/nxi_termination/invalid_request.json new file mode 100644 index 0000000..72eafd7 --- /dev/null +++ b/test/apps/nxi_termination/invalid_request.json @@ -0,0 +1,17 @@ +{ + "requestInfo": { + "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "callbackUrl": "http://0.0.0.0:9000/osdfCallback/", + "sourceId": "SO", + "timeout": 5, + "addtnlArgs": { + "serviceInstanceId":"cdad9f49-4201-4e3a-aac1-b0f27902c299" + } + }, + "type":"NST", + "NxIId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "UUID":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "invariantUUID":"d290f1ee-6c54-4b01-90e6-d701748f0851" + +} diff --git a/test/apps/nxi_termination/nsi_success_output.json b/test/apps/nxi_termination/nsi_success_output.json new file mode 100644 index 0000000..e25a272 --- /dev/null +++ b/test/apps/nxi_termination/nsi_success_output.json @@ -0,0 +1,7 @@ +{ + "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestStatus": "success", + "terminateResponse": true, + "reason": "" +}
\ No newline at end of file diff --git a/test/apps/nxi_termination/nssi_failure_output.json b/test/apps/nxi_termination/nssi_failure_output.json new file mode 100644 index 0000000..f300c53 --- /dev/null +++ b/test/apps/nxi_termination/nssi_failure_output.json @@ -0,0 +1,8 @@ +{ + "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestStatus": "success", + "terminateResponse": false, + "reason": "" + +}
\ No newline at end of file diff --git a/test/apps/nxi_termination/nssi_termination.json b/test/apps/nxi_termination/nssi_termination.json new file mode 100644 index 0000000..b4e3711 --- /dev/null +++ b/test/apps/nxi_termination/nssi_termination.json @@ -0,0 +1,17 @@ +{ + "requestInfo": { + "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "callbackUrl": "http://0.0.0.0:9000/osdfCallback/", + "sourceId": "SO", + "timeout": 5, + "addtnlArgs": { + "serviceInstanceId":"4115d3c8-dd59-45d6-b09d-e756dee9b518" + } + }, + "type":"NSSI", + "NxIId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "UUID":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "invariantUUID":"d290f1ee-6c54-4b01-90e6-d701748f0851" + +}
\ No newline at end of file diff --git a/test/apps/nxi_termination/nxi_failure_output1.json b/test/apps/nxi_termination/nxi_failure_output1.json new file mode 100644 index 0000000..4cce5eb --- /dev/null +++ b/test/apps/nxi_termination/nxi_failure_output1.json @@ -0,0 +1,10 @@ +{ + "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestStatus": "success", + "terminateResponse": false, + "reason": "" + +} + + diff --git a/test/apps/nxi_termination/nxi_failure_output2.json b/test/apps/nxi_termination/nxi_failure_output2.json new file mode 100644 index 0000000..f18b73c --- /dev/null +++ b/test/apps/nxi_termination/nxi_failure_output2.json @@ -0,0 +1,7 @@ +{ + "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestStatus": "success", + "terminateResponse": false, + "reason": "" +}
\ No newline at end of file diff --git a/test/apps/nxi_termination/nxi_termination.json b/test/apps/nxi_termination/nxi_termination.json new file mode 100644 index 0000000..1e25f2e --- /dev/null +++ b/test/apps/nxi_termination/nxi_termination.json @@ -0,0 +1,17 @@ +{ + "requestInfo": { + "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "callbackUrl": "http://0.0.0.0:9000/osdfCallback/", + "sourceId": "SO", + "timeout": 5, + "addtnlArgs": { + "serviceInstanceId":"cdad9f49-4201-4e3a-aac1-b0f27902c299" + } + }, + "type":"NSI", + "NxIId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "UUID":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "invariantUUID":"d290f1ee-6c54-4b01-90e6-d701748f0851" + +} diff --git a/test/apps/nxi_termination/service_profiles.json b/test/apps/nxi_termination/service_profiles.json new file mode 100644 index 0000000..899acb4 --- /dev/null +++ b/test/apps/nxi_termination/service_profiles.json @@ -0,0 +1,23 @@ +[ + { + "profile-id": "cdad9f49-4201-4e3a-aac1-b0f27902c299", + "latency": 20, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 100, + "exp-data-rate-DL": 100, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "reliability": 99.999, + "resource-version": "1581418602494" + } +] + diff --git a/test/apps/nxi_termination/success_relationship_list.json b/test/apps/nxi_termination/success_relationship_list.json new file mode 100644 index 0000000..608418d --- /dev/null +++ b/test/apps/nxi_termination/success_relationship_list.json @@ -0,0 +1,34 @@ +[ + { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v23/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/d88b6ce6-19be-439d-8553-4f9d6cce0494/allotted-resources/allotted-resource/07138106-f535-413b-b002-40ba24f95937", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "cdad9f49-4201-4e3a-aac1-b0f27902c299" + }, + { + "relationship-key": "allotted-resource.id", + "relationship-value": "07138106-f535-413b-b002-40ba24f95937" + } + ], + "related-to-property": [ + { + "property-key": "allotted-resource.description" + }, + { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_coe" + } + ] + } +]
\ No newline at end of file diff --git a/test/apps/nxi_termination/test_fetch_aai_data.py b/test/apps/nxi_termination/test_fetch_aai_data.py new file mode 100644 index 0000000..241b24b --- /dev/null +++ b/test/apps/nxi_termination/test_fetch_aai_data.py @@ -0,0 +1,70 @@ +# ------------------------------------------------------------------------- +# Copyright (C) 2020 Wipro Limited. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# + +import unittest +import mock +from unittest.mock import patch +from osdf.config.base import osdf_config +import osdf.config.loader as config_loader +from osdf.utils.programming_utils import DotDict +from osdf.utils.interfaces import json_from_file +from osdf.adapters.aai.fetch_aai_data import get_aai_data,AAIException + +class TestRemoteOptProcessor(unittest.TestCase): + def setUp(self): + self.config_spec = { + "deployment": "config/osdf_config.yaml", + "core": "config/common_config.yaml" + } + self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec)) + + def tearDown(self): + + patch.stopall() + + + def test_get_aai_data(self): + main_dir = "" + response_file = main_dir + 'test/apps/nxi_termination/aai_response.json' + exception_response_file = main_dir + 'test/apps/nxi_termination/aai_exception_response.json' + request_file = main_dir + 'test/apps/nxi_termination/nxi_termination.json' + response_json = json_from_file(response_file) + request_json = json_from_file(request_file) + exception_json = json_from_file(exception_response_file) + response = mock.MagicMock() + response.status_code = 200 + response.ok = True + response.json.return_value = response_json + self.patcher_req = patch('requests.get', + return_value = response) + self.Mock_req = self.patcher_req.start() + self.assertEquals(response_json, get_aai_data(request_json,osdf_config)) + self.patcher_req.stop() + + responsenew=mock.MagicMock() + responsenew.status_code=404 + responsenew.json.return_value = exception_json + self.patcher_req = patch('requests.get', + return_value=responsenew) + self.Mock_req = self.patcher_req.start() + self.assertRaises( AAIException,get_aai_data,request_json,osdf_config) + self.patcher_req.stop() + + +if __name__ == "__main__": + unittest.main()
\ No newline at end of file diff --git a/test/apps/nxi_termination/test_remote_opt_processor_termination.py b/test/apps/nxi_termination/test_remote_opt_processor_termination.py new file mode 100644 index 0000000..555f2e8 --- /dev/null +++ b/test/apps/nxi_termination/test_remote_opt_processor_termination.py @@ -0,0 +1,136 @@ +# ------------------------------------------------------------------------- +# Copyright (C) 2020 Wipro Limited. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# + +import unittest +from unittest.mock import patch +import osdf.config.loader as config_loader +import pytest +from apps.nxi_termination.optimizers.remote_opt_processor import process_nxi_termination_opt +from osdf.adapters.aai.fetch_aai_data import AAIException + +from osdf.config.base import osdf_config +from osdf.utils.programming_utils import DotDict +from osdf.utils.interfaces import json_from_file + +class TestRemoteOptProcessor(unittest.TestCase): + def setUp(self): + self.config_spec = { + "deployment": "config/osdf_config.yaml", + "core": "config/common_config.yaml" + } + self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec)) + + def tearDown(self): + + patch.stopall() + + def test_process_nxi_termination_opt(self): + main_dir = "" + request_file = main_dir + 'test/apps/nxi_termination/nxi_termination.json' + nssi_request_file=main_dir + 'test/apps/nxi_termination/nssi_termination.json' + service_file = main_dir + 'test/apps/nxi_termination/service_profiles.json' + failure_service_file = main_dir + 'test/apps/nxi_termination/failure_service_profiles.json' + failure_service_file2 = main_dir + 'test/apps/nxi_termination/failure_service_profiles2.json' + nsi_success=main_dir + 'test/apps/nxi_termination/nsi_success_output.json' + nxi_failure1 = main_dir + 'test/apps/nxi_termination/nxi_failure_output1.json' + nxi_failure2 = main_dir + 'test/apps/nxi_termination/nxi_failure_output2.json' + nssi_failure = main_dir + 'test/apps/nxi_termination/nssi_failure_output.json' + success_rel_file = main_dir + 'test/apps/nxi_termination/success_relationship_list.json' + failure_rel_file1 = main_dir + 'test/apps/nxi_termination/failure_relationship_list.json' + failure_rel_file2 = main_dir + 'test/apps/nxi_termination/failure_relationship_list2.json' + exception_response_file1 = main_dir + 'test/apps/nxi_termination/exception_response1.json' + request_json=json_from_file(request_file) + nssi_request_json = json_from_file(nssi_request_file) + service_profile_json = json_from_file(service_file) + failure_service_profile_json = json_from_file(failure_service_file) + failure_service_profile_json2 = json_from_file(failure_service_file2) + success_rel_json=json_from_file(success_rel_file) + failure_rel_json = json_from_file(failure_rel_file1) + failure_rel_json2 = json_from_file(failure_rel_file2) + success_output_json=json_from_file(nsi_success) + nxi_failure_output_json1 = json_from_file(nxi_failure1) + nxi_failure_output_json2 = json_from_file(nxi_failure2) + nssi_failure_output_json = json_from_file(nssi_failure) + exception_response_json1 = json_from_file(exception_response_file1) + + #nsi success scenario + self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_allotted_resources', return_value=success_rel_json) + self.Mock_req = self.patcher_req.start() + self.assertEquals(success_output_json, process_nxi_termination_opt(request_json, osdf_config)) + self.patcher_req.stop() + + #nsi failure scenario + self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_allotted_resources', return_value=failure_rel_json) + self.Mock_req = self.patcher_req.start() + self.assertEquals(nxi_failure_output_json1, process_nxi_termination_opt(request_json, osdf_config)) + self.patcher_req.stop() + + request_json["requestInfo"]["addtnlArgs"] = {} + + #nsi success scenario + self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_allotted_resources', + return_value=[]) + self.Mock_req = self.patcher_req.start() + self.assertEquals(success_output_json, process_nxi_termination_opt(request_json, osdf_config)) + self.patcher_req.stop() + + # # + # nssi success scenario + self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count', return_value=1) + self.Mock_req = self.patcher_req.start() + self.assertEquals(success_output_json, process_nxi_termination_opt(nssi_request_json, osdf_config)) + self.patcher_req.stop() + + # nssi failure scenario + self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count', + return_value=2) + self.Mock_req = self.patcher_req.start() + self.assertEquals(nssi_failure_output_json, process_nxi_termination_opt(nssi_request_json, osdf_config)) + self.patcher_req.stop() + + nssi_request_json["requestInfo"]["addtnlArgs"] = {} + + # nssi success scenario + self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count', + return_value=0) + self.Mock_req = self.patcher_req.start() + self.assertEquals(success_output_json, process_nxi_termination_opt(nssi_request_json, osdf_config)) + self.patcher_req.stop() + + # nssi failure scenario + self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count', + return_value=1) + self.Mock_req = self.patcher_req.start() + self.assertEquals(nxi_failure_output_json2, process_nxi_termination_opt(nssi_request_json, osdf_config)) + self.patcher_req.stop() + + self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count', + side_effect=AAIException("Error response recieved from AAI for the request")) + self.Mock_req = self.patcher_req.start() + self.assertEquals("failure", process_nxi_termination_opt(nssi_request_json, osdf_config).get('requestStatus')) + self.patcher_req.stop() + + self.patcher_req = patch('apps.nxi_termination.optimizers.remote_opt_processor.get_resource_count', + side_effect=AAIException("Request exception was encountered")) + self.Mock_req = self.patcher_req.start() + self.assertEquals("failure", process_nxi_termination_opt(nssi_request_json, osdf_config).get('requestStatus')) + self.patcher_req.stop() + + +if __name__ == "__main__": + unittest.main()
\ No newline at end of file diff --git a/test/apps/pci_optimization/des_result.json b/test/apps/pci_optimization/des_result.json new file mode 100644 index 0000000..9209acf --- /dev/null +++ b/test/apps/pci_optimization/des_result.json @@ -0,0 +1,18 @@ +[ + [ + { + "overallHoAtt": 1300 + }, + { + "overallHoAtt": 550 + } + ], + [ + { + "overallHoAtt": 450 + }, + { + "overallHoAtt": 400 + } + ] +] diff --git a/test/apps/pci_optimization/test_ml_model.py b/test/apps/pci_optimization/test_ml_model.py new file mode 100644 index 0000000..cf0dee5 --- /dev/null +++ b/test/apps/pci_optimization/test_ml_model.py @@ -0,0 +1,87 @@ +# ------------------------------------------------------------------------- +# Copyright (C) 2020 Wipro Limited. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# + +import copy +from mock import patch +import unittest +from apps.pci.optimizers.solver.ml_model import MlModel +from osdf.adapters.dcae.des import DESException +import osdf.config.loader as config_loader +from osdf.utils.interfaces import json_from_file +from osdf.utils.programming_utils import DotDict + + +class TestMlModel(unittest.TestCase): + def setUp(self): + self.config_spec = { + "deployment": "config/osdf_config.yaml", + "core": "config/common_config.yaml" + } + self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec)) + + def tearDown(self): + pass + + def test_ml_model(self): + des_result_file = 'test/apps/pci_optimization/des_result.json' + results = json_from_file(des_result_file) + + dzn_data = { + 'NUM_NODES': 4, + 'NUM_PCIS': 4, + 'NUM_NEIGHBORS': 4, + 'NEIGHBORS': [], + 'NUM_SECOND_LEVEL_NEIGHBORS': 1, + 'SECOND_LEVEL_NEIGHBORS': [], + 'PCI_UNCHANGEABLE_CELLS': {}, + 'ORIGINAL_PCIS': [] + } + + network_cell_info = { + 'cell_list': [ + { + 'cell_id': 'Chn0001', + 'id': 1, + 'nbr_list': [] + }, + { + 'cell_id': 'Chn0002', + 'id': 2, + 'nbr_list': [] + } + ] + } + self.patcher_req = patch('osdf.adapters.dcae.des.extract_data', side_effect=results) + self.Mock_req = self.patcher_req.start() + mlmodel = MlModel() + mlmodel.get_additional_inputs(dzn_data, network_cell_info) + self.assertEqual({1}, dzn_data['PCI_UNCHANGEABLE_CELLS']) + self.patcher_req.stop() + + dzn_data['PCI_UNCHANGEABLE_CELLS'] = [] + self.patcher_req = patch('osdf.adapters.dcae.des.extract_data', side_effect=DESException('error')) + self.Mock_req = self.patcher_req.start() + mlmodel.get_additional_inputs(dzn_data, network_cell_info) + self.assertEqual(set() , dzn_data['PCI_UNCHANGEABLE_CELLS']) + self.patcher_req.stop() + + self.patcher_req = patch('osdf.adapters.dcae.des.extract_data', return_value=[]) + self.Mock_req = self.patcher_req.start() + mlmodel.get_additional_inputs(dzn_data, network_cell_info) + self.assertEqual(set() , dzn_data['PCI_UNCHANGEABLE_CELLS']) + self.patcher_req.stop() diff --git a/test/apps/slice_selection/conductor_error_response.json b/test/apps/slice_selection/conductor_error_response.json new file mode 100644 index 0000000..95a9750 --- /dev/null +++ b/test/apps/slice_selection/conductor_error_response.json @@ -0,0 +1,18 @@ +{ + "plans": [ + { + "status": "error", + "message": "Some error message", + "name": "Plan Name 1", + "links": [ + [ + { + "href": "http://conductor:8091/v1/plans/plan_id", + "rel": "self" + } + ] + ], + "id": "plan_id" + } + ] +} diff --git a/test/apps/slice_selection/new_solution_conductor_response.json b/test/apps/slice_selection/new_solution_conductor_response.json new file mode 100644 index 0000000..897aa2b --- /dev/null +++ b/test/apps/slice_selection/new_solution_conductor_response.json @@ -0,0 +1,47 @@ +{ + "plans":[ + { + "status":"done", + "id":"plan_id", + "name":"Plan Name 1", + "links":[ + [ + { + "href":"http://conductor:8091/v1/plans/plan_id", + "rel":"self" + } + ] + ], + "recommendations":[ + { + "embb-nst":{ + "inventory_provider":"generator", + "candidate": { + "candidate_id":"1a636c4d-5e76-427e-bfd6-241a947224b0", + "latency":20, + "inventory_provider":"generator", + "max_number_of_ues":100, + "ue_mobility_level":"stationary", + "candidate_type":"slice_profiles", + "resource_sharing_level":"shared", + "inventory_type":"slice_profiles", + "reliability": 99.99, + "AN_latency": 10, + "AN_ue_mobility_level": "stationary", + "AN_max_number_of_ues": 100, + "AN_reliability": 99.99, + "AN_resource_sharing_level":"shared", + "CN_latency": 5, + "CN_reliability": 99.99, + "CN_resource_sharing_level":"shared", + "TN-BH_reliability": 99.99, + "TN-BH_latency": 5, + "TN-BH_resource_sharing_level":"shared", + "cost":1.0 + } + } + } + ] + } + ] +} diff --git a/test/apps/slice_selection/new_solution_nsi_response.json b/test/apps/slice_selection/new_solution_nsi_response.json new file mode 100644 index 0000000..52624b6 --- /dev/null +++ b/test/apps/slice_selection/new_solution_nsi_response.json @@ -0,0 +1,35 @@ +{ + "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestStatus": "completed", + "statusMessage": "", + "solutions": [ + { + "existingNSI": false, + "newNSISolution": { + "sliceProfiles": [ + { + "domainType": "AN", + "resourceSharingLevel": "shared", + "latency": 10, + "reliability": 99.99, + "uEMobilityLevel": "stationary", + "maxNumberofUEs": 100 + }, + { + "domainType": "CN", + "resourceSharingLevel": "shared", + "latency": 5, + "reliability": 99.99 + }, + { + "domainType": "TN-BH", + "resourceSharingLevel": "shared", + "latency": 5, + "reliability": 99.99 + } + ] + } + } + ] +} diff --git a/test/apps/slice_selection/no_rec.json b/test/apps/slice_selection/no_rec.json new file mode 100644 index 0000000..855afac --- /dev/null +++ b/test/apps/slice_selection/no_rec.json @@ -0,0 +1,18 @@ +{ + "plans": [ + { + "id": "d8c07237-5f66-4aa6-871c-a04221d99458", + "links": [ + [ + { + "href": "https://oof-has-api:8091/v1/plans/d8c07237-5f66-4aa6-871c-a04221d99458", + "rel": "self" + } + ] + ], + "message": "Plan d8c07237-5f66-4aa6-871c-a04221d99458 search failed, no recommendations found by machine dev-oof-has-solver-65d478b6d-ql5fp", + "name": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "status": "not found" + } + ] +} diff --git a/test/apps/slice_selection/no_recomm_conductor_response.json b/test/apps/slice_selection/no_recomm_conductor_response.json new file mode 100644 index 0000000..f23af87 --- /dev/null +++ b/test/apps/slice_selection/no_recomm_conductor_response.json @@ -0,0 +1,18 @@ +{
+ "plans":[
+ {
+ "status":"done",
+ "id":"plan_id",
+ "name":"Plan Name 1",
+ "links":[
+ [
+ {
+ "href":"http://conductor:8091/v1/plans/plan_id",
+ "rel":"self"
+ }
+ ]
+ ],
+ "recommendations": []
+ }
+ ]
+}
diff --git a/test/apps/slice_selection/no_recomm_nsi_response.json b/test/apps/slice_selection/no_recomm_nsi_response.json new file mode 100644 index 0000000..e36a243 --- /dev/null +++ b/test/apps/slice_selection/no_recomm_nsi_response.json @@ -0,0 +1,7 @@ +{
+ "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestStatus":"completed",
+ "statusMessage":"",
+ "solutions": []
+}
diff --git a/test/apps/slice_selection/nsi_error_response.json b/test/apps/slice_selection/nsi_error_response.json new file mode 100644 index 0000000..9dc5300 --- /dev/null +++ b/test/apps/slice_selection/nsi_error_response.json @@ -0,0 +1,6 @@ +{ + "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestStatus":"error", + "statusMessage":"Some error message" +} diff --git a/test/apps/slice_selection/nsi_request.json b/test/apps/slice_selection/nsi_request.json new file mode 100644 index 0000000..72b2c8b --- /dev/null +++ b/test/apps/slice_selection/nsi_request.json @@ -0,0 +1,31 @@ +{ + "serviceProfile": { + "latency": 2, + "security": "High", + "reliability": 99.9999, + "trafficDensity": 1, + "connDensity": 100000, + "expDataRate": 50, + "jitter": 1, + "survivalTime": 0, + "resourceSharingLevel":"shared" + }, + "serviceInfo":{ + "serviceInstanceId": "209fb01e-60ca-4325-b074-c5ad4e0499f8", + "serviceName": "" + }, + "requestInfo": { + "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "callbackUrl": "http://0.0.0.0:9000/osdfCallback/", + "sourceId": "SO", + "timeout": 5 + }, + "NSTInfoList": [ + { + "modelInvariantId": "fda3c1e8-7653-4acd-80ef-f5755c1d3859", + "modelVersionId": "a6906768-1cae-4e78-acd1-d753ac61f3e8", + "modelName": "URLLC_1" + } + ] +} diff --git a/test/apps/slice_selection/nsi_selection_invalid_request.json b/test/apps/slice_selection/nsi_selection_invalid_request.json new file mode 100644 index 0000000..3ecd1e3 --- /dev/null +++ b/test/apps/slice_selection/nsi_selection_invalid_request.json @@ -0,0 +1,80 @@ +{ + "serviceProfile": { + "latency": 2, + "security": "High", + "reliability": 99.9999, + "trafficDensity": 1, + "connDensity": 100000, + "expDataRate": 50, + "jitter": 1, + "survivalTime": 0, + "resourceSharingLevel":"shared" + }, + "requestInfo": { + "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "callbackUrl": "http://0.0.0.0:9000/osdfCallback/", + "sourceId": "SO", + "timeout": 5 + }, + "NSSTInfo":[ + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa2", + "invariantUUID":"2fa85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-an-nf" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa3", + "invariantUUID":"4fa85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-cn" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa4", + "invariantUUID":"5ta85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-tn-fh" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa5", + "invariantUUID":"6ya85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-tn-mh" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa7", + "invariantUUID":"7ua85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-tn-bh" + } + ], + "preferReuse":true, + "subnetCapabilities":[ + { + "domainType":"AN-NF", + "capabilityDetails":{ + "blob":"content" + } + }, + { + "domainType":"CN", + "capabilityDetails":{ + "blob":"content" + } + }, + { + "domainType":"TN-FH", + "capabilityDetails":{ + "blob":"content" + } + }, + { + "domainType":"TN-MH", + "capabilityDetails":{ + "blob":"content" + } + }, + { + "domainType":"TN-BH", + "capabilityDetails":{ + "blob":"content" + } + } + ] +} diff --git a/test/apps/slice_selection/nsi_selection_request.json b/test/apps/slice_selection/nsi_selection_request.json new file mode 100644 index 0000000..39fb925 --- /dev/null +++ b/test/apps/slice_selection/nsi_selection_request.json @@ -0,0 +1,84 @@ +{ + "serviceProfile":{ + "latency":5, + "security":"High", + "reliability":99.999, + "resourceSharingLevel":"shared" + }, + "requestInfo":{ + "transactionId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "callbackUrl": "http://0.0.0.0:9000/osdfCallback/", + "callbackHeader":{ + "blob":"content" + }, + "sourceId":"d290f1ee-6c54-4b01-90e6-d701748f0851", + "timeout":5, + "numSolutions":1 + }, + "NSTInfo":{ + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa1", + "invariantUUID":"7ua85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-nst" + }, + "NSSTInfo":[ + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa2", + "invariantUUID":"2fa85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-an-nf" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa3", + "invariantUUID":"4fa85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-cn" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa4", + "invariantUUID":"5ta85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-tn-fh" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa5", + "invariantUUID":"6ya85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-tn-mh" + }, + { + "UUID":"3fa85f64-5717-4562-b3fc-2c963f66afa7", + "invariantUUID":"7ua85f64-5717-4562-b3fc-2c963f66afa6", + "name":"embb-tn-bh" + } + ], + "preferReuse":false, + "subnetCapabilities":[ + { + "domainType":"AN", + "capabilityDetails":{ + "latency": "4", + "reliability": "99.9", + "maxNumberofUEs": "10", + "maxThroughput": "50", + "termDensity": "60" + } + }, + { + "domainType":"CN", + "capabilityDetails":{ + "latency": "3", + "reliability": "99.9", + "maxNumberofUEs": "10", + "maxThroughput": "50", + "termDensity": "60" + } + }, + { + "domainType":"TN-BH", + "capabilityDetails":{ + "latency": "2", + "reliability": "99.9", + "maxNumberofUEs": "10", + "maxThroughput": "50", + "termDensity": "60" + } + } + ] +} diff --git a/test/apps/slice_selection/nssi_conductor_response.json b/test/apps/slice_selection/nssi_conductor_response.json new file mode 100644 index 0000000..d2edcf5 --- /dev/null +++ b/test/apps/slice_selection/nssi_conductor_response.json @@ -0,0 +1,53 @@ +{ + "plans":[ + { + "status":"done", + "id":"plan_id", + "name":"Plan Name 1", + "links":[ + [ + { + "href":"http://conductor:8091/v1/plans/plan_id", + "rel":"self" + } + ] + ], + "recommendations":[ + { + "embb-cn": { + "inventory_provider": "aai", + "candidate": { + "exp_data_rate": 0, + "conn_density": 0, + "coverage_area_ta_list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", + "activity_factor": 0, + "cs_availability": null, + "candidate_id": "1a636c4d-5e76-427e-bfd6-241a947224b0", + "area_traffic_cap_dl": null, + "latency": 20, + "service_area_dimension": null, + "e2e_latency": 0, + "area_traffic_cap_ul": null, + "inventory_provider": "aai", + "exp_data_rate_ul": 100, + "max_number_of_ues": 0, + "ue_mobility_level": "stationary", + "candidate_type": "nssi", + "traffic_density": 0, + "payload_size": 0, + "exp_data_rate_dl": 100, + "jitter": 0, + "survival_time": 0, + "resource_sharing_level": "shared", + "inventory_type": "nssi", + "reliability": null, + "cost": 1.0, + "instance_id": "e1041cdc-12da-4f36-b84e-68c380e9cd47", + "instance_name": "nssi_test_0211" + } + } + } + ] + } + ] +} diff --git a/test/apps/slice_selection/nssi_error_response.json b/test/apps/slice_selection/nssi_error_response.json new file mode 100644 index 0000000..70e0596 --- /dev/null +++ b/test/apps/slice_selection/nssi_error_response.json @@ -0,0 +1,7 @@ +{ + "requestId":"r450f1ee-6c54-4b01-90e6-d701748f0851", + "transactionId":"t670f1ee-6c54-4b01-90e6-d701748f0851", + "requestStatus":"completed", + "statusMessage":"", + "solutions": [] +} diff --git a/test/apps/slice_selection/nssi_selection_invalid_request.json b/test/apps/slice_selection/nssi_selection_invalid_request.json new file mode 100644 index 0000000..57e0184 --- /dev/null +++ b/test/apps/slice_selection/nssi_selection_invalid_request.json @@ -0,0 +1,23 @@ +{ + "sliceProfile": { + "blob": "content" + }, + "requestInfo": { + "transactionId": "t670f1ee-6c54-4b01-90e6-d701748f0851", + "requestId": "r450f1ee-6c54-4b01-90e6-d701748f0851", + "callbackUrl": "http://0.0.0.0:9000/osdfCallback/", + "callbackHeader": { + "blob": "content" + }, + "sourceId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "timeout": 5, + "numSolutions": 1, + "addtnlArgs": { + "blob": "content" + } + }, + "NSSTInfo": { + "UUID": "y7785f64-5717-4562-b3fc-2c963f66afa6", + "name": "embb-cn" + } +} diff --git a/test/apps/slice_selection/nssi_selection_request.json b/test/apps/slice_selection/nssi_selection_request.json new file mode 100644 index 0000000..61ee563 --- /dev/null +++ b/test/apps/slice_selection/nssi_selection_request.json @@ -0,0 +1,27 @@ +{ + "sliceProfile": { + "latency":5, + "security":"High", + "reliability":99.999, + "resourceSharingLevel":"shared" + }, + "requestInfo": { + "transactionId": "t670f1ee-6c54-4b01-90e6-d701748f0851", + "requestId": "r450f1ee-6c54-4b01-90e6-d701748f0851", + "callbackUrl": "http://0.0.0.0:9000/osdfCallback/", + "callbackHeader": { + "blob": "content" + }, + "sourceId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "timeout": 5, + "numSolutions": 1, + "addtnlArgs": { + "blob": "content" + } + }, + "NSSTInfo": { + "UUID": "a7785f64-5717-4562-b3fc-2c963f66afa6", + "invariantUUID": "9fh85f64-5717-4562-b3fc-2c963f66afa6", + "name": "embb-cn" + } +} diff --git a/test/apps/slice_selection/shared_solution_conductor_response.json b/test/apps/slice_selection/shared_solution_conductor_response.json new file mode 100644 index 0000000..a187fef --- /dev/null +++ b/test/apps/slice_selection/shared_solution_conductor_response.json @@ -0,0 +1,53 @@ +{ + "plans":[ + { + "status":"done", + "id":"plan_id", + "name":"Plan Name 1", + "links":[ + [ + { + "href":"http://conductor:8091/v1/plans/plan_id", + "rel":"self" + } + ] + ], + "recommendations":[ + { + "embb-nst": { + "inventory_provider": "aai", + "candidate": { + "exp_data_rate": 0, + "conn_density": 0, + "coverage_area_ta_list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]", + "activity_factor": 0, + "cs_availability": null, + "candidate_id": "1a636c4d-5e76-427e-bfd6-241a947224b0", + "area_traffic_cap_dl": null, + "latency": 20, + "service_area_dimension": null, + "e2e_latency": 0, + "area_traffic_cap_ul": null, + "inventory_provider": "aai", + "exp_data_rate_ul": 100, + "max_number_of_ues": 0, + "ue_mobility_level": "stationary", + "candidate_type": "nsi", + "traffic_density": 0, + "payload_size": 0, + "exp_data_rate_dl": 100, + "jitter": 0, + "survival_time": 0, + "resource_sharing_level": "shared", + "inventory_type": "nsi", + "reliability": null, + "cost": 1.0, + "instance_id": "f1041cdc-12da-4f36-b84e-68c380e9cd47", + "instance_name": "nsi_test_0211" + } + } + } + ] + } + ] +} diff --git a/test/apps/slice_selection/shared_solution_nsi_response.json b/test/apps/slice_selection/shared_solution_nsi_response.json new file mode 100644 index 0000000..ff83dfc --- /dev/null +++ b/test/apps/slice_selection/shared_solution_nsi_response.json @@ -0,0 +1,17 @@ +{ + "requestId": "d290f1ee-6c54-4b01-90e6-d701748f0851", + "requestStatus": "completed", + "solutions": [ + { + "existingNSI": true, + "sharedNSISolution": { + "UUID": "3fa85f64-5717-4562-b3fc-2c963f66afa1", + "invariantUUID": "7ua85f64-5717-4562-b3fc-2c963f66afa6", + "NSIName": "nsi_test_0211", + "NSIId": "f1041cdc-12da-4f36-b84e-68c380e9cd47" + } + } + ], + "statusMessage": "", + "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851" +} diff --git a/test/apps/slice_selection/shared_solution_nssi_response.json b/test/apps/slice_selection/shared_solution_nssi_response.json new file mode 100644 index 0000000..f3468a4 --- /dev/null +++ b/test/apps/slice_selection/shared_solution_nssi_response.json @@ -0,0 +1,15 @@ +{ + "requestId": "r450f1ee-6c54-4b01-90e6-d701748f0851", + "requestStatus": "completed", + "solutions": [ + { + "UUID": "a7785f64-5717-4562-b3fc-2c963f66afa6", + "invariantUUID": "9fh85f64-5717-4562-b3fc-2c963f66afa6", + "NSSIName": "nssi_test_0211", + "NSSIId": "e1041cdc-12da-4f36-b84e-68c380e9cd47" + + } + ], + "statusMessage": "", + "transactionId": "t670f1ee-6c54-4b01-90e6-d701748f0851" +} diff --git a/test/apps/slice_selection/slice_policies.txt b/test/apps/slice_selection/slice_policies.txt new file mode 100644 index 0000000..7eb55de --- /dev/null +++ b/test/apps/slice_selection/slice_policies.txt @@ -0,0 +1,5 @@ +query_policy_nsi.json +threshold_policy_nsi.json +vnf_policy_nsi_shared_case.json +opt_policy_nsi_reuse.json + diff --git a/test/apps/slice_selection/subnet_policies.txt b/test/apps/slice_selection/subnet_policies.txt new file mode 100644 index 0000000..649672d --- /dev/null +++ b/test/apps/slice_selection/subnet_policies.txt @@ -0,0 +1,5 @@ +query_policy_nsi.json +threshold_policy_nsi.json +vnf_policy_nssi_shared.json +opt_policy_nssi.json + diff --git a/test/apps/slice_selection/test_remote_opt_processor.py b/test/apps/slice_selection/test_remote_opt_processor.py new file mode 100644 index 0000000..7c2d191 --- /dev/null +++ b/test/apps/slice_selection/test_remote_opt_processor.py @@ -0,0 +1,165 @@ +# -------------------------------------------------------------------------
+# Copyright (C) 2020 Wipro Limited.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# -------------------------------------------------------------------------
+#
+
+import json
+import unittest
+from requests import RequestException, Response
+
+from apps.slice_selection.optimizers.conductor.remote_opt_processor import SliceSelectionOptimizer
+from osdf.adapters.local_data import local_policies
+from osdf.utils.interfaces import json_from_file, yaml_from_file
+from osdf.utils.programming_utils import DotDict
+import osdf.config.loader as config_loader
+from mock import patch, MagicMock
+import json
+from osdf.logging.osdf_logging import error_log, debug_log
+from osdf.adapters.policy.interface import get_policies
+
+
+class TestRemoteOptProcessor(unittest.TestCase):
+ def setUp(self):
+ self.config_spec = {
+ "deployment": "config/osdf_config.yaml",
+ "core": "config/common_config.yaml"
+ }
+ slice_spec = "config/slicing_config.yaml"
+ self.slice_config = config_loader.load_config_file(slice_spec)
+ self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec))
+ self.patcher_RestClient = patch(
+ 'osdf.utils.interfaces.RestClient.request', return_value=MagicMock())
+ self.mock_rc = self.patcher_RestClient.start()
+
+ def tearDown(self):
+ patch.stopall()
+
+ def test_process_nsi_selection_opt(self):
+ main_dir = ""
+ request_file = main_dir + 'test/apps/slice_selection/nsi_selection_request.json'
+ not_shared_request_file = main_dir + 'test/apps/slice_selection/not_shared_nsi_request.json'
+ #response files
+ new_solution_response_file = main_dir + 'test/apps/slice_selection/new_solution_nsi_response.json'
+ shared_solution_response_file = main_dir + 'test/apps/slice_selection/shared_solution_nsi_response.json'
+ no_solution_response_file = main_dir + 'test/apps/slice_selection/no_recomm_nsi_response.json'
+ error_response_file = main_dir + 'test/apps/slice_selection/nsi_error_response.json'
+
+ request_json = json_from_file(request_file)
+ new_solution_response_json = json_from_file(new_solution_response_file)
+ shared_solution_response_json = json_from_file(shared_solution_response_file)
+ no_solution_response_json = json_from_file(no_solution_response_file)
+ error_response_json = json_from_file(error_response_file)
+
+ policies_path = main_dir + 'test/policy-local-files/slice-selection-files'
+ slice_policies_file = main_dir + 'test/apps/slice_selection/slice_policies.txt'
+
+ valid_policies_files = local_policies.get_policy_names_from_file(slice_policies_file)
+ policies = [json_from_file(policies_path + '/' + name) for name in valid_policies_files]
+ self.patcher_get_policies = patch('osdf.adapters.policy.interface.remote_api',
+ return_value=policies)
+ self.Mock_get_policies = self.patcher_get_policies.start()
+
+ # new solution
+ new_solution_conductor_response_file = 'test/apps/slice_selection/new_solution_conductor_response.json'
+ new_solution_conductor_response = json_from_file(new_solution_conductor_response_file)
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ return_value=new_solution_conductor_response)
+ self.Mock_req = self.patcher_req.start()
+ slice_select_opt = SliceSelectionOptimizer(self.osdf_config, self.slice_config, request_json, 'NSI')
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=new_solution_response_json, noresponse=True)
+ self.patcher_req.stop()
+
+ # shared solution
+ request_json['preferReuse'] = True
+ shared_solution_conductor_response_file = 'test/apps/slice_selection/shared_solution_conductor_response.json'
+ shared_solution_conductor_response = json_from_file(shared_solution_conductor_response_file)
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ return_value=shared_solution_conductor_response)
+ self.Mock_req = self.patcher_req.start()
+ slice_select_opt = SliceSelectionOptimizer(self.osdf_config, self.slice_config, request_json, 'NSI')
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=shared_solution_response_json, noresponse=True)
+ self.patcher_req.stop()
+
+ # no recommendation
+ no_solution_conductor_response_file = 'test/apps/slice_selection/no_rec.json'
+ no_solution_conductor_response = json_from_file(no_solution_conductor_response_file)
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ return_value=no_solution_conductor_response)
+ self.Mock_req = self.patcher_req.start()
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=no_solution_response_json, noresponse=True)
+ self.patcher_req.stop()
+
+ # Exception
+ conductor_error_response_file = 'test/apps/slice_selection/conductor_error_response.json'
+ conductor_error_response = json_from_file(conductor_error_response_file)
+
+ response = Response()
+ response._content = json.dumps(conductor_error_response).encode()
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ side_effect=RequestException(response=response))
+ self.Mock_req = self.patcher_req.start()
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=error_response_json, noresponse=True)
+ self.patcher_req.stop()
+
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ side_effect=Exception("Some error message"))
+ self.Mock_req = self.patcher_req.start()
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=error_response_json, noresponse=True)
+ self.patcher_req.stop()
+
+ def test_process_nssi_selection_opt(self):
+ main_dir = ""
+ request_file = main_dir + 'test/apps/slice_selection/nssi_selection_request.json'
+ # response files
+ shared_solution_response_file = main_dir + 'test/apps/slice_selection/shared_solution_nssi_response.json'
+ error_response_file = main_dir + 'test/apps/slice_selection/nssi_error_response.json'
+
+ request_json = json_from_file(request_file)
+ shared_solution_response_json = json_from_file(shared_solution_response_file)
+ error_response_json = json_from_file(error_response_file)
+
+ policies_path = main_dir + 'test/policy-local-files/slice-selection-files'
+ slice_policies_file = main_dir + 'test/apps/slice_selection/subnet_policies.txt'
+
+ valid_policies_files = local_policies.get_policy_names_from_file(slice_policies_file)
+ policies = [json_from_file(policies_path + '/' + name) for name in valid_policies_files]
+ self.patcher_get_policies = patch('osdf.adapters.policy.interface.remote_api',
+ return_value=policies)
+ self.Mock_get_policies = self.patcher_get_policies.start()
+
+ shared_solution_conductor_response_file = 'test/apps/slice_selection/nssi_conductor_response.json'
+ shared_solution_conductor_response = json_from_file(shared_solution_conductor_response_file)
+ self.patcher_req = patch('osdf.adapters.conductor.conductor.request',
+ return_value=shared_solution_conductor_response)
+ self.Mock_req = self.patcher_req.start()
+ slice_select_opt = SliceSelectionOptimizer(self.osdf_config, self.slice_config, request_json, 'NSSI')
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=shared_solution_response_json, noresponse=True)
+ self.patcher_req.stop()
+
+ request_json['sliceProfile']['resourceSharingLevel'] = "not-shared"
+ slice_select_opt = SliceSelectionOptimizer(self.osdf_config, self.slice_config, request_json, 'NSSI')
+ slice_select_opt.process_slice_selection_opt()
+ self.mock_rc.assert_called_with(json=error_response_json, noresponse=True)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/test/conductor/test_conductor_calls.py b/test/conductor/test_conductor_calls.py index 1a96da7..8b4411d 100644 --- a/test/conductor/test_conductor_calls.py +++ b/test/conductor/test_conductor_calls.py @@ -1,5 +1,6 @@ # ------------------------------------------------------------------------- # Copyright (c) 2018 AT&T Intellectual Property +# Copyright (C) 2020 Wipro Limited. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +18,7 @@ # import unittest -from osdf.optimizers.placementopt.conductor import conductor +from osdf.adapters.conductor import conductor import osdf.config.loader as config_loader from osdf.utils.interfaces import json_from_file from osdf.utils.programming_utils import DotDict @@ -34,6 +35,10 @@ class TestConductorCalls(unittest.TestCase): self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec)) self.lp = self.osdf_config.core.get('osdf_temp', {}).get('local_policies', {} ).get('placement_policy_files_vcpe') + self.template_fields = { + 'location_enabled': True, + 'version': '2017-10-10' + } def tearDown(self): pass @@ -41,7 +46,22 @@ class TestConductorCalls(unittest.TestCase): def test_request(self): req_json = json_from_file("./test/placement-tests/request.json") policies = pol.get_local_policies("test/policy-local-files/", self.lp) - conductor.request(req_json, self.osdf_config, policies) + req_info = req_json['requestInfo'] + demands = req_json['placementInfo']['placementDemands'] + request_parameters = req_json['placementInfo']['requestParameters'] + service_info = req_json['serviceInfo'] + conductor.request(req_info, demands, request_parameters, service_info, self.template_fields, + self.osdf_config, policies) + + def test_request_vfmod(self): + req_json = json_from_file("./test/placement-tests/request_vfmod.json") + policies = pol.get_local_policies("test/policy-local-files/", self.lp) + req_info = req_json['requestInfo'] + demands = req_json['placementInfo']['placementDemands'] + request_parameters = req_json['placementInfo']['requestParameters'] + service_info = req_json['serviceInfo'] + conductor.request(req_info, demands, request_parameters, service_info, self.template_fields, + self.osdf_config, policies) if __name__ == "__main__": diff --git a/test/conductor/test_conductor_translation.py b/test/conductor/test_conductor_translation.py index 0c7da94..2a600e4 100644 --- a/test/conductor/test_conductor_translation.py +++ b/test/conductor/test_conductor_translation.py @@ -1,5 +1,6 @@ # ------------------------------------------------------------------------- # Copyright (c) 2017-2018 AT&T Intellectual Property +# Copyright (C) 2020 Wipro Limited. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,40 +16,71 @@ # # ------------------------------------------------------------------------- # -import mock import unittest -from flask import Response -from mock import patch from osdf.adapters.local_data import local_policies -from osdf.optimizers.placementopt.conductor import translation as tr -from osdf.utils.interfaces import json_from_file, yaml_from_file +from osdf.adapters.conductor import translation as tr +from osdf.utils.interfaces import json_from_file class TestConductorTranslation(unittest.TestCase): def setUp(self): - main_dir = "" - conductor_api_template = main_dir + "osdf/templates/conductor_interface.json" - parameter_data_file = main_dir + "test/placement-tests/request.json" - policy_data_path = main_dir + "test/policy-local-files/" - local_config_file = main_dir + "config/common_config.yaml" + self.main_dir = "" + self.conductor_api_template = self.main_dir + "osdf/templates/conductor_interface.json" + self.local_config_file = self.main_dir + "config/common_config.yaml" + policy_data_path = self.main_dir + "test/policy-local-files" valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt' valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file) + parameter_data_file = self.main_dir + "test/placement-tests/request.json" self.request_json = json_from_file(parameter_data_file) + parameter_data_file = self.main_dir + "test/placement-tests/request_vfmod.json" + self.request_vfmod_json = json_from_file(parameter_data_file) self.policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files] + self.optimization_policies = [json_from_file(policy_data_path + '/' + + "slice-selection-files/opt_policy_nsi_reuse.json")] + def tearDown(self): pass def test_gen_demands(self): # need to run this only on vnf policies - vnf_policies = [x for x in self.policies if x["content"]["policyType"] == "vnfPolicy"] - res = tr.gen_demands(self.request_json, vnf_policies) + vnf_policies = [x for x in self.policies if x[list(x.keys())[0]]["type"] + == "onap.policies.optimization.VnfPolicy"] + res = tr.gen_demands(self.request_json['placementInfo']['placementDemands'], vnf_policies) + + assert res is not None + + def test_gen_vfmod_demands(self): + # need to run this only on vnf policies + vnf_policies = [x for x in self.policies if x[list(x.keys())[0]]["type"] + == "onap.policies.optimization.VnfPolicy"] + res = tr.gen_demands(self.request_vfmod_json['placementInfo']['placementDemands'], vnf_policies) assert res is not None + def test_gen_optimization_policy(self): + expected = [{ + "goal": "minimize", + "operation_function": { + "operator": "sum", + "operands": [ + { + "function": "attribute", + "params": { + "attribute": "creation_cost", + "demand": "embb-nst" + } + } + ] + } + }] + self.assertEqual(expected, + tr.gen_optimization_policy(self.request_vfmod_json['placementInfo']['placementDemands'], + self.optimization_policies)) + if __name__ == "__main__": unittest.main() diff --git a/test/config/common_config.yaml b/test/config/common_config.yaml index a3ef82e..560d707 100644 --- a/test/config/common_config.yaml +++ b/test/config/common_config.yaml @@ -61,4 +61,14 @@ policy_info: - get_param: subscriber_role default: # if no explicit service related information is needed policy_fetch: by_name - policy_scope: none
\ No newline at end of file + policy_scope: none + +PCI: + ML: + average_ho_threshold: 10000 + latest_ho_threshold: 500 + DES: + service_id: ho_metric + filter: + interval: 10 + ml_enabled: false diff --git a/test/config/log.yml b/test/config/log.yml new file mode 100644 index 0000000..ad0de21 --- /dev/null +++ b/test/config/log.yml @@ -0,0 +1,100 @@ +version: 1 +disable_existing_loggers: True + +loggers: + error: + handlers: [error_handler, console_handler] + level: "WARN" + propagate: True + debug: + handlers: [debug_handler, console_handler] + level: "DEBUG" + propagate: True + metrics: + handlers: [metrics_handler, console_handler] + level: "INFO" + propagate: True + audit: + handlers: [audit_handler, console_handler] + level: "INFO" + propagate: True +handlers: + debug_handler: + level: "DEBUG" + class: "logging.handlers.TimedRotatingFileHandler" + filename: "logs/debug.log" + formatter: "debugFormat" + when: midnight + interval: 1 + utc: True + delay: False + backupCount: 10 + error_handler: + level: "WARN" + class: "logging.handlers.TimedRotatingFileHandler" + filename: "logs/error.log" + formatter: "errorFormat" + when: midnight + interval: 1 + utc: True + delay: False + backupCount: 10 + metrics_handler: + level: "INFO" + class: "logging.handlers.TimedRotatingFileHandler" + filename: "logs/metrics.log" + formatter: "metricsFormat" + when: midnight + interval: 1 + utc: True + delay: False + backupCount: 10 + audit_handler: + level: "INFO" + class: "logging.handlers.TimedRotatingFileHandler" + filename: "logs/audit.log" + formatter: "auditFormat" + when: midnight + interval: 1 + utc: True + delay: False + backupCount: 10 + console_handler: + level: "DEBUG" + class: "logging.StreamHandler" + formatter: "metricsFormat" + +formatters: + standard: + format: "%(asctime)s|||||%(name)s||%(thread)||%(funcName)s||%(levelname)s||%(message)s" + debugFormat: + format: "%(mdc)s" + datefmt: "%Y-%m-%dT%H:%M:%S" + mdcfmt: "%(asctime)s.%(msecs)03d+00:00|{requestID}|%(threadName)s|{server}|%(levelname)s|%(message)s" + (): osdf.logging.oof_mdc_formatter.OOFMDCFormatter + errorFormat: + format: "%(mdc)s" + datefmt: "%Y-%m-%dT%H:%M:%S" + mdcfmt: "%(asctime)s.%(msecs)03d+00:00|{requestID}|%(threadName)s|{serviceName}|{partnerName}\ + |{targetEntity}|{targetServiceName}|%(levelname)s|{errorCode}|{errorDescription}|%(message)s" + (): osdf.logging.oof_mdc_formatter.OOFMDCFormatter + auditFormat: + format: "%(mdc)s" + datefmt: "%Y-%m-%dT%H:%M:%S" + mdcfmt: "{entryTimestamp}+00:00|%(asctime)s.%(msecs)03d+00:00|{requestID}|{serviceInstanceID}\ + |%(threadName)s|{server}|{serviceName}|{partnerName}|{statusCode}|{responseCode}|{responseDescription}\ + |{instanceUUID}|%(levelname)s|{severity}|{serverIPAddress}|{timer}|{server}|{IPAddress}||{unused}\ + |{processKey}|{customField1}|{customField2}|{customField3}|{customField4}|%(message)s" + (): osdf.logging.oof_mdc_formatter.OOFMDCFormatter + metricsFormat: + format: "%(mdc)s" + datefmt: "%Y-%m-%dT%H:%M:%S" + mdcfmt: "{entryTimestamp}+00:00|%(asctime)s.%(msecs)03d+00:00|{requestID}|{serviceInstanceID}\ + |%(threadName)s|{server}|{serviceName}|{partnerName}|{targetEntity}|{targetServiceName}|{statusCode}|{responseCode}|{responseDescription}\ + |{instanceUUID}|%(levelname)s|{severity}|{serverIPAddress}|{timer}|{server}|{IPAddress}||{unused}\ + |{processKey}|{TargetVirtualEntity}|{customField1}|{customField2}|{customField3}|{customField4}|%(message)s" + (): osdf.logging.oof_mdc_formatter.OOFMDCFormatter + mdcFormat: + format: "%(asctime)s.%(msecs)03d+00:00|||||%(name)s||%(thread)s||%(funcName)s||%(levelname)s||%(message)s||||%(mdc)s" + mdcfmt: "{requestID} {invocationID} {serviceName} {serverIPAddress}" + (): osdf.logging.oof_mdc_formatter.OOFMDCFormatter diff --git a/test/config/opteng_config.yaml b/test/config/opteng_config.yaml new file mode 100755 index 0000000..4a7e57d --- /dev/null +++ b/test/config/opteng_config.yaml @@ -0,0 +1,25 @@ +# Policy Platform -- requires Authorization +policyPlatformUrl: https://policy-xacml-pdp:6969/policy/pdpx/decision/v1 # Policy Dev platform URL + +# AAF Authentication config +is_aaf_enabled: False +aaf_cache_expiry_mins: 5 +aaf_url: https://aaftest.simpledemo.onap.org:8095 +aaf_user_roles: + - '/optmodel:org.onap.oof.access|*|read ALL' + - '/optengine:org.onap.oof.access|*|read ALL' + +# Secret Management Service from AAF +aaf_sms_url: https://aaf-sms.onap:10443 +aaf_sms_timeout: 30 +secret_domain: osdf +aaf_ca_certs: ssl_certs/aaf_root_ca.cer + +osdfDatabaseHost: localhost +osdfDatabaseSchema: osdf +osdfDatabaseUsername: osdf +osdfDatabasePassword: osdf +osdfDatabasePort: 3306 + +#key +appkey: os35@rrtky400fdntc#001t5
\ No newline at end of file diff --git a/test/config/osdf_config.yaml b/test/config/osdf_config.yaml index 8cff1d5..05d7c6a 100755 --- a/test/config/osdf_config.yaml +++ b/test/config/osdf_config.yaml @@ -48,10 +48,11 @@ osdfPlacementUsername: "test" osdfPlacementPassword: "testpwd" is_aaf_enabled: False -aaf_cache_expiry_hrs: 3 +aaf_cache_expiry_mins: 5 aaf_url: https://aaftest.simpledemo.onap.org:8095 aaf_user_roles: - - /api/oof/v1/placement:org.onap.osdf.access|*|read ALL + - '/placement:org.onap.oof.access|*|read ALL' + - '/pci:org.onap.oof.access|*|read ALL' # Secret Management Service from AAF aaf_sms_url: https://aaf-sms.onap:10443 @@ -63,6 +64,35 @@ aaf_ca_certs: ssl_certs/aaf_root_ca.cer pciHMSUsername: "" # pcihandler username for call back. pciHMSPassword: "" # pcihandler password for call back. +configClientType: configdb + +# config db api +configDbUrl: http://127.0.0.1:5000/simulated/configdb +configDbUserName: osdf +configDbPassword: passwd +configDbGetCellListUrl: 'getCellList' +configDbGetNbrListUrl: 'getNbrList' + # Credentials for the OOF PCI Opt service osdfPCIOptUsername: PCI-OSDF-USER osdfPCIOptPassword: PCI-OSDF-PASSWD + +aaiUrl: "https://aai.url:30233" +aaiServiceInstanceUrl : "/aai/v20/nodes/service-instances/service-instance/" + +#DES api +desUrl: http://des.url:9000 +desApiPath: /datalake/v1/exposure/ +desHeaders: + Accept: application/json + Content-Type: application/json +desUsername: +desPassword: + +#consulconfig +consulHost: '127.0.0.1' +consulPort: 8500 +consulScheme: 'http' +consulVerify: True +consulCert: None +activateConsulConfig: False
\ No newline at end of file diff --git a/test/configdb/test_configdb_calls.py b/test/configdb/test_configdb_calls.py index eb799e7..3393991 100644 --- a/test/configdb/test_configdb_calls.py +++ b/test/configdb/test_configdb_calls.py @@ -16,7 +16,7 @@ # ------------------------------------------------------------------------- # -from osdf.optimizers.pciopt.configdb import request +from apps.pci.optimizers.config_request import request import osdf.config.loader as config_loader from osdf.utils.interfaces import json_from_file from osdf.utils.programming_utils import DotDict diff --git a/test/functest/scripts/start-simulators.sh b/test/functest/scripts/start-simulators.sh index a3f3db1..66507d4 100755 --- a/test/functest/scripts/start-simulators.sh +++ b/test/functest/scripts/start-simulators.sh @@ -20,7 +20,12 @@ # This script is in osdf/test/functest/scripts/ -SCRIPTDIR=$(dirname $(readlink -f $0)) +if [[ `uname` == "Darwin" ]] +then + SCRIPTDIR=$(dirname $(greadlink -f $0)) +else + SCRIPTDIR=$(dirname $(readlink -f $0)) +fi FUNC_TEST_DIR=$(dirname $SCRIPTDIR) TEST_DIR=$(dirname $FUNC_TEST_DIR) OSDF_DIR=$(dirname $TEST_DIR) diff --git a/test/functest/scripts/stop-simulators.sh b/test/functest/scripts/stop-simulators.sh index c9dd126..e80a080 100755 --- a/test/functest/scripts/stop-simulators.sh +++ b/test/functest/scripts/stop-simulators.sh @@ -23,7 +23,12 @@ # We don't need all the directory names here and the "cd", but it may be needed later on # Also, it will be a guard against some bad config where the directory doesn't exist -SCRIPTDIR=$(dirname $(readlink -f $0)) +if [[ `uname` == "Darwin" ]] +then + SCRIPTDIR=$(dirname $(greadlink -f $0)) +else + SCRIPTDIR=$(dirname $(readlink -f $0)) +fi FUNC_TEST_DIR=$(dirname $SCRIPTDIR) TEST_DIR=$(dirname $FUNC_TEST_DIR) OSDF_DIR=$(dirname $TEST_DIR) diff --git a/test/functest/simulators/Dockerfile b/test/functest/simulators/Dockerfile index 7f6b49f..233503c 100644 --- a/test/functest/simulators/Dockerfile +++ b/test/functest/simulators/Dockerfile @@ -17,18 +17,22 @@ # ------------------------------------------------------------------------- # -FROM ubuntu:16.04 +FROM ubuntu:20.04 + +ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -y \ - && apt-get install -y vim unzip wget libmpfr-dev \ - && apt-get install -y git libqt5printsupport5 build-essential \ - && apt-get install -y python3 python3-setuptools python3-dev \ - && easy_install3 pip \ - && pip install --upgrade virtualenv pip wheel + && apt-get install -y --no-install-recommends software-properties-common \ + curl ca-certificates vim binutils binfmt-support build-essential \ + python3 python3-setuptools python3-dev \ + && ln -s /usr/bin/python3.8 /usr/bin/python \ + && curl -s https://bootstrap.pypa.io/get-pip.py | python \ + && python -m pip --no-cache-dir install --upgrade pip wheel setuptools \ + && rm -rf /var/lib/apt/lists/* -RUN ln -s /usr/bin/python3.5 /usr/bin/python -ADD requirements.txt /requirements.txt +COPY requirements.txt /requirements.txt RUN pip install -r requirements.txt -ADD sim /sim +COPY sim /sim +COPY start_sim.sh /start_sim.sh -CMD cd /sim && python oof_dependencies_simulators.py > simulator-logs 2>&1
\ No newline at end of file +CMD ["/start_sim.sh"]
\ No newline at end of file diff --git a/test/functest/simulators/aai/response-payloads/nsi_instance.json b/test/functest/simulators/aai/response-payloads/nsi_instance.json new file mode 100644 index 0000000..b09d2e4 --- /dev/null +++ b/test/functest/simulators/aai/response-payloads/nsi_instance.json @@ -0,0 +1,13 @@ +{ + "service-instance-id": "9629e36c-a3d9-4aed-8368-f72b8be1cd34", + "service-instance-name": "nsi_test_0211", + "service-type": "embb", + "service-role": "nsi", + "environment-context": "cn", + "model-invariant-id": "21d57d4b-52ad-4d3c-a798-248b5bb9124a", + "model-version-id": "bfba363e-e39c-4bd9-a9d5-1371c28f4d22", + "resource-version": "1581418601616", + "orchestration-status": "active", + "relationship-list": { + "relationship": [ +]}} diff --git a/test/functest/simulators/aai/response-payloads/nsi_instance_with_args.json b/test/functest/simulators/aai/response-payloads/nsi_instance_with_args.json new file mode 100644 index 0000000..19e5ac1 --- /dev/null +++ b/test/functest/simulators/aai/response-payloads/nsi_instance_with_args.json @@ -0,0 +1,45 @@ +{ + "service-instance-id": "9629e36c-a3d9-4aed-8368-f72b8be1cd34", + "service-instance-name": "nsi_test_0211", + "service-type": "embb", + "service-role": "nsi", + "environment-context": "cn", + "model-invariant-id": "21d57d4b-52ad-4d3c-a798-248b5bb9124a", + "model-version-id": "bfba363e-e39c-4bd9-a9d5-1371c28f4d22", + "resource-version": "1581418601616", + "orchestration-status": "active", + "relationship-list": { + "relationship": [ + { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v23/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/d88b6ce6-19be-439d-8553-4f9d6cce0494/allotted-resources/allotted-resource/07138106-f535-413b-b002-40ba24f95937", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "cdad9f49-4201-4e3a-aac1-b0f27902c299" + }, + { + "relationship-key": "allotted-resource.id", + "relationship-value": "07138106-f535-413b-b002-40ba24f95937" + } + ], + "related-to-property": [ + { + "property-key": "allotted-resource.description" + }, + { + "property-key": "allotted-resource.allotted-resource-name", + "property-value": "Allotted_coe" + } + ] + } +]}} diff --git a/test/functest/simulators/build_sim_image.sh b/test/functest/simulators/build_sim_image.sh index c035e9a..561db19 100755 --- a/test/functest/simulators/build_sim_image.sh +++ b/test/functest/simulators/build_sim_image.sh @@ -18,13 +18,23 @@ # ------------------------------------------------------------------------- # -SCRIPTDIR=$(dirname $(readlink -f $0)) +if [[ `uname` == "Darwin" ]] +then + SCRIPTDIR=$(dirname $(greadlink -f $0)) +else + SCRIPTDIR=$(dirname $(readlink -f $0)) +fi + FUNC_TEST_DIR=$(dirname $SCRIPTDIR) TEST_DIR=$(dirname $FUNC_TEST_DIR) SIMULATORS_DIR=$FUNC_TEST_DIR/simulators OSDF_DIR=$(dirname $TEST_DIR) DOCKER_DIR=$SIMULATORS_DIR/tmp_docker +echo "Before Docker Build" +cat $OSDF_DIR/requirements-sim.txt +echo $OSDF_DIR + mkdir -p $DOCKER_DIR/sim/osdf/policy/response-payloads/pdp-has-vcpe-good cp $SIMULATORS_DIR/Dockerfile $DOCKER_DIR/. @@ -32,13 +42,17 @@ cp $SIMULATORS_DIR/Dockerfile $DOCKER_DIR/. cp -r $OSDF_DIR/osdf $DOCKER_DIR/sim mkdir -p $DOCKER_DIR/sim/config/ cp $SIMULATORS_DIR/simulated-config/*.yaml $DOCKER_DIR/sim/config/ +cp $SIMULATORS_DIR/simulated-config/*.yml $DOCKER_DIR/sim/config/ cp $SIMULATORS_DIR/simulated-config/*.config $DOCKER_DIR/sim/config/ cp -r $SIMULATORS_DIR/configdb $DOCKER_DIR/sim cp -r $SIMULATORS_DIR/has-api $DOCKER_DIR/sim cp -r $SIMULATORS_DIR/policy $DOCKER_DIR/sim +cp -r $SIMULATORS_DIR/aai $DOCKER_DIR/sim cp $TEST_DIR/policy-local-files/*.json $DOCKER_DIR/sim/policy/response-payloads/pdp-has-vcpe-good +cp $TEST_DIR/placement-tests/policy_response.json $DOCKER_DIR/sim/policy/response-payloads/ cp $SIMULATORS_DIR/oof_dependencies_simulators.py $DOCKER_DIR/sim/oof_dependencies_simulators.py -cp $OSDF_DIR/requirements.txt $DOCKER_DIR +cp $OSDF_DIR/requirements-sim.txt $DOCKER_DIR/requirements.txt +cp -r $SIMULATORS_DIR/start_sim.sh $DOCKER_DIR/ cd $DOCKER_DIR diff --git a/test/functest/simulators/configdb/response-payloads/getCellList-1000.json b/test/functest/simulators/configdb/response-payloads/getCellList-netw1000.json index df23f6e..df23f6e 100644 --- a/test/functest/simulators/configdb/response-payloads/getCellList-1000.json +++ b/test/functest/simulators/configdb/response-payloads/getCellList-netw1000.json diff --git a/test/functest/simulators/configdb/response-payloads/getCellList-netw2000.json b/test/functest/simulators/configdb/response-payloads/getCellList-netw2000.json new file mode 100644 index 0000000..77cf7db --- /dev/null +++ b/test/functest/simulators/configdb/response-payloads/getCellList-netw2000.json @@ -0,0 +1 @@ +["cell20","cell21","cell22","cell23","cell24"]
\ No newline at end of file diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell0.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell0.json index e0986d8..ff291fb 100644 --- a/test/functest/simulators/configdb/response-payloads/getNbrList-cell0.json +++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell0.json @@ -1,10 +1,15 @@ -[ - { - "cellId": "cell1", - "pciValue": 1 - }, - { - "cellId": "cell2", - "pciValue": 2 - } -]
\ No newline at end of file +{ + "cellId": "cell0", + "nbrList": [ + { + "targetCellId": "cell1", + "pciValue": 1, + "ho": true + }, + { + "targetCellId": "cell2", + "pciValue": 2, + "ho": true + } + ] +}
\ No newline at end of file diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell1.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell1.json index d6ed353..3c487e8 100644 --- a/test/functest/simulators/configdb/response-payloads/getNbrList-cell1.json +++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell1.json @@ -1,10 +1,15 @@ -[ - { - "cellId": "cell0", - "pciValue": 0 - }, - { - "cellId": "cell2", - "pciValue": 2 - } -]
\ No newline at end of file +{ + "cellId": "cell1", + "nbrList": [ + { + "targetCellId": "cell0", + "pciValue": 0, + "ho": true + }, + { + "targetCellId": "cell2", + "pciValue": 2, + "ho": true + } + ] +}
\ No newline at end of file diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell2.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell2.json index 1ea80be..20a8c98 100644 --- a/test/functest/simulators/configdb/response-payloads/getNbrList-cell2.json +++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell2.json @@ -1,10 +1,15 @@ -[ - { - "cellId": "cell0", - "pciValue": 0 - }, - { - "cellId": "cell1", - "pciValue": 1 - } -]
\ No newline at end of file +{ + "cellId": "cell2", + "nbrList": [ + { + "targetCellId": "cell0", + "pciValue": 0, + "ho": true + }, + { + "targetCellId": "cell1", + "pciValue": 1, + "ho": true + } + ] +}
\ No newline at end of file diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell20.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell20.json new file mode 100644 index 0000000..d4e754f --- /dev/null +++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell20.json @@ -0,0 +1,20 @@ +{ + "cellId": "cell20", + "nbrList": [ + { + "targetCellId": "cell21", + "pciValue": 0, + "ho": true + }, + { + "targetCellId": "cell22", + "pciValue": 1, + "ho": true + }, + { + "targetCellId": "cell23", + "pciValue": 2, + "ho": true + } + ] +}
\ No newline at end of file diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell21.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell21.json new file mode 100644 index 0000000..a1d6f55 --- /dev/null +++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell21.json @@ -0,0 +1,10 @@ +{ + "cellId": "cell21", + "nbrList": [ + { + "targetCellId": "cell20", + "pciValue": 0, + "ho": true + } + ] +}
\ No newline at end of file diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell22.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell22.json new file mode 100644 index 0000000..9c16aec --- /dev/null +++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell22.json @@ -0,0 +1,10 @@ +{ + "cellId": "cell22", + "nbrList": [ + { + "targetCellId": "cell20", + "pciValue": 0, + "ho": true + } + ] +}
\ No newline at end of file diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell23.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell23.json new file mode 100644 index 0000000..ac3bf6f --- /dev/null +++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell23.json @@ -0,0 +1,10 @@ +{ + "cellId": "cell23", + "nbrList": [ + { + "targetCellId": "cell24", + "pciValue": 0, + "ho": true + } + ] +}
\ No newline at end of file diff --git a/test/functest/simulators/configdb/response-payloads/getNbrList-cell24.json b/test/functest/simulators/configdb/response-payloads/getNbrList-cell24.json new file mode 100644 index 0000000..f34128e --- /dev/null +++ b/test/functest/simulators/configdb/response-payloads/getNbrList-cell24.json @@ -0,0 +1,10 @@ +{ + "cellId": "cell24", + "nbrList": [ + { + "targetCellId": "cell23", + "pciValue": 2, + "ho": true + } + ] +}
\ No newline at end of file diff --git a/test/functest/simulators/oof_dependencies_simulators.py b/test/functest/simulators/oof_dependencies_simulators.py index 2995861..d7b1f04 100755..100644 --- a/test/functest/simulators/oof_dependencies_simulators.py +++ b/test/functest/simulators/oof_dependencies_simulators.py @@ -22,6 +22,7 @@ Simulators for dependencies of OSDF (e.g. HAS-API, Policy, SO-callback, etc.) import glob import json import os + from flask import Flask, jsonify, request from osdf.utils.interfaces import json_from_file @@ -93,6 +94,14 @@ def get_policies(sub_component): return jsonify(list_json) +@app.route("/simulated/policy/pdpx/decision/v1", methods=["POST"]) +def get_pdx_policies(): + """ + get the pdpx policy + """ + return jsonify(json_from_file("policy/response-payloads/policy_response.json")) + + @app.route("/simulated/configdb/getCellList/<network_id>/<ts>", methods=["GET"]) def get_cell_list(network_id, ts): data, status = get_payload_for_simulated_component('configdb', @@ -109,6 +118,40 @@ def get_nbr_list(cell_id, ts): return jsonify(data) return jsonify(data), 503 +@app.route("/simulated/aai/v23/nodes/service-instances/service-instance/<service_id>", methods=["GET"]) +def get_aai_instances(service_id): + data, status = get_payload_for_simulated_component('aai', 'nsi_instance.json') + if not status: + return jsonify(data) + return jsonify(data), 503 + +@app.route("/simulated/aai/v23/dsl", methods=["PUT"]) +def dsl_query(): + + nssi_query = {"dsl": "service-instance*('service-instance-id','9629e36c-a3d9-4aed-8368-f72b8be1cd34')('workload-context', 'CN') > " + "service-instance*('service-role','nsi')"} + + nssi_with_nsi_query = {"dsl": "service-instance*('service-instance-id','9629e36c-a3d9-4aed-8368-f72b8be1cd34')('workload-context', 'CN') > " + "service-instance*('service-role','nsi')('service-instance-id'," + "'660ca85c-1a0f-4521-a559-65f23e794699')"} + + queries = { + "nssi_query": nssi_query, + "nssi_with_nsi": nssi_with_nsi_query + } + + count = { + "nssi_query": 1, + "nssi_with_nsi": 2 + } + + request_body = request.get_json() + service_count = 0 + for query_type, query in queries.items(): + if request_body == query: + service_count = count[query_type] + return {'results': [{'service-instance': service_count}]} + if __name__ == "__main__": app.run(debug=True, host='0.0.0.0') diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Affinity_vCPE_1.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Affinity_vCPE_1.json index 6f0ecb3..2953589 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Affinity_vCPE_1.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Affinity_vCPE_1.json @@ -1,7 +1,7 @@ { - "service": "zone", - "policyName": "OSDF_R2.Affinity_vCPE_1", - "description": "Optimization query policy for vCPE", + "service": "affinityPolicy", + "policyName": "OSDF_DUBLIN.Affinity_vCPE_1", + "description": "Zone policy for vCPE", "templateVersion": "OpenSource.version.1", "version": "test1", "priority": "3", diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Capacity_vGMuxInfra.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Capacity_vGMuxInfra.json index 2578544..010cf3f 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Capacity_vGMuxInfra.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Capacity_vGMuxInfra.json @@ -1,6 +1,6 @@ { "service": "vim_fit", - "policyName": "OSDF_R2.Capacity_vGMuxInfra", + "policyName": "OSDF_DUBLIN.Capacity_vGMuxInfra", "description": "Capacity policy for vGMuxInfra", "templateVersion": "OpenSource.version.1", "version": "test1", diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Capacity_vG_1.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Capacity_vG_1.json index c1682fa..fedcc4f 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Capacity_vG_1.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Capacity_vG_1.json @@ -1,6 +1,6 @@ { "service": "vim_fit", - "policyName": "OSDF_R2.Capacity_vG_1", + "policyName": "OSDF_DUBLIN.Capacity_vG_1", "description": "Capacity policy for vG", "templateVersion": "OpenSource.version.1", "version": "test1", diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Distance_vGMuxInfra_1.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Distance_vGMuxInfra_1.json index 61ec500..e3ba83c 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Distance_vGMuxInfra_1.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Distance_vGMuxInfra_1.json @@ -1,6 +1,6 @@ { - "service": "distance_to_location", - "policyName": "OSDF_R2.Distance_vGMuxInfra", + "service": "distancePolicy", + "policyName": "OSDF_DUBLIN.Distance_vGMuxInfra", "description": "Distance Policy for vGMuxInfra", "templateVersion": "OpenSource.version.1", "version": "test1", @@ -10,13 +10,13 @@ "guard": "False", "content": { "distanceProperties": { - "locationInfo": "customer_location", + "locationInfo": "customer_loc", "distance": { "value": "500", "operator": "<", "unit": "km" } }, "identity": "distance-vGMuxInfra", "resources": ["vGMuxInfra"], "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"], - "policyType": "distancePolicy", + "policyType": "distance_to_location", "applicableResources": "any" } } diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Distance_vG_1.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Distance_vG_1.json index 06c3ada..c498c7a 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Distance_vG_1.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Distance_vG_1.json @@ -1,6 +1,6 @@ { - "service": "distance_to_location", - "policyName": "OSDF_R2.Distance_vG_1", + "service": "distancePolicy", + "policyName": "OSDF_DUBLIN.Distance_vG_1", "description": "Distance Policy for vG", "templateVersion": "OpenSource.version.1", "version": "test1", @@ -10,13 +10,13 @@ "guard": "False", "content": { "distanceProperties": { - "locationInfo": "customer_location", + "locationInfo": "customer_loc", "distance": { "value": "1500", "operator": "<", "unit": "km" } }, "identity": "distance-vG", "resources": ["vG"], "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vG"], - "policyType": "distancePolicy", + "policyType": "distance_to_location", "applicableResources": "any" } } diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Placement_Optimization_1.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Placement_Optimization_1.json index ab3c586..9b062b0 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Placement_Optimization_1.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Placement_Optimization_1.json @@ -1,6 +1,6 @@ { - "service": "placementOptimization", - "policyName": "OSDF_R2.Placement_Optimization_1", + "service": "optimizationPolicy", + "policyName": "OSDF_DUBLIN.Placement_Optimization_1", "description": "Placement Optimization Policy for vGMuxInfra", "templateVersion": "OpenSource.version.1", "version": "test1", @@ -30,13 +30,26 @@ "parameter": "hpa_score", "weight": "200", "operator": "product" + }, + { + "resources": ["vFW"], + "customerLocationInfo": "customer_loc", + "parameter": "distance", + "weight": "100", + "operator": "product" + }, + { + "resources": ["vFW"], + "parameter": "hpa_score", + "weight": "200", + "operator": "product" } ], "operator": "sum" }, "identity": "optimization", "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"], - "policyType": "placementOptimization", + "policyType": "placement_optimization", "objective": "minimize" } } diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/QueryPolicy_vCPE.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/QueryPolicy_vCPE.json index 27f49d2..5097964 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/QueryPolicy_vCPE.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/QueryPolicy_vCPE.json @@ -1,7 +1,7 @@ { - "service": "optimizationQueryPolicy", - "policyName": "OSDF_R2.QueryPolicy_vCPE", - "description": "Optimization query policy for vCPE", + "service": "queryPolicy", + "policyName": "OSDF_DUBLIN.QueryPolicy_vCPE", + "description": "Query policy for vCPE", "templateVersion": "OpenSource.version.1", "version": "test1", "priority": "3", @@ -14,7 +14,7 @@ {"attribute":"customerLongitude", "attribute_location": "customerLongitude"} ], "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"], - "policyType": "optimizationQueryPolicy", + "policyType": "request_param_query", "serviceName": "vCPE", "identity": "vCPE_Query_Policy" } diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/QueryPolicy_vCPE_2.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/QueryPolicy_vCPE_2.json index 7f1db83..e398f39 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/QueryPolicy_vCPE_2.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/QueryPolicy_vCPE_2.json @@ -1,10 +1,10 @@ { - "service": "optimizationQueryPolicy", - "policyName": "oofBeijing.queryPolicy_vCPE", - "description": "Optimization query policy for vCPE", - "templateVersion": "0.0.1", - "version": "oofBeijing", - "priority": "5", + "service": "queryPolicy", + "policyName": "OSDF_DUBLIN.queryPolicy_vCPE", + "description": "Query policy for vCPE", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "3", "riskType": "test", "riskLevel": "2", "guard": "False", @@ -17,7 +17,8 @@ {"attribute":"customerLongitude", "attribute_location": "customerLongitude", "value": 2.2} ], "serviceName": "vCPE", - "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG", "optimizationQueryPolicy"], - "policyType": "optimizationQueryPolicy" + "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"], + "policyType": "request_param_query", + "identity": "vCPE_Query_Policy" } } diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/hpa_policy_vGMuxInfra_1.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/hpa_policy_vGMuxInfra_1.json index ce0b7e3..690f5dc 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/hpa_policy_vGMuxInfra_1.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/hpa_policy_vGMuxInfra_1.json @@ -1,6 +1,6 @@ { "service": "hpaPolicy", - "policyName": "OSDF_R2.hpa_policy_vGMuxInfra_1", + "policyName": "OSDF_DUBLIN.hpa_policy_vGMuxInfra_1", "description": "HPA policy for vGMuxInfra", "templateVersion": "OpenSource.version.1", "version": "test1", @@ -9,10 +9,10 @@ "riskLevel": "2", "guard": "False", "content": { - "resources": "vGMuxInfra", - "identity": "hpaPolicy_vGMuxInfra", + "resources": ["vGMuxInfra"], + "identity": "hpa-vGMuxInfra", "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"], - "policyType": "hpaPolicy", + "policyType": "hpa", "flavorFeatures": [ { "id": "vgmux_1", diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/hpa_policy_vG_1.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/hpa_policy_vG_1.json index 5d2499f..b29c67d 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/hpa_policy_vG_1.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/hpa_policy_vG_1.json @@ -1,6 +1,6 @@ { "service": "hpaPolicy", - "policyName": "OSDF_R2.hpa_policy_vG_1", + "policyName": "OSDF_DUBLIN.hpa_policy_vG_1", "description": "HPA policy for vG", "templateVersion": "OpenSource.version.1", "version": "test1", @@ -9,10 +9,10 @@ "riskLevel": "2", "guard": "False", "content": { - "resources": "vG", - "identity": "hpaPolicy_vG", + "resources": ["vG"], + "identity": "hpa-vG", "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vG"], - "policyType": "hpaPolicy", + "policyType": "hpa", "flavorFeatures": [ { "id": "vg_1", diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/vnfPolicy_vG.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/vnfPolicy_vG.json index d215078..b047686 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/vnfPolicy_vG.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/vnfPolicy_vG.json @@ -1,6 +1,6 @@ { "service": "vnfPolicy", - "policyName": "OSDF_R2.vnfPolicy_vG", + "policyName": "OSDF_DUBLIN.vnfPolicy_vG", "description": "vnfPolicy", "templateVersion": "OpenSource.version.1", "version": "test1", diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/vnfPolicy_vGMuxInfra.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/vnfPolicy_vGMuxInfra.json index 6849105..45d67f6 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/vnfPolicy_vGMuxInfra.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/vnfPolicy_vGMuxInfra.json @@ -1,6 +1,6 @@ { "service": "vnfPolicy", - "policyName": "OSDF_R2.vnfPolicy_vGMuxInfra", + "policyName": "OSDF_DUBLIN.vnfPolicy_vGMuxInfra", "description": "vnfPolicy", "templateVersion": "OpenSource.version.1", "version": "test1", diff --git a/test/functest/simulators/simulated-config/common_config.yaml b/test/functest/simulators/simulated-config/common_config.yaml index 1249dc0..36c639f 100644 --- a/test/functest/simulators/simulated-config/common_config.yaml +++ b/test/functest/simulators/simulated-config/common_config.yaml @@ -62,3 +62,13 @@ policy_info: default: # if no explicit service related information is needed policy_fetch: by_name policy_scope: none + +PCI: + ML: + average_ho_threshold: 10000 + latest_ho_threshold: 500 + DES: + service_id: ho_metric + filter: + interval: 10 + ml_enabled: false diff --git a/test/functest/simulators/simulated-config/log.yml b/test/functest/simulators/simulated-config/log.yml new file mode 100644 index 0000000..ad0de21 --- /dev/null +++ b/test/functest/simulators/simulated-config/log.yml @@ -0,0 +1,100 @@ +version: 1 +disable_existing_loggers: True + +loggers: + error: + handlers: [error_handler, console_handler] + level: "WARN" + propagate: True + debug: + handlers: [debug_handler, console_handler] + level: "DEBUG" + propagate: True + metrics: + handlers: [metrics_handler, console_handler] + level: "INFO" + propagate: True + audit: + handlers: [audit_handler, console_handler] + level: "INFO" + propagate: True +handlers: + debug_handler: + level: "DEBUG" + class: "logging.handlers.TimedRotatingFileHandler" + filename: "logs/debug.log" + formatter: "debugFormat" + when: midnight + interval: 1 + utc: True + delay: False + backupCount: 10 + error_handler: + level: "WARN" + class: "logging.handlers.TimedRotatingFileHandler" + filename: "logs/error.log" + formatter: "errorFormat" + when: midnight + interval: 1 + utc: True + delay: False + backupCount: 10 + metrics_handler: + level: "INFO" + class: "logging.handlers.TimedRotatingFileHandler" + filename: "logs/metrics.log" + formatter: "metricsFormat" + when: midnight + interval: 1 + utc: True + delay: False + backupCount: 10 + audit_handler: + level: "INFO" + class: "logging.handlers.TimedRotatingFileHandler" + filename: "logs/audit.log" + formatter: "auditFormat" + when: midnight + interval: 1 + utc: True + delay: False + backupCount: 10 + console_handler: + level: "DEBUG" + class: "logging.StreamHandler" + formatter: "metricsFormat" + +formatters: + standard: + format: "%(asctime)s|||||%(name)s||%(thread)||%(funcName)s||%(levelname)s||%(message)s" + debugFormat: + format: "%(mdc)s" + datefmt: "%Y-%m-%dT%H:%M:%S" + mdcfmt: "%(asctime)s.%(msecs)03d+00:00|{requestID}|%(threadName)s|{server}|%(levelname)s|%(message)s" + (): osdf.logging.oof_mdc_formatter.OOFMDCFormatter + errorFormat: + format: "%(mdc)s" + datefmt: "%Y-%m-%dT%H:%M:%S" + mdcfmt: "%(asctime)s.%(msecs)03d+00:00|{requestID}|%(threadName)s|{serviceName}|{partnerName}\ + |{targetEntity}|{targetServiceName}|%(levelname)s|{errorCode}|{errorDescription}|%(message)s" + (): osdf.logging.oof_mdc_formatter.OOFMDCFormatter + auditFormat: + format: "%(mdc)s" + datefmt: "%Y-%m-%dT%H:%M:%S" + mdcfmt: "{entryTimestamp}+00:00|%(asctime)s.%(msecs)03d+00:00|{requestID}|{serviceInstanceID}\ + |%(threadName)s|{server}|{serviceName}|{partnerName}|{statusCode}|{responseCode}|{responseDescription}\ + |{instanceUUID}|%(levelname)s|{severity}|{serverIPAddress}|{timer}|{server}|{IPAddress}||{unused}\ + |{processKey}|{customField1}|{customField2}|{customField3}|{customField4}|%(message)s" + (): osdf.logging.oof_mdc_formatter.OOFMDCFormatter + metricsFormat: + format: "%(mdc)s" + datefmt: "%Y-%m-%dT%H:%M:%S" + mdcfmt: "{entryTimestamp}+00:00|%(asctime)s.%(msecs)03d+00:00|{requestID}|{serviceInstanceID}\ + |%(threadName)s|{server}|{serviceName}|{partnerName}|{targetEntity}|{targetServiceName}|{statusCode}|{responseCode}|{responseDescription}\ + |{instanceUUID}|%(levelname)s|{severity}|{serverIPAddress}|{timer}|{server}|{IPAddress}||{unused}\ + |{processKey}|{TargetVirtualEntity}|{customField1}|{customField2}|{customField3}|{customField4}|%(message)s" + (): osdf.logging.oof_mdc_formatter.OOFMDCFormatter + mdcFormat: + format: "%(asctime)s.%(msecs)03d+00:00|||||%(name)s||%(thread)s||%(funcName)s||%(levelname)s||%(message)s||||%(mdc)s" + mdcfmt: "{requestID} {invocationID} {serviceName} {serverIPAddress}" + (): osdf.logging.oof_mdc_formatter.OOFMDCFormatter diff --git a/test/functest/simulators/simulated-config/opteng_config.yaml b/test/functest/simulators/simulated-config/opteng_config.yaml new file mode 100755 index 0000000..0dfb536 --- /dev/null +++ b/test/functest/simulators/simulated-config/opteng_config.yaml @@ -0,0 +1,25 @@ +# Policy Platform -- requires Authorization +policyPlatformUrl: https://policy-xacml-pdp:6969/policy/pdpx/decision/v1 # Policy Dev platform URL + +# AAF Authentication config +is_aaf_enabled: False +aaf_cache_expiry_mins: 5 +aaf_url: https://aaftest.simpledemo.onap.org:8095 +aaf_user_roles: + - '/optmodel:org.onap.oof.access|*|read ALL' + - '/optengine:org.onap.oof.access|*|read ALL' + +# Secret Management Service from AAF +aaf_sms_url: https://aaf-sms.onap:10443 +aaf_sms_timeout: 30 +secret_domain: osdf +aaf_ca_certs: ssl_certs/aaf_root_ca.cer + +osdfDatabaseHost: localhost +osdfDatabaseSchema: osdf +osdfDatabaseUsername: osdf +osdfDatabasePassword: osdf +osdfDatabasePort: 3306 + +#key +appkey: os35@rrtky400fdntc#001t5 diff --git a/test/functest/simulators/simulated-config/osdf_config.yaml b/test/functest/simulators/simulated-config/osdf_config.yaml index eccad14..eb02b33 100755 --- a/test/functest/simulators/simulated-config/osdf_config.yaml +++ b/test/functest/simulators/simulated-config/osdf_config.yaml @@ -60,6 +60,8 @@ aaf_sms_timeout: 30 secret_domain: osdf aaf_ca_certs: ssl_certs/aaf_root_ca.cer +configClientType: configdb + # config db api configDbUrl: http://127.0.0.1:5000/simulated/configdb configDbUserName: osdf @@ -71,3 +73,16 @@ configDbGetNbrListUrl: 'getNbrList' pciHMSUsername: "" # pcihandler username for call back. pciHMSPassword: "" # pcihandler password for call back. +aaiUrl: "https://api.url:30233" +aaiGetLinksUrl: "/aai/v16/network/logical-links" +aaiGetControllersUrl: /aai/v19/external-system/esr-thirdparty-sdnc-list +controllerQueryUrl: /aai/v19/query?format=resource +aaiGetInterDomainLinksUrl: /aai/v19/network/logical-links?link-type=inter-domain&operational-status=up + +#consulconfig +consulHost: '127.0.0.1' +consulPort: 8500 +consulScheme: 'http' +consulVerify: True +consulCert: None +activateConsulConfig: False diff --git a/test/functest/simulators/simulated-config/slicing_config.yaml b/test/functest/simulators/simulated-config/slicing_config.yaml new file mode 100644 index 0000000..179f54a --- /dev/null +++ b/test/functest/simulators/simulated-config/slicing_config.yaml @@ -0,0 +1,96 @@ +app_info: + NSI: + app_name: slice_selection + requirements_field: serviceProfile + model_info: NSTInfo + NSSI: + app_name: subnet_selection + requirements_field: sliceProfile + model_info: NSSTInfo + +attribute_mapping: + camel_to_snake: + maxBandwidth: max_bandwidth + jitter: jitter + sST: sst + latency: latency + resourceSharingLevel: resource_sharing_level + uEMobilityLevel: ue_mobility_level + maxNumberofUEs: max_number_of_ues + dLThptPerUE: dl_thpt_per_ue + uLThptPerUE: ul_thpt_per_ue + sNSSAI: s_nssai + pLMNIdList: plmn_id_list + activityFactor: activity_factor + coverageAreaTAList: coverage_area_ta_list + availability: availability + cSAvailabilityTarget: cs_availability_target + reliability: reliability + cSReliabilityMeanTime: cs_reliability_mean_time + dLThptPerSlice: dl_thpt_per_slice + expDataRateDL: exp_data_rate_dl + uLThptPerSlice: ul_thpt_per_slice + expDataRateUL: exp_data_rate_ul + maxPktSize: max_pkt_size + msgSizeByte: msg_size_byte + maxNumberofConns: max_number_of_conns + maxNumberofPDUSession: max_number_of_pdu_session + termDensity: terminal_density + survivalTime: survival_time + areaTrafficCapDL: area_traffic_cap_dl + areaTrafficCapUL: area_traffic_cap_ul + overallUserDensity: overall_user_density + transferIntervalTarget: transfer_interval_target + expDataRate: exp_data_rate + security: security + maxThroughput: max_throughput + sliceProfileId: slice_profile_id + snssaiList: s_nssai_list + domainType: domain_type + logicInterfaceId: logical_interface_id + ipAddress: ip_address + nextHopInfo: next_hop_info + perfReq: perf_req + + snake_to_camel: + max_bandwidth: maxBandwidth + jitter: jitter + sst: sST + latency: latency + resource_sharing_level: resourceSharingLevel + ue_mobility_level: uEMobilityLevel + max_number_of_ues: maxNumberofUEs + dl_thpt_per_ue: dLThptPerUE + ul_thpt_per_ue: uLThptPerUE + s_nssai: sNSSAI + plmn_id_list: pLMNIdList + activity_factor: activityFactor + coverage_area_ta_list: coverageAreaTAList + availability: availability + cs_availability_target: cSAvailabilityTarget + reliability: reliability + cs_reliability_mean_time: cSReliabilityMeanTime + dl_thpt_per_slice: dLThptPerSlice + exp_data_rate_dl: expDataRateDL + ul_thpt_per_slice: uLThptPerSlice + exp_data_rate_ul: expDataRateUL + max_pkt_size: maxPktSize + msg_size_byte: msgSizeByte + max_number_of_conns: maxNumberofConns + max_number_of_pdu_session: maxNumberofPDUSession + terminal_density: termDensity + survival_time: survivalTime + area_traffic_cap_dl: areaTrafficCapDL + area_traffic_cap_ul: areaTrafficCapUL + overall_user_density: overallUserDensity + transfer_interval_target: transferIntervalTarget + exp_data_rate: expDataRate + security: security + max_throughput: maxThroughput + slice_profile_id: sliceProfileId + s_nssai_list: snssaiList + domain_type: domainType + logical_interface_id: logicInterfaceId + ip_address: ipAddress + next_hop_info: nextHopInfo + perf_req: perfReq diff --git a/test/functest/simulators/start_sim.sh b/test/functest/simulators/start_sim.sh new file mode 100755 index 0000000..f5935da --- /dev/null +++ b/test/functest/simulators/start_sim.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +cd /sim +python oof_dependencies_simulators.py diff --git a/test/inter_domain_route_opt/bandwidth_attributes.json b/test/inter_domain_route_opt/bandwidth_attributes.json new file mode 100644 index 0000000..0de7e51 --- /dev/null +++ b/test/inter_domain_route_opt/bandwidth_attributes.json @@ -0,0 +1,176 @@ +{ + "int-1-bw":{ + "interface-name":"int1", + "bandwidth-attributes":{ + "bandwidth-attribute":[ + { + "bwa-id":"bw6", + "resource-version":"1596387588545", + "available-bandwidth-map":{ + "available-bandwidth":[ + { + "ab-id":"ab226", + "odu-type":"ODU2", + "number":1, + "resource-version":"1596387588545" + }, + { + "ab-id":"ab112", + "odu-type":"ODU4", + "number":8, + "resource-version":"1596387588545" + } + ] + } + } + ] + }, + "resource-version":"1596387588545", + "in-maint":false + }, + "int-3-bw":{ + "interface-name":"int3", + "bandwidth-attributes":{ + "bandwidth-attribute":[ + { + "bwa-id":"bw6", + "resource-version":"1596387588545", + "available-bandwidth-map":{ + "available-bandwidth":[ + { + "ab-id":"ab226", + "odu-type":"ODU2", + "number":1, + "resource-version":"1596387588545" + }, + { + "ab-id":"ab112", + "odu-type":"ODU4", + "number":8, + "resource-version":"1596387588545" + } + ] + } + } + ] + }, + "resource-version":"1596387588545", + "in-maint":false + }, + "int-4-bw":{ + "interface-name":"int4", + "bandwidth-attributes":{ + "bandwidth-attribute":[ + { + "bwa-id":"bw6", + "resource-version":"1596387588545", + "available-bandwidth-map":{ + "available-bandwidth":[ + { + "ab-id":"ab226", + "odu-type":"ODU2", + "number":1, + "resource-version":"1596387588545" + }, + { + "ab-id":"ab112", + "odu-type":"ODU4", + "number":8, + "resource-version":"1596387588545" + } + ] + } + } + ] + }, + "resource-version":"1596387588545", + "in-maint":false + }, + "int-5-bw":{ + "interface-name":"int5", + "bandwidth-attributes":{ + "bandwidth-attribute":[ + { + "bwa-id":"bw6", + "resource-version":"1596387588545", + "available-bandwidth-map":{ + "available-bandwidth":[ + { + "ab-id":"ab226", + "odu-type":"ODU2", + "number":1, + "resource-version":"1596387588545" + }, + { + "ab-id":"ab112", + "odu-type":"ODU4", + "number":8, + "resource-version":"1596387588545" + } + ] + } + } + ] + }, + "resource-version":"1596387588545", + "in-maint":false + }, + "int-6-bw":{ + "interface-name":"int6", + "bandwidth-attributes":{ + "bandwidth-attribute":[ + { + "bwa-id":"bw6", + "resource-version":"1596387588545", + "available-bandwidth-map":{ + "available-bandwidth":[ + { + "ab-id":"ab226", + "odu-type":"ODU2", + "number":1, + "resource-version":"1596387588545" + }, + { + "ab-id":"ab112", + "odu-type":"ODU4", + "number":8, + "resource-version":"1596387588545" + } + ] + } + } + ] + }, + "resource-version":"1596387588545", + "in-maint":false + }, + "int-7-bw":{ + "interface-name":"int7", + "bandwidth-attributes":{ + "bandwidth-attribute":[ + { + "bwa-id":"bw6", + "resource-version":"1596387588545", + "available-bandwidth-map":{ + "available-bandwidth":[ + { + "ab-id":"ab226", + "odu-type":"ODU2", + "number":1, + "resource-version":"1596387588545" + }, + { + "ab-id":"ab112", + "odu-type":"ODU4", + "number":8, + "resource-version":"1596387588545" + } + ] + } + } + ] + }, + "resource-version":"1596387588545", + "in-maint":false + } +} diff --git a/test/inter_domain_route_opt/controllers_for_interfaces.json b/test/inter_domain_route_opt/controllers_for_interfaces.json new file mode 100644 index 0000000..3de47d1 --- /dev/null +++ b/test/inter_domain_route_opt/controllers_for_interfaces.json @@ -0,0 +1,62 @@ +{ + "int-1-cont":{ + "results":[ + { + "esr-thirdparty-sdnc":{ + "thirdparty-sdnc-id":"Controller1", + "resource-version":"1593421890494" + } + } + ] + }, + "int-3-cont":{ + "results":[ + { + "esr-thirdparty-sdnc":{ + "thirdparty-sdnc-id":"Controller2", + "resource-version":"1593421890494" + } + } + ] + }, + "int-4-cont":{ + "results":[ + { + "esr-thirdparty-sdnc":{ + "thirdparty-sdnc-id":"Controller2", + "resource-version":"1593421890494" + } + } + ] + }, + "int-5-cont":{ + "results":[ + { + "esr-thirdparty-sdnc":{ + "thirdparty-sdnc-id":"Controller3", + "resource-version":"1593421890494" + } + } + ] + }, + "int-6-cont":{ + "results":[ + { + "esr-thirdparty-sdnc":{ + "thirdparty-sdnc-id":"Controller3", + "resource-version":"1593421890494" + } + } + ] + }, + "int-7-cont":{ + "results":[ + { + "esr-thirdparty-sdnc":{ + "thirdparty-sdnc-id":"Controller4", + "resource-version":"1593421890494" + } + } + ] + } +} diff --git a/test/inter_domain_route_opt/controllers_list.json b/test/inter_domain_route_opt/controllers_list.json new file mode 100644 index 0000000..158f530 --- /dev/null +++ b/test/inter_domain_route_opt/controllers_list.json @@ -0,0 +1,16 @@ +{ + "esr-thirdparty-sdnc":[ + { + "thirdparty-sdnc-id":"Controller1" + }, + { + "thirdparty-sdnc-id":"Controller2" + }, + { + "thirdparty-sdnc-id":"Controller3" + }, + { + "thirdparty-sdnc-id":"Controller4" + } + ] +} diff --git a/test/inter_domain_route_opt/get_links.json b/test/inter_domain_route_opt/get_links.json new file mode 100644 index 0000000..0e70523 --- /dev/null +++ b/test/inter_domain_route_opt/get_links.json @@ -0,0 +1,157 @@ +{ + "logical-link":[ + { + "link-name":"link1", + "in-maint":false, + "link-type":"inter-domain", + "resource-version":"1588952379221", + "operational-status":"up", + "relationship-list":{ + "relationship":[ + { + "related-to":"p-interface", + "relationship-label":"tosca.relationships.network.LinksTo", + "related-link":"/aai/v19/network/pnfs/pnf/pnf1/p-interfaces/p-interface/int1", + "relationship-data":[ + { + "relationship-key":"pnf.pnf-name", + "relationship-value":"pnf1" + }, + { + "relationship-key":"p-interface.interface-name", + "relationship-value":"int1" + } + ], + "related-to-property":[ + { + "property-key":"p-interface.prov-status" + } + ] + }, + { + "related-to":"p-interface", + "relationship-label":"tosca.relationships.network.LinksTo", + "related-link":"/aai/v19/network/pnfs/pnf/pnf2/p-interfaces/p-interface/int3", + "relationship-data":[ + { + "relationship-key":"pnf.pnf-name", + "relationship-value":"pnf2" + }, + { + "relationship-key":"p-interface.interface-name", + "relationship-value":"int3" + } + ], + "related-to-property":[ + { + "property-key":"p-interface.prov-status" + } + ] + } + ] + } + }, + { + "link-name":"link2", + "in-maint":false, + "link-type":"inter-domain", + "resource-version":"1588952379221", + "operational-status":"up", + "relationship-list":{ + "relationship":[ + { + "related-to":"p-interface", + "relationship-label":"tosca.relationships.network.LinksTo", + "related-link":"/aai/v19/network/pnfs/pnf/pnf2/p-interfaces/p-interface/int4", + "relationship-data":[ + { + "relationship-key":"pnf.pnf-name", + "relationship-value":"pnf2" + }, + { + "relationship-key":"p-interface.interface-name", + "relationship-value":"int4" + } + ], + "related-to-property":[ + { + "property-key":"p-interface.prov-status" + } + ] + }, + { + "related-to":"p-interface", + "relationship-label":"tosca.relationships.network.LinksTo", + "related-link":"/aai/v19/network/pnfs/pnf/pnf3/p-interfaces/p-interface/int5", + "relationship-data":[ + { + "relationship-key":"pnf.pnf-name", + "relationship-value":"pnf3" + }, + { + "relationship-key":"p-interface.interface-name", + "relationship-value":"int5" + } + ], + "related-to-property":[ + { + "property-key":"p-interface.prov-status" + } + ] + } + ] + } + }, + { + "link-name":"link3", + "in-maint":false, + "link-type":"inter-domain", + "resource-version":"1588952379221", + "operational-status":"up", + "relationship-list":{ + "relationship":[ + { + "related-to":"p-interface", + "relationship-label":"tosca.relationships.network.LinksTo", + "related-link":"/aai/v19/network/pnfs/pnf/pnf3/p-interfaces/p-interface/int6", + "relationship-data":[ + { + "relationship-key":"pnf.pnf-name", + "relationship-value":"pnf3" + }, + { + "relationship-key":"p-interface.interface-name", + "relationship-value":"int6" + } + ], + "related-to-property":[ + { + "property-key":"p-interface.prov-status" + } + ] + }, + { + "related-to":"p-interface", + "relationship-label":"tosca.relationships.network.LinksTo", + "related-link":"/aai/v19/network/pnfs/pnf/pnf4/p-interfaces/p-interface/int7", + "relationship-data":[ + { + "relationship-key":"pnf.pnf-name", + "relationship-value":"pnf4" + }, + { + "relationship-key":"p-interface.interface-name", + "relationship-value":"int7" + } + ], + "related-to-property":[ + { + "property-key":"p-interface.prov-status" + } + ] + } + ] + } + } + ] +} diff --git a/test/inter_domain_route_opt/request.json b/test/inter_domain_route_opt/request.json new file mode 100644 index 0000000..041a32f --- /dev/null +++ b/test/inter_domain_route_opt/request.json @@ -0,0 +1,30 @@ +{ + "requestInfo":{ + "transactionId":"123456", + "requestId":"789456", + "callbackUrl":"", + "callbackHeader": "", + "sourceId":"SDNC", + "requestType":"create", + "numSolutions":1, + "optimizers":[ + "route" + ], + "timeout":600 + }, + "routeInfo":{ + "routeRequest":{ + "srcDetails":{ + "interfaceId":"int19", + "nodeId":"pnf1", + "controllerId":"Controller1" + }, + "dstDetails":{ + "interfaceId":"int20", + "nodeId":"pnf4", + "controllerId":"Controller3" + }, + "serviceRate":"ODU2" + } + } +} diff --git a/test/logging/test_osdf_logging.py b/test/logging/test_osdf_logging.py index 982ef0b..c8fa3ae 100755 --- a/test/logging/test_osdf_logging.py +++ b/test/logging/test_osdf_logging.py @@ -16,13 +16,11 @@ # ------------------------------------------------------------------------- # import unittest -import json -import yaml +from unittest import mock from osdf.logging import osdf_logging as L1 -from osdf.logging.osdf_logging import OOF_OSDFLogMessageHelper as MH -from osdf.logging.osdf_logging import OOF_OSDFLogMessageFormatter as formatter -from unittest import mock +from osdf.logging.osdf_logging import OOFOSDFLogMessageFormatter as formatter +from osdf.logging.osdf_logging import OOFOSDFLogMessageHelper as MH class TestOSDFLogging(unittest.TestCase): @@ -45,12 +43,8 @@ class TestOSDFLogging(unittest.TestCase): self.json_body = mock.MagicMock() self.F = formatter - def test_log_handlers_pre_onap(self): - res = L1.log_handlers_pre_onap() - assert type(res) == dict - def test_format_exception(self): - res = L1.format_exception(Exception("Some error")) + L1.format_exception(Exception("Some error")) def test_accepted_valid_request(self): res = formatter.accepted_valid_request(self.req_id, self.request) @@ -95,7 +89,7 @@ class TestOSDFLogging(unittest.TestCase): def test_error_calling_back(self): res = formatter.error_calling_back(self.service_name, self.callback_url, self.err) assert res.startswith("Error while posting result to callback URL") - + def test_calling_back(self): res = formatter.calling_back(self.req_id, self.callback_url) assert res.startswith("Posting result to callback URL") @@ -168,15 +162,6 @@ class TestOSDFLogging(unittest.TestCase): """Log the message to error_log.warn and audit_log.warn""" L1.warn_audit_error("Some warning message") - def test_log_message_multi(msg): - X = L1.log_handlers_pre_onap() - wanted_methods = [ - X["error"].error, X["error"].warn, X["audit"].info, - X["metrics"].info, X["debug"].debug, X["error"].fatal - ] - L1.log_message_multi("Some log message", *wanted_methods) - if __name__ == "__main__": unittest.main() - diff --git a/test/mainapp/test_osdfapp.py b/test/mainapp/test_osdfapp.py index 7fbe707..e4f12e6 100644 --- a/test/mainapp/test_osdfapp.py +++ b/test/mainapp/test_osdfapp.py @@ -15,21 +15,27 @@ # # ------------------------------------------------------------------------- # -import osdfapp + import unittest +from unittest import TestCase +from unittest import mock +from unittest.mock import patch -from osdf.operation.exceptions import BusinessException -from requests import Request, RequestException +from requests import Request +from requests import RequestException from schematics.exceptions import DataError -from unittest import mock, TestCase -from unittest.mock import patch + +from osdf.apps import baseapp +from osdf.apps.baseapp import app +from osdf.operation.exceptions import BusinessException class TestOSDFApp(TestCase): def setUp(self): - self.patcher_g = patch('osdfapp.g', return_value={'request_id':'DUMMY-REQ'}) - self.Mock_g = self.patcher_g.start() + with app.app_context(): + self.patcher_g = patch('osdf.apps.baseapp.g', return_value={'request_id': 'DUMMY-REQ'}) + self.Mock_g = self.patcher_g.start() # self.patcher2 = patch('package.module.Class2') # self.MockClass2 = self.patcher2.start() @@ -44,31 +50,30 @@ class TestOSDFApp(TestCase): e.response.content = "Some request exception occurred" # request().raise_for_status.side_effect = e return e - + def test_handle_business_exception(self): e = BusinessException("Business Exception Description") - resp = osdfapp.handle_business_exception(e) + resp = baseapp.handle_business_exception(e) assert resp.status_code == 400 def test_handle_request_exception(self): e = self.dummy_request_exception() - resp = osdfapp.handle_request_exception(e) + resp = baseapp.handle_request_exception(e) assert resp.status_code == 400 def test_handle_data_error(self): e = DataError({"A1": "A1 Data Error"}) - resp = osdfapp.handle_data_error(e) + resp = baseapp.handle_data_error(e) assert resp.status_code == 400 def test_internal_failure(self): e = Exception("An Internal Error") - resp = osdfapp.internal_failure(e) + resp = baseapp.internal_failure(e) assert resp.status_code == 500 def test_get_options_default(self): - opts = osdfapp.get_options(["PROG"]) # ensure nothing breaks + baseapp.get_options(["PROG"]) # ensure nothing breaks if __name__ == "__main__": unittest.main() - diff --git a/test/optengine-tests/test_modelapi_invalid.json b/test/optengine-tests/test_modelapi_invalid.json new file mode 100644 index 0000000..a58258e --- /dev/null +++ b/test/optengine-tests/test_modelapi_invalid.json @@ -0,0 +1,13 @@ +{ + "requestInfo": { + "transactinId": "xxx-xxx-xxxx", + "requestID": "yyy-yyy-yyyy", + "sourceId": "cmopt" + }, + "modelInfo": { + "modelId": "model2", + "solver": "mzn", + "description": "graph coloring problem for australia", + "modelContent": "int: nc;\r\nvar 1 .. nc: wa; var 1 .. nc: nt; var 1 .. nc: sa; var 1 .. nc: q;\r\nvar 1 .. nc: nsw; var 1 .. nc: v; var 1 .. nc: t;\r\nconstraint wa != nt;\r\nconstraint wa != sa;\r\nconstraint nt != sa;\r\nconstraint nt != q;\r\nconstraint sa != q;\r\nconstraint sa != nsw;\r\nconstraint sa != v;\r\nconstraint q != nsw;\r\nconstraint nsw != v;\r\nsolve satisfy;\r\noutput [\r\n \"wa=\\(wa)\\t nt=\\(nt)\\t sa=\\(sa)\\n\",\r\n \"q=\\(q)\\t nsw=\\(nsw)\\t v=\\(v)\\n\",\r\n \"t=\", show(t), \"\\n\"\r\n];" + } +}
\ No newline at end of file diff --git a/test/optengine-tests/test_modelapi_valid.json b/test/optengine-tests/test_modelapi_valid.json new file mode 100644 index 0000000..1fbca5b --- /dev/null +++ b/test/optengine-tests/test_modelapi_valid.json @@ -0,0 +1,13 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestID": "yyy-yyy-yyyy", + "sourceId": "cmopt" + }, + "modelInfo": { + "modelId": "model2", + "solver": "mzn", + "description": "graph coloring problem for australia", + "modelContent": "int: nc;\r\nvar 1 .. nc: wa; var 1 .. nc: nt; var 1 .. nc: sa; var 1 .. nc: q;\r\nvar 1 .. nc: nsw; var 1 .. nc: v; var 1 .. nc: t;\r\nconstraint wa != nt;\r\nconstraint wa != sa;\r\nconstraint nt != sa;\r\nconstraint nt != q;\r\nconstraint sa != q;\r\nconstraint sa != nsw;\r\nconstraint sa != v;\r\nconstraint q != nsw;\r\nconstraint nsw != v;\r\nsolve satisfy;\r\noutput [\r\n \"wa=\\(wa)\\t nt=\\(nt)\\t sa=\\(sa)\\n\",\r\n \"q=\\(q)\\t nsw=\\(nsw)\\t v=\\(v)\\n\",\r\n \"t=\", show(t), \"\\n\"\r\n];" + } +}
\ No newline at end of file diff --git a/test/optengine-tests/test_optengine_invalid.json b/test/optengine-tests/test_optengine_invalid.json new file mode 100644 index 0000000..9a0267a --- /dev/null +++ b/test/optengine-tests/test_optengine_invalid.json @@ -0,0 +1,18 @@ +{ + "requestInfo": { + "transactioId": "xxx-xxx-xxxx", + "requestID": "yyy-yyy-yyyy", + "sourceId": "cmopt", + "timeout": 600 + }, + "optimInfo": { + "solver": "mzn", + "solverArgs": { + "solver": "geocode" + }, + "modelContent": "int: nc;\r\nvar 1 .. nc: wa; var 1 .. nc: nt; var 1 .. nc: sa; var 1 .. nc: q;\r\nvar 1 .. nc: nsw; var 1 .. nc: v; var 1 .. nc: t;\r\nconstraint wa != nt;\r\nconstraint wa != sa;\r\nconstraint nt != sa;\r\nconstraint nt != q;\r\nconstraint sa != q;\r\nconstraint sa != nsw;\r\nconstraint sa != v;\r\nconstraint q != nsw;\r\nconstraint nsw != v;\r\nsolve satisfy;\r\noutput [\r\n \"wa=\\(wa)\\t nt=\\(nt)\\t sa=\\(sa)\\n\",\r\n \"q=\\(q)\\t nsw=\\(nsw)\\t v=\\(v)\\n\",\r\n \"t=\", show(t), \"\\n\"\r\n];", + "optData": { + "nc": 3 + } + } +}
\ No newline at end of file diff --git a/test/optengine-tests/test_optengine_invalid2.json b/test/optengine-tests/test_optengine_invalid2.json new file mode 100644 index 0000000..23c5a8e --- /dev/null +++ b/test/optengine-tests/test_optengine_invalid2.json @@ -0,0 +1,15 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestID": "yyy-yyy-yyyy", + "sourceId": "cmopt", + "timeout": 600 + }, + "optimInfo": { + + "solverArgs": { + "solver": "cbc" + }, + "modelContent": "% Baking cakes for the school fete (with data file)\r\n\r\nint: flour; %no. grams of flour available\r\nint: banana; %no. of bananas available\r\nint: sugar; %no. grams of sugar available\r\nint: butter; %no. grams of butter available\r\nint: cocoa; %no. grams of cocoa available\r\n\r\nconstraint assert(flour >= 0,\"Invalid datafile: \" ++\r\n \"Amount of flour should be non-negative\");\r\nconstraint assert(banana >= 0,\"Invalid datafile: \" ++\r\n \"Amount of banana should be non-negative\");\r\nconstraint assert(sugar >= 0,\"Invalid datafile: \" ++\r\n \"Amount of sugar should be non-negative\");\r\nconstraint assert(butter >= 0,\"Invalid datafile: \" ++\r\n \"Amount of butter should be non-negative\");\r\nconstraint assert(cocoa >= 0,\"Invalid datafile: \" ++\r\n \"Amount of cocoa should be non-negative\");\r\n\r\nvar 0..100: b; % no. of banana cakes\r\nvar 0..100: c; % no. of chocolate cakes\r\n\r\n% flour\r\nconstraint 250*b + 200*c <= flour;\r\n% bananas\r\nconstraint 2*b <= banana;\r\n% sugar\r\nconstraint 75*b + 150*c <= sugar;\r\n% butter\r\nconstraint 100*b + 150*c <= butter;\r\n% cocoa\r\nconstraint 75*c <= cocoa;\r\n\r\n% maximize our profit\r\nsolve maximize 400*b + 450*c;\r\n\r\noutput [\"no. of banana cakes = \\(b)\\n\",\r\n \"no. of chocolate cakes = \\(c)\\n\"];" + } +}
\ No newline at end of file diff --git a/test/optengine-tests/test_optengine_invalid_solver.json b/test/optengine-tests/test_optengine_invalid_solver.json new file mode 100644 index 0000000..a967c16 --- /dev/null +++ b/test/optengine-tests/test_optengine_invalid_solver.json @@ -0,0 +1,15 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestID": "yyy-yyy-yyyy", + "sourceId": "cmopt", + "timeout": 600 + }, + "optimInfo": { + "solver": "apy", + "modelContent": "import sys\r\n\r\nif __name__ == \"__main__\":\r\n print(sys.argv[1],sys.argv[2])\r\n\r\n with open(sys.argv[2], \"wt\") as f:\r\n f.write('{\"hello\":\"world\",\"another\":\"string\"}')\r\n\r\n", + "optData": { + "text": "flour = 8000; \r\nbanana = 11; \r\nsugar = 3000; \r\nbutter = 1500; \r\ncocoa = 800; " + } + } +}
\ No newline at end of file diff --git a/test/optengine-tests/test_optengine_modelId.json b/test/optengine-tests/test_optengine_modelId.json new file mode 100644 index 0000000..b676d91 --- /dev/null +++ b/test/optengine-tests/test_optengine_modelId.json @@ -0,0 +1,19 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestID": "yyy-yyy-yyyy", + "sourceId": "cmopt", + "timeout": 600 + }, + "optimInfo": { + "modelId": "test", + "solverArgs": { + "solver": "geocode" + }, + "optData": { + "json": { + "nc": 3 + } + } + } +}
\ No newline at end of file diff --git a/test/optengine-tests/test_optengine_no_modelid.json b/test/optengine-tests/test_optengine_no_modelid.json new file mode 100644 index 0000000..9a8c3a4 --- /dev/null +++ b/test/optengine-tests/test_optengine_no_modelid.json @@ -0,0 +1,24 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestID": "yyy-yyy-yyyy", + "sourceId": "cmopt", + "timeout": 600 + }, + "optimInfo": { + "solver": "mzn", + "solverArgs": { + "solver": "cbc" + }, + "modelContent": "% Baking cakes for the school fete (with data file)\r\n\r\nint: flour; %no. grams of flour available\r\nint: banana; %no. of bananas available\r\nint: sugar; %no. grams of sugar available\r\nint: butter; %no. grams of butter available\r\nint: cocoa; %no. grams of cocoa available\r\n\r\nconstraint assert(flour >= 0,\"Invalid datafile: \" ++\r\n \"Amount of flour should be non-negative\");\r\nconstraint assert(banana >= 0,\"Invalid datafile: \" ++\r\n \"Amount of banana should be non-negative\");\r\nconstraint assert(sugar >= 0,\"Invalid datafile: \" ++\r\n \"Amount of sugar should be non-negative\");\r\nconstraint assert(butter >= 0,\"Invalid datafile: \" ++\r\n \"Amount of butter should be non-negative\");\r\nconstraint assert(cocoa >= 0,\"Invalid datafile: \" ++\r\n \"Amount of cocoa should be non-negative\");\r\n\r\nvar 0..100: b; % no. of banana cakes\r\nvar 0..100: c; % no. of chocolate cakes\r\n\r\n% flour\r\nconstraint 250*b + 200*c <= flour;\r\n% bananas\r\nconstraint 2*b <= banana;\r\n% sugar\r\nconstraint 75*b + 150*c <= sugar;\r\n% butter\r\nconstraint 100*b + 150*c <= butter;\r\n% cocoa\r\nconstraint 75*c <= cocoa;\r\n\r\n% maximize our profit\r\nsolve maximize 400*b + 450*c;\r\n\r\noutput [\"no. of banana cakes = \\(b)\\n\",\r\n \"no. of chocolate cakes = \\(c)\\n\"];", + "optData": { + "json": { + "flour": 4000, + "banana": 6, + "sugar": 2000, + "butter": 500, + "cocoa": 500 + } + } + } +}
\ No newline at end of file diff --git a/test/optengine-tests/test_optengine_no_optdata.json b/test/optengine-tests/test_optengine_no_optdata.json new file mode 100644 index 0000000..f6645c8 --- /dev/null +++ b/test/optengine-tests/test_optengine_no_optdata.json @@ -0,0 +1,15 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestID": "yyy-yyy-yyyy", + "sourceId": "cmopt", + "timeout": 600 + }, + "optimInfo": { + "solver": "mzn", + "solverArgs": { + "solver": "geocode" + }, + "modelContent": "int: nc;\r\nvar 1 .. nc: wa; var 1 .. nc: nt; var 1 .. nc: sa; var 1 .. nc: q;\r\nvar 1 .. nc: nsw; var 1 .. nc: v; var 1 .. nc: t;\r\nconstraint wa != nt;\r\nconstraint wa != sa;\r\nconstraint nt != sa;\r\nconstraint nt != q;\r\nconstraint sa != q;\r\nconstraint sa != nsw;\r\nconstraint sa != v;\r\nconstraint q != nsw;\r\nconstraint nsw != v;\r\nsolve satisfy;\r\noutput [\r\n \"wa=\\(wa)\\t nt=\\(nt)\\t sa=\\(sa)\\n\",\r\n \"q=\\(q)\\t nsw=\\(nsw)\\t v=\\(v)\\n\",\r\n \"t=\", show(t), \"\\n\"\r\n];" + } +}
\ No newline at end of file diff --git a/test/optengine-tests/test_optengine_solverid.json b/test/optengine-tests/test_optengine_solverid.json new file mode 100644 index 0000000..bfd446c --- /dev/null +++ b/test/optengine-tests/test_optengine_solverid.json @@ -0,0 +1,15 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestID": "yyy-yyy-yyyy", + "sourceId": "cmopt", + "timeout": 600 + }, + "optimInfo": { + "solver": "py", + "modelContent": "import sys\r\n\r\nif __name__ == \"__main__\":\r\n print(sys.argv[1],sys.argv[2])\r\n\r\n with open(sys.argv[2], \"wt\") as f:\r\n f.write('{\"hello\":\"world\",\"another\":\"string\"}')\r\n\r\n", + "optData": { + "text": "flour = 8000; \r\nbanana = 11; \r\nsugar = 3000; \r\nbutter = 1500; \r\ncocoa = 800; " + } + } +}
\ No newline at end of file diff --git a/test/optengine-tests/test_optengine_valid.json b/test/optengine-tests/test_optengine_valid.json new file mode 100644 index 0000000..8de2b71 --- /dev/null +++ b/test/optengine-tests/test_optengine_valid.json @@ -0,0 +1,20 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestID": "yyy-yyy-yyyy", + "sourceId": "cmopt", + "timeout": 600 + }, + "optimInfo": { + "solver": "mzn", + "solverArgs": { + "solver": "geocode" + }, + "modelContent": "int: nc;\r\nvar 1 .. nc: wa; var 1 .. nc: nt; var 1 .. nc: sa; var 1 .. nc: q;\r\nvar 1 .. nc: nsw; var 1 .. nc: v; var 1 .. nc: t;\r\nconstraint wa != nt;\r\nconstraint wa != sa;\r\nconstraint nt != sa;\r\nconstraint nt != q;\r\nconstraint sa != q;\r\nconstraint sa != nsw;\r\nconstraint sa != v;\r\nconstraint q != nsw;\r\nconstraint nsw != v;\r\nsolve satisfy;\r\noutput [\r\n \"wa=\\(wa)\\t nt=\\(nt)\\t sa=\\(sa)\\n\",\r\n \"q=\\(q)\\t nsw=\\(nsw)\\t v=\\(v)\\n\",\r\n \"t=\", show(t), \"\\n\"\r\n];", + "optData": { + "json": { + "nc": 3 + } + } + } +}
\ No newline at end of file diff --git a/test/optengine-tests/test_py_optengine_valid.json b/test/optengine-tests/test_py_optengine_valid.json new file mode 100644 index 0000000..bfd446c --- /dev/null +++ b/test/optengine-tests/test_py_optengine_valid.json @@ -0,0 +1,15 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestID": "yyy-yyy-yyyy", + "sourceId": "cmopt", + "timeout": 600 + }, + "optimInfo": { + "solver": "py", + "modelContent": "import sys\r\n\r\nif __name__ == \"__main__\":\r\n print(sys.argv[1],sys.argv[2])\r\n\r\n with open(sys.argv[2], \"wt\") as f:\r\n f.write('{\"hello\":\"world\",\"another\":\"string\"}')\r\n\r\n", + "optData": { + "text": "flour = 8000; \r\nbanana = 11; \r\nsugar = 3000; \r\nbutter = 1500; \r\ncocoa = 800; " + } + } +}
\ No newline at end of file diff --git a/test/osdf/utils/test_interfaces.py b/test/osdf/utils/test_interfaces.py index cdb3d7a..8d66e16 100644 --- a/test/osdf/utils/test_interfaces.py +++ b/test/osdf/utils/test_interfaces.py @@ -16,12 +16,13 @@ # ------------------------------------------------------------------------- # import requests -import unittest - from requests.models import Response -from osdf.utils.interfaces import RestClient, get_rest_client +import unittest from unittest.mock import patch +from osdf.utils.interfaces import get_rest_client +from osdf.utils.interfaces import RestClient + m1 = Response() m1._content = b'{"msg": "OK"}' @@ -39,7 +40,7 @@ class TestOsdfUtilsInterfaces(unittest.TestCase): def test_rc_request(self, mock_good_response): rc = RestClient() rc.add_headers({}) - rc.request(req_id="testReq") + rc.request(url="http://localhost", req_id="testReq") @patch('requests.request', return_value=mock_good_response) def test_rc_request_v1(self, mock_good_response): @@ -53,7 +54,7 @@ class TestOsdfUtilsInterfaces(unittest.TestCase): def test_rc_request_v2(self, mock_bad_response): rc = RestClient() try: - rc.request() + rc.request(url="http://localhost") except requests.RequestException: return raise Exception("Allows bad requests instead of raising exception") @@ -66,4 +67,3 @@ class TestOsdfUtilsInterfaces(unittest.TestCase): if __name__ == "__main__": unittest.main() - diff --git a/test/pci-optimization-tests/fixed_pci.json b/test/pci-optimization-tests/fixed_pci.json new file mode 100644 index 0000000..0038d04 --- /dev/null +++ b/test/pci-optimization-tests/fixed_pci.json @@ -0,0 +1,42 @@ +{ + + "requestInfo": { + + "transactionId": "xxx-xxx-xxxx", + + "requestId": "yyy-yyy-yyyy", + + "callbackUrl": "https://wiki.onap.org:5000/callbackUrl/", + + "sourceId": "SO", + + "requestType": "create", + + "numSolutions": 1, + + "optimizers": [ + + "pci-anr" + + ], + + "timeout": 600 + + }, + + "cellInfo": { + + "networkId": "netw2000", + + "cellIdList": [ + + "cell0" + + ], + + "fixedPCICells": ["cell21","cell22"], + "anrInputList": [{"cellId": "cell20", "removeableNeighbors" :["cell23"]}], + "trigger": "NbrListChange" + } + +} diff --git a/test/pci-optimization-tests/pci_anr_request.json b/test/pci-optimization-tests/pci_anr_request.json new file mode 100644 index 0000000..34e2409 --- /dev/null +++ b/test/pci-optimization-tests/pci_anr_request.json @@ -0,0 +1,29 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestId": "yyy-yyy-yyyy", + "callbackUrl": "https://wiki.onap.org:5000/callbackUrl/", + "sourceId": "SO", + "requestType": "create", + "numSolutions": 1, + "optimizers": [ + "pci-anr" + ], + "timeout": 600 + }, + "cellInfo": { + "networkId": "netw2000", + "cellIdList": [ + "cell20" + ] + }, + "anrInputList": [ + { + "cellId": "cell20", + "removeableNeighbors": [ + "cell23" + ] + } + ], + "trigger": "NbrListChange" +}
\ No newline at end of file diff --git a/test/pci-optimization-tests/request.json b/test/pci-optimization-tests/request.json index 7ec9ab5..a8eb4f6 100644 --- a/test/pci-optimization-tests/request.json +++ b/test/pci-optimization-tests/request.json @@ -7,14 +7,14 @@ "requestType": "create", "numSolutions": 1, "optimizers": [ - "placement" + "pci" ], "timeout": 600 }, "cellInfo": { - "networkId": "1000", + "networkId": "netw1000", "cellIdList": [ "cell0" ] } -}
\ No newline at end of file +} diff --git a/test/placement-tests/policy_response.json b/test/placement-tests/policy_response.json index 8de8537..a257ecc 100644 --- a/test/placement-tests/policy_response.json +++ b/test/placement-tests/policy_response.json @@ -1,182 +1,694 @@ -[ { - "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\",\"PVT Homing\",\"subscriberpolicy\",\"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\",\"PVT Homing\",\"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\",\"PVT Homing\",\"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\",\"PVT Homing\",\"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\",\"PVT Homing\",\"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\", \"PVT Homing\",\"us\", \"international\", \"ip\", \"vG\", \"vim_fit\"], \"resources\": [\"vG\"], \"capacityProperty\": {\"controller\": \"multicloud\", \"request\": \"{\\\"vCPU\\\": 10, \\\"Memory\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_MEM\\\"}, \\\"unit\\\": \\\"GB\\\"}, \\\"Storage\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_DISK\\\", \\\"unit\\\": \\\"GB\\\"}}}\"}, \"policyType\": \"vim_fit\", \"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\", \"attribute_location\": \"customerLocation\", \"value\": \"\"}, {\"attribute\": \"id\", \"attribute_location\": \"vpnInfo.vpnId\", \"value\": \"\"}, {\"attribute\": \"upstreamBW\", \"attribute_location\": \"vpnInfo.upstreamBW\", \"value\": \"\"}, {\"attribute\": \"customerLatitude\", \"attribute_location\": \"customerLatitude\", \"value\": 32.89748}, {\"attribute\": \"customerLongitude\", \"attribute_location\": \"customerLongitude\", \"value\": -97.040443}], \"policyScope\": [\"vcpe\", \"PVT Homing\",\"us\", \"international\", \"ip\", \"vGMuxInfra\", \"vG\", \"optimizationQueryPolicy\"], \"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\",\"PVT Homing\",\"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\",\"PVT Homing\",\"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\", \"PVT Homing\",\"us\", \"international\", \"ip\", \"vGMuxInfra\", \"vim_fit\"], \"resources\": [\"vGMuxInfra\"], \"capacityProperty\": {\"controller\": \"multicloud\", \"request\": \"{\\\"vCPU\\\": 10, \\\"Memory\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_MEM\\\"}, \\\"unit\\\": \\\"GB\\\"}, \\\"Storage\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_DISK\\\", \\\"unit\\\": \\\"GB\\\"}}}\"}, \"policyType\": \"vim_fit\", \"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 + "policies": { + "OSDF_FRANKFURT.SubscriberPolicy_v1": { + "type": "onap.policies.optimization.SubscriberPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.SubscriberPolicy_v1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "identity": "subscriber_vCPE", + "properties": { + "subscriberName": [ + "subscriber_x", + "subscriber_y" + ], + "subscriberRole": [ + "PVT Homing" + ], + "provStatus": [ + "CAPPED" + ] + } + } + }, + "OSDF_FRANKFURT.vnfPolicy_vG": { + "type": "onap.policies.optimization.VnfPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.vnfPolicy_vG", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "vnf_vG", + "applicableResources": "any", + "vnfProperties": [ + { + "inventoryProvider": "aai", + "serviceType": "", + "inventoryType": "cloud", + "customerId": "", + "orchestrationStatus": "", + "equipmentRole": "" + } + ] + } + }, + "OSDF_FRANKFURT.vnfPolicy_vGMuxInfra": { + "type": "onap.policies.optimization.VnfPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.vnfPolicy_vGMuxInfra", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "vnf_vGMuxInfra", + "applicableResources": "any", + "vnfProperties": [ + { + "inventoryProvider": "aai", + "serviceType": "vGMuxInfra-xx", + "inventoryType": "service", + "customerId": "SDN-ETHERNET-INTERNET", + "orchestrationStatus": "", + "equipmentRole": "" + } + ] + } + }, + "OSDF_FRANKFURT.Distance_vG_1": { + "type": "onap.policies.optimization.DistancePolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Distance_vG_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "distance-vG", + "applicableResources": "any", + "distanceProperties": { + "locationInfo": "customer_loc", + "distance": { + "value": "1500", + "operator": "<", + "unit": "km" + } + } + } + }, + "OSDF_FRANKFURT.Distance_vGMuxInfra": { + "type": "onap.policies.optimization.DistancePolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Distance_vGMuxInfra", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "distance-vGMuxInfra", + "applicableResources": "any", + "distanceProperties": { + "locationInfo": "customer_loc", + "distance": { + "value": "500", + "operator": "<", + "unit": "km" + } + } + } + }, + "OSDF_FRANKFURT.Placement_optimization_1": { + "type": "onap.policies.optimization.OptimizationPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Placement_optimization_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG", + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "optimization", + "objective": "minimize", + "objectiveParameter": { + "parameterAttributes": [ + { + "resources": [ + "vGMuxInfra" + ], + "customerLocationInfo": "customer_loc", + "parameter": "distance", + "weight": "1", + "operator": "product" + }, + { + "resources": [ + "vG" + ], + "customerLocationInfo": "customer_loc", + "parameter": "distance", + "weight": "1", + "operator": "product" + }, + { + "resources": [ + "vG" + ], + "parameter": "hpa_score", + "weight": "200", + "operator": "product" + }, + { + "resources": [ + "vFW" + ], + "customerLocationInfo": "customer_loc", + "parameter": "distance", + "weight": "100", + "operator": "product" + }, + { + "resources": [ + "vFW" + ], + "parameter": "hpa_score", + "weight": "200", + "operator": "product" + } + ], + "operator": "sum" + } + } + }, + "OSDF_FRANKFURT.queryPolicy_vCPE": { + "type": "onap.policies.optimization.QueryPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.queryPolicy_vCPE", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra", + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "vCPE_Query_Policy", + "queryProperties": [ + { + "attribute": "customerLatitude", + "attribute_location": "customerLatitude" + }, + { + "attribute": "customerLongitude", + "attribute_location": "customerLongitude" + } + ] + } + }, + "OSDF_FRANKFURT.hpa_policy_vG_1": { + "type": "onap.policies.optimization.HpaPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.hpa_policy_vG_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "hpa-vG", + "flavorFeatures": [ + { + "id": "vg_1", + "type": "vnfc", + "directives": [ + { + "type": "flavor_directives", + "attributes": [ + { + "attribute_name": "flavor_label_vm_01", + "attribute_value": "" + } + ] + } + ], + "flavorProperties": [ + { + "hpa-feature": "cpuTopology", + "mandatory": "True", + "architecture": "generic", + "directives": [], + "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", + "directives": [], + "hpa-feature-attributes": [ + { + "hpa-attribute-key": "numVirtualCpu", + "hpa-attribute-value": 6, + "operator": [ + "=" + ], + "unit": "" + }, + { + "hpa-attribute-key": "virtualMemSize", + "hpa-attribute-value": 6, + "operator": [ + "=" + ], + "unit": "" + } + ] + }, + { + "hpa-feature": "ovsDpdk", + "mandatory": false, + "score": 3, + "architecture": "generic", + "directives": [], + "hpa-feature-attributes": [ + { + "hpa-attribute-key": "dataProcessingAccelerationLibrary", + "hpa-attribute-value": "ovsDpdk_version", + "operator": [ + "=" + ], + "unit": "" + } + ] + }, + { + "hpa-feature": "cpuInstructionSetExtensions", + "mandatory": true, + "architecture": "INTEL-64", + "directives": [], + "hpa-feature-attributes": [ + { + "hpa-attribute-key": "instructionSetExtensions", + "hpa-attribute-value": [ + "<CPUINST>", + "<CPUINST>" + ], + "operator": [ + "ALL" + ], + "unit": "" + } + ] + } + ] + }, + { + "id": "vg_2", + "type": "vnfc", + "directives": [ + { + "type": "flavor_directives", + "attributes": [ + { + "attribute_name": "flavor_label_vm_02", + "attribute_value": "" + } + ] + } + ], + "flavorProperties": [ + { + "hpa-feature": "cpuPinningy", + "mandatory": "True", + "architecture": "generic", + "directives": [], + "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", + "directives": [], + "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", + "directives": [], + "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": "pciePassthrough", + "mandatory": "True", + "architecture": "generic", + "directives": [], + "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": "" + } + ] + } + ] + }, + { + "id": "vg_3", + "type": "vnfc", + "directives": [ + { + "type": "flavor_directives", + "attributes": [ + { + "attribute_name": "flavor_label_vm_03", + "attribute_value": "" + } + ] + } + ], + "flavorProperties": [ + { + "hpa-feature": "numa", + "mandatory": "False", + "score": "5", + "architecture": "generic", + "directives": [], + "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", + "directives": [], + "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", + "directives": [], + "hpa-feature-attributes": [ + { + "hpa-attribute-key": "memoryPageSize", + "hpa-attribute-value": "<MEMORYPAGESIZE>", + "operator": "=", + "unit": "" + } + ] + } + ] + } + ] + } + }, + "OSDF_FRANKFURT.Capacity_vG_1": { + "type": "onap.policies.optimization.Vim_fit", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Capacity_vG_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "capacity_vG", + "applicableResources": "any", + "capacityProperty": { + "controller": "multicloud", + "request": "{\"vCPU\": 10, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"GB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}" + } + } + }, + "OSDF_FRANKFURT.Capacity_vGMuxInfra": { + "type": "onap.policies.optimization.Vim_fit", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Capacity_vGMuxInfra", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "capacity_vGMuxInfra", + "applicableResources": "any", + "capacityProperty": { + "controller": "multicloud", + "request": "{\"vCPU\": 10, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"GB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}" + } + } + } + } } -]
\ No newline at end of file diff --git a/test/placement-tests/policy_response2.json b/test/placement-tests/policy_response2.json index 2cd6dcb..15ddbe1 100644 --- a/test/placement-tests/policy_response2.json +++ b/test/placement-tests/policy_response2.json @@ -1,182 +1,705 @@ -[ - { - "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\",\"PVT Homing\",\"SubscriberPolicy\",\"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": "" +{ + "policies": { + "OSDF_FRANKFURT.SubscriberPolicy_v1": { + "type": "onap.policies.optimization.SubscriberPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.SubscriberPolicy_v1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "PVT Homing" + ], + "services": [ + "vCPE" + ], + "identity": "subscriber_vCPE", + "properties": { + "subscriberName": [ + "subscriber_x", + "subscriber_y" + ], + "subscriberRole": [ + "PVT Homing" + ], + "provStatus": [ + "CAPPED" + ] + } + } }, - "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\",\"PVT Homing\",\"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": "" + "OSDF_FRANKFURT.vnfPolicy_vG": { + "type": "onap.policies.optimization.VnfPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.vnfPolicy_vG", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "PVT Homing" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "vnf_vG", + "applicableResources": "any", + "vnfProperties": [ + { + "inventoryProvider": "aai", + "serviceType": "", + "inventoryType": "cloud", + "customerId": "", + "orchestrationStatus": "", + "equipmentRole": "" + } + ] + } }, - "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": "" + "OSDF_FRANKFURT.vnfPolicy_vGMuxInfra": { + "type": "onap.policies.optimization.VnfPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.vnfPolicy_vGMuxInfra", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "PVT Homing" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "vnf_vGMuxInfra", + "applicableResources": "any", + "vnfProperties": [ + { + "inventoryProvider": "aai", + "serviceType": "vGMuxInfra-xx", + "inventoryType": "service", + "customerId": "SDN-ETHERNET-INTERNET", + "orchestrationStatus": "", + "equipmentRole": "" + } + ] + } }, - "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": "" + "OSDF_FRANKFURT.Distance_vG_1": { + "type": "onap.policies.optimization.DistancePolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Distance_vG_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "PVT Homing" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "distance-vG", + "applicableResources": "any", + "distanceProperties": { + "locationInfo": "customer_loc", + "distance": { + "value": "1500", + "operator": "<", + "unit": "km" + } + } + } }, - "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": "" + "OSDF_FRANKFURT.Distance_vGMuxInfra": { + "type": "onap.policies.optimization.DistancePolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Distance_vGMuxInfra", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "PVT Homing" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "distance-vGMuxInfra", + "applicableResources": "any", + "distanceProperties": { + "locationInfo": "customer_loc", + "distance": { + "value": "500", + "operator": "<", + "unit": "km" + } + } + } }, - "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\", \"vim_fit\"], \"resources\": [\"vG\"], \"capacityProperty\": {\"controller\": \"multicloud\", \"request\": \"{\\\"vCPU\\\": 10, \\\"Memory\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_MEM\\\"}, \\\"unit\\\": \\\"GB\\\"}, \\\"Storage\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_DISK\\\", \\\"unit\\\": \\\"GB\\\"}}}\"}, \"policyType\": \"vim_fit\", \"applicableResources\": \"any\"}}", - "policyName": "oofBeijing.Config_MS_capacityPolicy_vG.1.xml", - "policyVersion": "1", - "matchingConditions": { - "ECOMPName": "SNIRO-Placement", - "ONAPName": "SNIRO-Placement", - "ConfigName": "", - "service": "capacityPolicy", - "uuid": "", - "Location": "" + "OSDF_FRANKFURT.Placement_optimization_1": { + "type": "onap.policies.optimization.OptimizationPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Placement_optimization_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "PVT Homing" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG", + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "optimization", + "objective": "minimize", + "objectiveParameter": { + "parameterAttributes": [ + { + "resources": [ + "vGMuxInfra" + ], + "customerLocationInfo": "customer_loc", + "parameter": "distance", + "weight": "1", + "operator": "product" + }, + { + "resources": [ + "vG" + ], + "customerLocationInfo": "customer_loc", + "parameter": "distance", + "weight": "1", + "operator": "product" + }, + { + "resources": [ + "vG" + ], + "parameter": "hpa_score", + "weight": "200", + "operator": "product" + }, + { + "resources": [ + "vFW" + ], + "customerLocationInfo": "customer_loc", + "parameter": "distance", + "weight": "100", + "operator": "product" + }, + { + "resources": [ + "vFW" + ], + "parameter": "hpa_score", + "weight": "200", + "operator": "product" + } + ], + "operator": "sum" + } + } }, - "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\", \"attribute_location\": \"customerLocation\", \"value\": \"\"}, {\"attribute\": \"id\", \"attribute_location\": \"vpnInfo.vpnId\", \"value\": \"\"}, {\"attribute\": \"upstreamBW\", \"attribute_location\": \"vpnInfo.upstreamBW\", \"value\": \"\"}, {\"attribute\": \"customerLatitude\", \"attribute_location\": \"customerLatitude\", \"value\": 32.89748}, {\"attribute\": \"customerLongitude\", \"attribute_location\": \"customerLongitude\", \"value\": -97.040443}], \"policyScope\": [\"vCPE\",\"US\", \"INTERNATIONAL\", \"ip\", \"vGMuxInfra\", \"vG\", \"optimizationQueryPolicy\"], \"policyType\": \"optimizationQueryPolicy\"}}", - "policyName": "oofBeijing.Config_MS_queryPolicy_vCPE.1.xml", - "policyVersion": "1", - "matchingConditions": { - "ECOMPName": "SNIRO-Placement", - "ONAPName": "SNIRO-Placement", - "ConfigName": "", - "service": "optimizationQueryPolicy", - "uuid": "", - "Location": "" + "OSDF_FRANKFURT.queryPolicy_vCPE": { + "type": "onap.policies.optimization.QueryPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.queryPolicy_vCPE", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "PVT Homing" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra", + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "vCPE_Query_Policy", + "queryProperties": [ + { + "attribute": "customerLatitude", + "attribute_location": "customerLatitude" + }, + { + "attribute": "customerLongitude", + "attribute_location": "customerLongitude" + } + ] + } }, - "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": "" + "OSDF_FRANKFURT.hpa_policy_vG_1": { + "type": "onap.policies.optimization.HpaPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.hpa_policy_vG_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "PVT Homing" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "hpa-vG", + "flavorFeatures": [ + { + "id": "vg_1", + "type": "vnfc", + "directives": [ + { + "type": "flavor_directives", + "attributes": [ + { + "attribute_name": "flavor_label_vm_01", + "attribute_value": "" + } + ] + } + ], + "flavorProperties": [ + { + "hpa-feature": "cpuTopology", + "mandatory": "True", + "architecture": "generic", + "directives": [], + "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", + "directives": [], + "hpa-feature-attributes": [ + { + "hpa-attribute-key": "numVirtualCpu", + "hpa-attribute-value": 6, + "operator": [ + "=" + ], + "unit": "" + }, + { + "hpa-attribute-key": "virtualMemSize", + "hpa-attribute-value": 6, + "operator": [ + "=" + ], + "unit": "" + } + ] + }, + { + "hpa-feature": "ovsDpdk", + "mandatory": false, + "score": 3, + "architecture": "generic", + "directives": [], + "hpa-feature-attributes": [ + { + "hpa-attribute-key": "dataProcessingAccelerationLibrary", + "hpa-attribute-value": "ovsDpdk_version", + "operator": [ + "=" + ], + "unit": "" + } + ] + }, + { + "hpa-feature": "cpuInstructionSetExtensions", + "mandatory": true, + "architecture": "INTEL-64", + "directives": [], + "hpa-feature-attributes": [ + { + "hpa-attribute-key": "instructionSetExtensions", + "hpa-attribute-value": [ + "<CPUINST>", + "<CPUINST>" + ], + "operator": [ + "ALL" + ], + "unit": "" + } + ] + } + ] + }, + { + "id": "vg_2", + "type": "vnfc", + "directives": [ + { + "type": "flavor_directives", + "attributes": [ + { + "attribute_name": "flavor_label_vm_02", + "attribute_value": "" + } + ] + } + ], + "flavorProperties": [ + { + "hpa-feature": "cpuPinningy", + "mandatory": "True", + "architecture": "generic", + "directives": [], + "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", + "directives": [], + "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", + "directives": [], + "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": "pciePassthrough", + "mandatory": "True", + "architecture": "generic", + "directives": [], + "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": "" + } + ] + } + ] + }, + { + "id": "vg_3", + "type": "vnfc", + "directives": [ + { + "type": "flavor_directives", + "attributes": [ + { + "attribute_name": "flavor_label_vm_03", + "attribute_value": "" + } + ] + } + ], + "flavorProperties": [ + { + "hpa-feature": "numa", + "mandatory": "False", + "score": "5", + "architecture": "generic", + "directives": [], + "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", + "directives": [], + "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", + "directives": [], + "hpa-feature-attributes": [ + { + "hpa-attribute-key": "memoryPageSize", + "hpa-attribute-value": "<MEMORYPAGESIZE>", + "operator": "=", + "unit": "" + } + ] + } + ] + } + ] + } }, - "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": "" + "OSDF_FRANKFURT.Capacity_vG_1": { + "type": "onap.policies.optimization.Vim_fit", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Capacity_vG_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "PVT Homing" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "capacity_vG", + "applicableResources": "any", + "capacityProperty": { + "controller": "multicloud", + "request": "{\"vCPU\": 10, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"GB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}" + } + } }, - "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\", \"vim_fit\"], \"resources\": [\"vGMuxInfra\"], \"capacityProperty\": {\"controller\": \"multicloud\", \"request\": \"{\\\"vCPU\\\": 10, \\\"Memory\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_MEM\\\"}, \\\"unit\\\": \\\"GB\\\"}, \\\"Storage\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_DISK\\\", \\\"unit\\\": \\\"GB\\\"}}}\"}, \"policyType\": \"vim_fit\", \"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 + "OSDF_FRANKFURT.Capacity_vGMuxInfra": { + "type": "onap.policies.optimization.Vim_fit", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Capacity_vGMuxInfra", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "PVT Homing" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "capacity_vGMuxInfra", + "applicableResources": "any", + "capacityProperty": { + "controller": "multicloud", + "request": "{\"vCPU\": 10, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"GB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}" + } + } + } } -]
\ No newline at end of file +} + diff --git a/test/placement-tests/policy_response2_old_format.json b/test/placement-tests/policy_response2_old_format.json new file mode 100644 index 0000000..2cd6dcb --- /dev/null +++ b/test/placement-tests/policy_response2_old_format.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\",\"PVT Homing\",\"SubscriberPolicy\",\"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\",\"PVT Homing\",\"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\", \"vim_fit\"], \"resources\": [\"vG\"], \"capacityProperty\": {\"controller\": \"multicloud\", \"request\": \"{\\\"vCPU\\\": 10, \\\"Memory\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_MEM\\\"}, \\\"unit\\\": \\\"GB\\\"}, \\\"Storage\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_DISK\\\", \\\"unit\\\": \\\"GB\\\"}}}\"}, \"policyType\": \"vim_fit\", \"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\", \"attribute_location\": \"customerLocation\", \"value\": \"\"}, {\"attribute\": \"id\", \"attribute_location\": \"vpnInfo.vpnId\", \"value\": \"\"}, {\"attribute\": \"upstreamBW\", \"attribute_location\": \"vpnInfo.upstreamBW\", \"value\": \"\"}, {\"attribute\": \"customerLatitude\", \"attribute_location\": \"customerLatitude\", \"value\": 32.89748}, {\"attribute\": \"customerLongitude\", \"attribute_location\": \"customerLongitude\", \"value\": -97.040443}], \"policyScope\": [\"vCPE\",\"US\", \"INTERNATIONAL\", \"ip\", \"vGMuxInfra\", \"vG\", \"optimizationQueryPolicy\"], \"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\", \"vim_fit\"], \"resources\": [\"vGMuxInfra\"], \"capacityProperty\": {\"controller\": \"multicloud\", \"request\": \"{\\\"vCPU\\\": 10, \\\"Memory\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_MEM\\\"}, \\\"unit\\\": \\\"GB\\\"}, \\\"Storage\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_DISK\\\", \\\"unit\\\": \\\"GB\\\"}}}\"}, \"policyType\": \"vim_fit\", \"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_old_format.json b/test/placement-tests/policy_response_old_format.json new file mode 100644 index 0000000..8de8537 --- /dev/null +++ b/test/placement-tests/policy_response_old_format.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\",\"PVT Homing\",\"subscriberpolicy\",\"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\",\"PVT Homing\",\"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\",\"PVT Homing\",\"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\",\"PVT Homing\",\"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\",\"PVT Homing\",\"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\", \"PVT Homing\",\"us\", \"international\", \"ip\", \"vG\", \"vim_fit\"], \"resources\": [\"vG\"], \"capacityProperty\": {\"controller\": \"multicloud\", \"request\": \"{\\\"vCPU\\\": 10, \\\"Memory\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_MEM\\\"}, \\\"unit\\\": \\\"GB\\\"}, \\\"Storage\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_DISK\\\", \\\"unit\\\": \\\"GB\\\"}}}\"}, \"policyType\": \"vim_fit\", \"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\", \"attribute_location\": \"customerLocation\", \"value\": \"\"}, {\"attribute\": \"id\", \"attribute_location\": \"vpnInfo.vpnId\", \"value\": \"\"}, {\"attribute\": \"upstreamBW\", \"attribute_location\": \"vpnInfo.upstreamBW\", \"value\": \"\"}, {\"attribute\": \"customerLatitude\", \"attribute_location\": \"customerLatitude\", \"value\": 32.89748}, {\"attribute\": \"customerLongitude\", \"attribute_location\": \"customerLongitude\", \"value\": -97.040443}], \"policyScope\": [\"vcpe\", \"PVT Homing\",\"us\", \"international\", \"ip\", \"vGMuxInfra\", \"vG\", \"optimizationQueryPolicy\"], \"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\",\"PVT Homing\",\"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\",\"PVT Homing\",\"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\", \"PVT Homing\",\"us\", \"international\", \"ip\", \"vGMuxInfra\", \"vim_fit\"], \"resources\": [\"vGMuxInfra\"], \"capacityProperty\": {\"controller\": \"multicloud\", \"request\": \"{\\\"vCPU\\\": 10, \\\"Memory\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_MEM\\\"}, \\\"unit\\\": \\\"GB\\\"}, \\\"Storage\\\": {\\\"quantity\\\": {\\\"get_param\\\": \\\"REQUIRED_DISK\\\", \\\"unit\\\": \\\"GB\\\"}}}\"}, \"policyType\": \"vim_fit\", \"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_placement_vfmod.json b/test/placement-tests/request_placement_vfmod.json new file mode 100644 index 0000000..4b2b852 --- /dev/null +++ b/test/placement-tests/request_placement_vfmod.json @@ -0,0 +1,113 @@ +{ + "name": "de4f04e3-0a65-470b-9d07-8ea6c2fb3e10", + "files": {}, + "timeout": 1200, + "num_solution": "100", + "template": { + "homing_template_version": "2017-10-10", + "parameters": { + "REQUIRED_MEM": "", + "REQUIRED_DISK": "", + "customer_lat": 1.1, + "customer_long": 2.2, + "service_name": "vFW_TD", + "service_id": "3e8d118c-10ca-4b4b-b3db-089b5e9e6a1c", + "chosen_region": "RegionOne" + }, + "locations": { + "customer_loc": { + "latitude": { + "get_param": "customer_lat" + }, + "longitude": { + "get_param": "customer_long" + } + } + }, + "demands": { + "vFW-SINK": [ + { + "inventory_provider": "aai", + "inventory_type": "vfmodule", + "service_type": "vFW-SINK-XX", + "service_resource_id": "vFW-SINK-XX", + "filtering_attributes": { + "global-customer-id": { + "get_param": "chosen_customer_id" + }, + "model-invariant-id": "e7227847-dea6-4374-abca-4561b070fe7d", + "model-version-id": "763731df-84fd-494b-b824-01fc59a5ff2d", + "orchestration-status": [ + "active" + ], + "prov-status": "ACTIVE", + "cloud-region-id": { + "get_param": "chosen_region" + }, + "service_instance_id": { + "get_param": "service_id" + } + }, + "passthrough_attributes": { + "td-role": "destination" + }, + "excluded_candidates": [ + { + "inventory_type": "vfmodule", + "candidate_id": [ + "e765d576-8755-4145-8536-0bb6d9b1dc9a" + ] + } + ] + } + ], + "vPGN": [ + { + "inventory_provider": "aai", + "inventory_type": "vfmodule", + "service_type": "vPGN-XX", + "service_resource_id": "vPGN-XX", + "unique": "False", + "filtering_attributes": { + "global-customer-id": { + "get_param": "chosen_customer_id" + }, + "model-invariant-id": "762472ef-5284-4daa-ab32-3e7bee2ec355", + "model-version-id": "e02a7e5c-9d27-4360-ab7c-73bb83b07e3b", + "orchestration-status": [ + "active" + ], + "prov-status": "ACTIVE", + "cloud-region-id": { + "get_param": "chosen_region" + }, + "service_instance_id": { + "get_param": "service_id" + } + }, + "passthrough_attributes": { + "td-role": "anchor" + } + } + ] + }, + "constraints": { + "affinity_vFW_TD": { + "type": "zone", + "demands": [ + "vFW-SINK", + "vPGN" + ], + "properties": { + "category": "region", + "qualifier": "same" + } + } + }, + "optimization": { + "minimize": { + "sum": [] + } + } + } +}
\ No newline at end of file diff --git a/test/placement-tests/request_vfmod.json b/test/placement-tests/request_vfmod.json new file mode 100644 index 0000000..1a8a462 --- /dev/null +++ b/test/placement-tests/request_vfmod.json @@ -0,0 +1,57 @@ +{ + "requestInfo": { + "transactionId": "e576c75e-7536-4145-a1c0-d60b65bb1bb8", + "requestId": "de4f04e3-0a65-470b-9d07-8ea6c2fb3e10", + "callbackUrl": "http://0.0.0.0:9000/osdfCallback/", + "sourceId": "SO", + "requestType": "create", + "numSolutions": "100", + "optimizers": [ + "placement" + ], + "timeout": 1200 + }, + "placementInfo": { + "requestParameters": { + "chosenRegion": "RegionOne" + }, + "subscriberInfo": { + "globalSubscriberId": "dbc2c763-6383-42d6-880a-b7d5c5bc84d9", + "subscriberName": "oof-so-chm" + }, + "placementDemands": [ + { + "resourceModuleName": "vFW-SINK", + "serviceResourceId": "vFW-SINK-XX", + "resourceModelInfo": { + "modelInvariantId": "e7227847-dea6-4374-abca-4561b070fe7d", + "modelVersionId": "763731df-84fd-494b-b824-01fc59a5ff2d" + }, + "excludedCandidates": [ + { + "identifierType": "vfmodule", + "identifiers": [ + "e765d576-8755-4145-8536-0bb6d9b1dc9a" + ] + } + ] + }, + { + "resourceModuleName": "vPGN", + "serviceResourceId": "vPGN-XX", + "resourceModelInfo": { + "modelInvariantId": "762472ef-5284-4daa-ab32-3e7bee2ec355", + "modelVersionId": "e02a7e5c-9d27-4360-ab7c-73bb83b07e3b" + } + } + ] + }, + "serviceInfo": { + "serviceInstanceId": "3e8d118c-10ca-4b4b-b3db-089b5e9e6a1c", + "serviceName": "vFW_TD", + "modelInfo": { + "modelInvariantId": "TD-invariantId", + "modelVersionId": "TD-versionId" + } + } +}
\ No newline at end of file diff --git a/test/placement-tests/response_vfmod.json b/test/placement-tests/response_vfmod.json new file mode 100644 index 0000000..06e40de --- /dev/null +++ b/test/placement-tests/response_vfmod.json @@ -0,0 +1,229 @@ +{ + "transactionId": "", + "requestStatus": "completed", + "solutions": { + "placementSolutions": [ + [{ + "assignmentInfo": [{ + "key": "locationType", + "value": "att_aic" + }, { + "key": "vnfHostName", + "value": "vFW-FW-MC" + }, { + "key": "locationId", + "value": "RegionOne" + }, { + "key": "isRehome", + "value": "false" + }, { + "key": "nf-name", + "value": "vFW-FW-MC" + }, { + "key": "vnf-type", + "value": "5G_EVE_Demo/5G_EVE_FW 0" + }, { + "key": "ipv6-oam-address", + "value": "" + }, { + "key": "ipv4-oam-address", + "value": "oam_network_zb4J" + }, { + "key": "vservers", + "value": [{ + "vserver-id": "4a61b075-5ae0-4cfe-b213-27d3647a0578", + "l-interfaces": [{ + "macaddr": "fa:16:3e:4a:00:56", + "interface-name": "vnf-snk-r1-t1-mc-vfw_private_3_port-tntiamoj2res", + "ipv4-addresses": ["10.100.100.1"], + "ipv6-addresses": [], + "interface-id": "ff27775b-a2b7-4e6e-8f71-6a5a5e6020cd", + "network-name": "", + "network-id": "59763a33-3296-4dc8-9ee6-2bdcd63322fc" + }, { + "macaddr": "fa:16:3e:a1:e8:c9", + "interface-name": "vnf-snk-r1-t1-mc-vfw_private_2_port-hiay5zan4da6", + "ipv4-addresses": ["10.0.110.1"], + "ipv6-addresses": [], + "interface-id": "0bb0bb92-a4d1-4104-b491-e469949f60a3", + "network-name": "", + "network-id": "cdb4bc25-2412-4b77-bbd5-791a02f8776d" + }, { + "macaddr": "fa:16:3e:45:e2:16", + "interface-name": "vnf-snk-r1-t1-mc-vfw_private_0_port-7xlr5kjvsmk6", + "ipv4-addresses": ["192.168.10.100"], + "ipv6-addresses": [], + "interface-id": "f0291365-6070-4baa-8470-8775bed7c2c4", + "network-name": "", + "network-id": "932ac514-639a-45b2-b1a3-4c5bb708b5c1" + }, { + "macaddr": "fa:16:3e:2f:0b:2f", + "interface-name": "vnf-snk-r1-t1-mc-vfw_private_1_port-khio4swt2vy3", + "ipv4-addresses": ["192.168.20.100"], + "ipv6-addresses": [], + "interface-id": "5ba290b0-0833-4008-acda-be1878b9ae0c", + "network-name": "", + "network-id": "bd64a2b0-0bdd-45b4-b755-65d5ebe1cee0" + }], + "vserver-name": "vfw-vfw-1-dt" + }, { + "vserver-id": "cf51eeab-8f75-4635-a01c-9f4bbd1e146e", + "l-interfaces": [{ + "macaddr": "fa:16:3e:23:82:d7", + "interface-name": "vnf-snk-r1-t1-mc-vsn_private_2_port-spbtqjnybz5g", + "ipv4-addresses": ["10.100.100.3"], + "ipv6-addresses": [], + "interface-id": "1b3fd313-cde3-4df6-8ea8-bf4ae28e7e03", + "network-name": "", + "network-id": "59763a33-3296-4dc8-9ee6-2bdcd63322fc" + }, { + "macaddr": "fa:16:3e:fc:bd:16", + "interface-name": "vnf-snk-r1-t1-mc-vsn_private_1_port-spqyrticfqan", + "ipv4-addresses": ["10.0.110.3"], + "ipv6-addresses": [], + "interface-id": "1b33d675-f351-4766-8669-7314f774d52c", + "network-name": "", + "network-id": "cdb4bc25-2412-4b77-bbd5-791a02f8776d" + }, { + "macaddr": "fa:16:3e:3d:e9:c5", + "interface-name": "vnf-snk-r1-t1-mc-vsn_private_0_port-5ijwpdueh2fl", + "ipv4-addresses": ["192.168.20.250"], + "ipv6-addresses": [], + "interface-id": "cf82e256-8ccf-4e43-ba96-04ea2e47b5d2", + "network-name": "", + "network-id": "bd64a2b0-0bdd-45b4-b755-65d5ebe1cee0" + }], + "vserver-name": "vfw-vsn-1-dt" + }] + }, { + "key": "nf-type", + "value": "vnf" + }, { + "key": "vnfHostName", + "value": "vFW-FW-MC" + }, { + "key": "aic_version", + "value": "1" + }, { + "key": "cloudClli", + "value": "clli1" + }, { + "key": "service_instance_id", + "value": "3e8d118c-10ca-4b4b-b3db-089b5e9e6a1c" + }, { + "key": "cloudOwner", + "value": "CloudOwner" + }, { + "value": "vfw-0-mc", + "key": "vf-module-name" + }, { + "value": "85eec994-b635-42c7-87a1-d39720cad36d", + "key": "vf-module-id" + }, { + "key": "nf-id", + "value": "4d2dc294-dbb3-44a2-8422-fa61b30c21a9" + }], + "serviceResourceId": "vFW-SINK-XX", + "solution": { + "cloudOwner": "CloudOwner", + "identifiers": ["85eec994-b635-42c7-87a1-d39720cad36d"], + "identifierType": "vfmodule" + }, + "resourceModuleName": "vFW-SINK" + }, { + "assignmentInfo": [{ + "key": "locationType", + "value": "att_aic" + }, { + "key": "vnfHostName", + "value": "vFW-PKG-MC" + }, { + "key": "locationId", + "value": "RegionOne" + }, { + "key": "isRehome", + "value": "false" + }, { + "key": "nf-name", + "value": "vFW-PKG-MC" + }, { + "key": "vnf-type", + "value": "5G_EVE_Demo/5G_EVE_PKG 0" + }, { + "key": "ipv6-oam-address", + "value": "" + }, { + "key": "ipv4-oam-address", + "value": "oam_network_zb4J" + }, { + "key": "vservers", + "value": [{ + "vserver-id": "00bddefc-126e-4e4f-a18d-99b94d8d9a30", + "l-interfaces": [{ + "macaddr": "fa:16:3e:c4:07:7f", + "interface-name": "vnf-pkg-r1-t2-mc-vpg_private_2_port-mf7lu55usq7i", + "ipv4-addresses": ["10.100.100.2"], + "ipv6-addresses": [], + "interface-id": "4b333af1-90d6-42ae-8389-d440e6ff0e93", + "network-name": "", + "network-id": "59763a33-3296-4dc8-9ee6-2bdcd63322fc" + }, { + "macaddr": "fa:16:3e:b5:86:38", + "interface-name": "vnf-pkg-r1-t2-mc-vpg_private_1_port-734xxixicw6r", + "ipv4-addresses": ["10.0.110.2"], + "ipv6-addresses": [], + "interface-id": "85dd57e9-6e3a-48d0-a784-4598d627e798", + "network-name": "", + "network-id": "cdb4bc25-2412-4b77-bbd5-791a02f8776d" + }, { + "macaddr": "fa:16:3e:ff:d8:6f", + "interface-name": "vnf-pkg-r1-t2-mc-vpg_private_0_port-e5qdm3p5ijhe", + "ipv4-addresses": ["192.168.10.200"], + "ipv6-addresses": [], + "interface-id": "edaff25a-878e-4706-ad52-4e3d51cf6a82", + "network-name": "", + "network-id": "932ac514-639a-45b2-b1a3-4c5bb708b5c1" + }], + "vserver-name": "zdfw1fwl01pgn01" + }] + }, { + "key": "nf-type", + "value": "vnf" + }, { + "key": "vnfHostName", + "value": "vFW-PKG-MC" + }, { + "key": "aic_version", + "value": "1" + }, { + "key": "cloudClli", + "value": "clli1" + }, { + "key": "service_instance_id", + "value": "3e8d118c-10ca-4b4b-b3db-089b5e9e6a1c" + }, { + "key": "cloudOwner", + "value": "CloudOwner" + }, { + "value": "pkg-0-mc", + "key": "vf-module-name" + }, { + "value": "d187d743-5932-4fb9-a42d-db0a5be5ba7e", + "key": "vf-module-id" + }, { + "key": "nf-id", + "value": "fcbff633-47cc-4f38-a98d-4ba8285bd8b6" + }], + "serviceResourceId": "vPGN-XX", + "solution": { + "cloudOwner": "CloudOwner", + "identifiers": ["d187d743-5932-4fb9-a42d-db0a5be5ba7e"], + "identifierType": "vfmodule" + }, + "resourceModuleName": "vPGN" + }] + ] + }, + "statusMessage": "", + "requestId": "de4f04e3-0a65-470b-9d07-8ea6c2fb3e10" +}
\ 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 2cdd4e4..1968b89 100644 --- a/test/placement-tests/test_by_scope.yaml +++ b/test/placement-tests/test_by_scope.yaml @@ -2,23 +2,32 @@ references: service_name: source: request value: serviceInfo.serviceName + resource: + source: request + value: placementInfo.placementDemands.resourceModuleName subscriber_role: - source: SubscriberPolicy - value: content.properties.subscriberRole + source: onap.policies.optimization.SubscriberPolicy + value: properties.properties.subscriberRole policy_info: placement: policy_fetch: by_scope policy_scope: - default_scope: OSDF_R2 - vcpe_scope: OSDF_R2 - secondary_scopes: - - - - get_param: service_name - - SubscriberPolicy - - + - + scope: + - OSDF_FRANKFURT + - onap.policies.optimization.SubscriberPolicy + service: - get_param: service_name + - + scope: + - OSDF_FRANKFURT - get_param: subscriber_role + service: + - get_param: service_name + # - + # - 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/test_by_scope_old_format.yaml b/test/placement-tests/test_by_scope_old_format.yaml new file mode 100644 index 0000000..2cdd4e4 --- /dev/null +++ b/test/placement-tests/test_by_scope_old_format.yaml @@ -0,0 +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: 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/policy-local-files/Affinity_vCPE_1.json b/test/policy-local-files/Affinity_vCPE_1.json index 0f7efc3..5364d5d 100644 --- a/test/policy-local-files/Affinity_vCPE_1.json +++ b/test/policy-local-files/Affinity_vCPE_1.json @@ -1,21 +1,33 @@ { - "service": "affinityPolicy", - "policyName": "OSDF_CASABLANCA.Affinity_vCPE_1", - "description": "Zone policy for vCPE", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "3", - "riskType": "test", - "riskLevel": "2", - "guard": "False", - "content": { - "identity": "affinity_vCPE", - "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"], - "affinityProperty": { - "qualifier": "same", - "category": "complex" - }, - "policyType": "zone", - "resources": ["vGMuxInfra", "vG"] + "OSDF_FRANKFURT.Affinity_vCPE_1": { + "type": "onap.policies.optimization.resource.AffinityPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Affinity_vCPE_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG", + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "affinity_vCPE", + "applicableResources": "any", + "affinityProperties": { + "qualifier": "same", + "category": "complex" + } } + } } diff --git a/test/policy-local-files/Affinity_vFW_TD.json b/test/policy-local-files/Affinity_vFW_TD.json new file mode 100644 index 0000000..5df3bf4 --- /dev/null +++ b/test/policy-local-files/Affinity_vFW_TD.json @@ -0,0 +1,31 @@ +{ + "OSDF_FRANKFURT.Affinity_vFW_TD": { + "type": "onap.policies.optimization.resource.AffinityPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Affinity_vFW_TD", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "TD" + ], + "resources": [ + "vFW-SINK", + "vPGN" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "affinity_vFW_TD", + "applicableResources": "any", + "affinityProperties": { + "qualifier": "same", + "category": "region" + } + } + } +} diff --git a/test/policy-local-files/Attribute_vNS_1.json b/test/policy-local-files/Attribute_vNS_1.json new file mode 100644 index 0000000..97c967c --- /dev/null +++ b/test/policy-local-files/Attribute_vNS_1.json @@ -0,0 +1,51 @@ +{ + "OSDF_FRANKFURT.Attribute_vNS_1": { + "type": "onap.policies.optimization.resource.AttributePolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Attribute_vNS_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vNS" + ], + "resources": [ + "vNS" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "attribute-vNS", + "attributeProperties": { + "cloudRegion": { + "serviceRequests": [ + "", + "" + ], + "cloudRequests": [ + "", + "" + ] + }, + "networkRoles": { + "all": [ + "", + "" + ] + }, + "complex": { + "any": [ + "", + "" + ] + } + } + } + } +}
\ No newline at end of file diff --git a/test/policy-local-files/Capacity_vGMuxInfra.json b/test/policy-local-files/Capacity_vGMuxInfra.json index f5abc42..7ce02bf 100644 --- a/test/policy-local-files/Capacity_vGMuxInfra.json +++ b/test/policy-local-files/Capacity_vGMuxInfra.json @@ -1,22 +1,32 @@ { - "service": "vim_fit", - "policyName": "OSDF_CASABLANCA.Capacity_vGMuxInfra", - "description": "Capacity policy for vGMuxInfra", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "5", - "riskType": "test", - "riskLevel": "2", - "guard": "False", - "content": { - "identity": "capacity_vGMuxInfra", - "policyScope": ["VCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"], - "resources": ["vGMuxInfra"], - "capacityProperty": { - "controller": "multicloud", - "request": "{\"vCPU\": 10, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"GB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}" - }, - "policyType": "vim_fit", - "applicableResources": "any" + "OSDF_FRANKFURT.Capacity_vGMuxInfra": { + "type": "onap.policies.optimization.resource.Vim_fit", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Capacity_vGMuxInfra", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "capacity_vGMuxInfra", + "applicableResources": "any", + "capacityProperty": { + "controller": "multicloud", + "request": "{\"vCPU\": 10, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"GB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}" + } } + } } diff --git a/test/policy-local-files/Capacity_vG_1.json b/test/policy-local-files/Capacity_vG_1.json index 6fa1f2d..c897a87 100644 --- a/test/policy-local-files/Capacity_vG_1.json +++ b/test/policy-local-files/Capacity_vG_1.json @@ -1,22 +1,32 @@ { - "service": "vim_fit", - "policyName": "OSDF_CASABLANCA.Capacity_vG_1", - "description": "Capacity policy for vG", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "5", - "riskType": "test", - "riskLevel": "2", - "guard": "False", - "content": { - "identity": "capacity_vG", - "policyScope": ["VCPE", "US", "INTERNATIONAL", "ip", "vG"], - "resources": ["vG"], - "capacityProperty": { - "controller": "multicloud", - "request": "{\"vCPU\": 10, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"GB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}" - }, - "policyType": "vim_fit", - "applicableResources": "any" + "OSDF_FRANKFURT.Capacity_vG_1": { + "type": "onap.policies.optimization.resource.Vim_fit", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Capacity_vG_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "capacity_vG", + "applicableResources": "any", + "capacityProperty": { + "controller": "multicloud", + "request": "{\"vCPU\": 10, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"GB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}" + } } + } } diff --git a/test/policy-local-files/Distance_vGMuxInfra_1.json b/test/policy-local-files/Distance_vGMuxInfra_1.json index 5d22702..163d0df 100644 --- a/test/policy-local-files/Distance_vGMuxInfra_1.json +++ b/test/policy-local-files/Distance_vGMuxInfra_1.json @@ -1,22 +1,36 @@ { - "service": "distancePolicy", - "policyName": "OSDF_CASABLANCA.Distance_vGMuxInfra", - "description": "Distance Policy for vGMuxInfra", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "3", - "riskType": "test", - "riskLevel": "2", - "guard": "False", - "content": { - "distanceProperties": { - "locationInfo": "customer_loc", - "distance": { "value": "500", "operator": "<", "unit": "km" } + "OSDF_FRANKFURT.Distance_vGMuxInfra": { + "type": "onap.policies.optimization.resource.DistancePolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Distance_vGMuxInfra", + "policy-version": 1 }, - "identity": "distance-vGMuxInfra", - "resources": ["vGMuxInfra"], - "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"], - "policyType": "distance_to_location", - "applicableResources": "any" + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "distance-vGMuxInfra", + "applicableResources": "any", + "distanceProperties": { + "locationInfo": "customer_loc", + "distance": { + "value": "500", + "operator": "<", + "unit": "km" + } + } + } } } diff --git a/test/policy-local-files/Distance_vG_1.json b/test/policy-local-files/Distance_vG_1.json index a326331..aa6badc 100644 --- a/test/policy-local-files/Distance_vG_1.json +++ b/test/policy-local-files/Distance_vG_1.json @@ -1,22 +1,36 @@ { - "service": "distancePolicy", - "policyName": "OSDF_CASABLANCA.Distance_vG_1", - "description": "Distance Policy for vG", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "3", - "riskType": "test", - "riskLevel": "2", - "guard": "False", - "content": { - "distanceProperties": { - "locationInfo": "customer_loc", - "distance": { "value": "1500", "operator": "<", "unit": "km" } + "OSDF_FRANKFURT.Distance_vG_1": { + "type": "onap.policies.optimization.resource.DistancePolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Distance_vG_1", + "policy-version": 1 }, - "identity": "distance-vG", - "resources": ["vG"], - "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vG"], - "policyType": "distance_to_location", - "applicableResources": "any" + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "distance-vG", + "applicableResources": "any", + "distanceProperties": { + "locationInfo": "customer_loc", + "distance": { + "value": "1500", + "operator": "<", + "unit": "km" + } + } + } } } diff --git a/test/policy-local-files/Placement_Optimization_1.json b/test/policy-local-files/Placement_Optimization_1.json index 8632b6b..62b024c 100644 --- a/test/policy-local-files/Placement_Optimization_1.json +++ b/test/policy-local-files/Placement_Optimization_1.json @@ -1,15 +1,30 @@ { - "service": "optimizationPolicy", - "policyName": "OSDF_CASABLANCA.Placement_Optimization_1", - "description": "Placement Optimization Policy for vGMuxInfra", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "5", - "riskType": "test", - "riskLevel": "3", - "guard": "False", - "content": { - "objectiveParameter": { + "OSDF_FRANKFURT.Placement_optimization_1": { + "type": "onap.policies.optimization.resource.OptimizationPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.Placement_optimization_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG", + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "optimization", + "objective": "minimize", + "objectiveParameter": { "parameterAttributes": [ { "resources": ["vGMuxInfra"], @@ -46,10 +61,7 @@ } ], "operator": "sum" - }, - "identity": "optimization", - "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"], - "policyType": "placement_optimization", - "objective": "minimize" + } } + } } diff --git a/test/policy-local-files/QueryPolicy_vCPE.json b/test/policy-local-files/QueryPolicy_vCPE.json index 7d5aad2..3bcc67e 100644 --- a/test/policy-local-files/QueryPolicy_vCPE.json +++ b/test/policy-local-files/QueryPolicy_vCPE.json @@ -1,21 +1,38 @@ { - "service": "queryPolicy", - "policyName": "OSDF_CASABLANCA.QueryPolicy_vCPE", - "description": "Query policy for vCPE", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "3", - "riskType": "test", - "riskLevel": "2", - "guard": "False", - "content": { - "queryProperties": [ - {"attribute":"customerLatitude", "attribute_location": "customerLatitude"}, - {"attribute":"customerLongitude", "attribute_location": "customerLongitude"} - ], - "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"], - "policyType": "request_param_query", - "serviceName": "vCPE", - "identity": "vCPE_Query_Policy" + "OSDF_FRANKFURT.queryPolicy_vCPE": { + "type": "onap.policies.optimization.service.QueryPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.queryPolicy_vCPE", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra", + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "vCPE_Query_Policy", + "queryProperties": [ + { + "attribute": "customerLatitude", + "attribute_location": "customerLatitude" + }, + { + "attribute": "customerLongitude", + "attribute_location": "customerLongitude" + } + ] + } } } diff --git a/test/policy-local-files/QueryPolicy_vCPE_2.json b/test/policy-local-files/QueryPolicy_vCPE_2.json index 512989f..3d9f4ca 100644 --- a/test/policy-local-files/QueryPolicy_vCPE_2.json +++ b/test/policy-local-files/QueryPolicy_vCPE_2.json @@ -1,24 +1,55 @@ { - "service": "queryPolicy", - "policyName": "OSDF_CASABLANCA.queryPolicy_vCPE", - "description": "Query policy for vCPE", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "3", - "riskType": "test", - "riskLevel": "2", - "guard": "False", - "content": { - "queryProperties": [ - {"attribute":"locationId", "attribute_location": "customerLocation", "value": ""}, - {"attribute":"id", "attribute_location": "vpnInfo.vpnId", "value": ""}, - {"attribute":"upstreamBW", "attribute_location": "vpnInfo.upstreamBW", "value": ""}, - {"attribute":"customerLatitude", "attribute_location": "customerLatitude", "value": 1.1}, - {"attribute":"customerLongitude", "attribute_location": "customerLongitude", "value": 2.2} - ], - "serviceName": "vCPE", - "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"], - "policyType": "request_param_query", - "identity": "vCPE_Query_Policy" + "OSDF_FRANKFURT.queryPolicy_vCPE": { + "type": "onap.policies.optimization.service.QueryPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.queryPolicy_vCPE", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra", + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "vCPE_Query_Policy", + "queryProperties": [ + { + "attribute": "locationId", + "attribute_location": "customerLocation", + "value": "" + }, + { + "attribute": "id", + "attribute_location": "vpnInfo.vpnId", + "value": "" + }, + { + "attribute": "upstreamBW", + "attribute_location": "vpnInfo.upstreamBW", + "value": "" + }, + { + "attribute": "customerLatitude", + "attribute_location": "customerLatitude", + "value": 1.1 + }, + { + "attribute": "customerLongitude", + "attribute_location": "customerLongitude", + "value": 2.2 + } + ] + } } } diff --git a/test/policy-local-files/QueryPolicy_vFW_TD.json b/test/policy-local-files/QueryPolicy_vFW_TD.json new file mode 100644 index 0000000..ab199ac --- /dev/null +++ b/test/policy-local-files/QueryPolicy_vFW_TD.json @@ -0,0 +1,47 @@ +{ + "OSDF_FRANKFURT.queryPolicy_vFW_TD": { + "type": "onap.policies.optimization.service.QueryPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.queryPolicy_vFW_TD", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vFW_TD" + ], + "resources": [ + "vFW-SINK", + "vPGN" + ], + "geography": [ + "US" + ], + "identity": "vFW_TD_Query_Policy", + "queryProperties": [ + { + "attribute": "chosen_region", + "attribute_location": "chosenRegion" + }, + { + "attribute": "chosen_customer_id", + "attribute_location": "chosenCustomerId" + }, + { + "attribute": "customerLatitude", + "attribute_location": "customerLatitude", + "value": 1.1 + }, + { + "attribute": "customerLongitude", + "attribute_location": "customerLongitude", + "value": 2.2 + } + ] + } + } +} diff --git a/test/policy-local-files/aggregationPolicy_URLLC_1.json b/test/policy-local-files/aggregationPolicy_URLLC_1.json new file mode 100644 index 0000000..13014c1 --- /dev/null +++ b/test/policy-local-files/aggregationPolicy_URLLC_1.json @@ -0,0 +1,37 @@ +{ + "OSDF_FRANKFURT.Aggregation_URLLC_1":{ + "type":"onap.policies.optimization.resource.AggregationPolicy", + "version":"1.0.0", + "type_version":"1.0.0", + "metadata":{ + "policy-id":"OSDF_FRANKFURT.Aggregation_URLLC_1", + "policy-version":1 + }, + "properties":{ + "scope":[ + "OSDF_FRANKFURT", + "URLLC_1" + ], + "geography": [], + "resources":[ + "URLLC_Core_1" + ], + "services":[ + "URLLC_1" + ], + "identity":"Aggregation_URLLC_1", + "applicableResources":"any", + "aggregationProperties":[ + { + "attribute":"latency", + "function":"sum", + "operator":"lte", + "threshold":{ + "get_param": "latency" + }, + "unit":"ms" + } + ] + } + } +}
\ No newline at end of file diff --git a/test/policy-local-files/hpa_policy_vGMuxInfra_1.json b/test/policy-local-files/hpa_policy_vGMuxInfra_1.json index 8ee0469..b6317f8 100644 --- a/test/policy-local-files/hpa_policy_vGMuxInfra_1.json +++ b/test/policy-local-files/hpa_policy_vGMuxInfra_1.json @@ -1,18 +1,27 @@ { - "service": "hpaPolicy", - "policyName": "OSDF_CASABLANCA.hpa_policy_vGMuxInfra_1", - "description": "HPA policy for vGMuxInfra", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "3", - "riskType": "test", - "riskLevel": "2", - "guard": "False", - "content": { - "resources": ["vGMuxInfra"], + "OSDF_FRANKFURT.hpa_policy_vGMuxInfra_1": { + "type": "onap.policies.optimization.resource.HpaPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.hpa_policy_vGMuxInfra_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], "identity": "hpa-vGMuxInfra", - "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"], - "policyType": "hpa", "flavorFeatures": [ { "id": "vgmux_1", @@ -28,8 +37,8 @@ ] } ], - "flavorProperties":[ - { + "flavorProperties": [ + { "hpa-feature" : "cpuTopology", "mandatory" : "True", "architecture": "generic", @@ -43,33 +52,64 @@ {"hpa-attribute-key":"numCpuThreads", "hpa-attribute-value": "8", "operator":"<=", "unit": ""} ] }, - { - "hpa-feature" : "basicCapabilities", - "mandatory" : "True", + { + "hpa-feature": "basicCapabilities", + "mandatory": true, "architecture": "generic", "directives": [], "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-attribute-key": "numVirtualCpu", + "hpa-attribute-value": 6, + "operator": [ + "=" + ], + "unit": "" + }, + { + "hpa-attribute-key": "virtualMemSize", + "hpa-attribute-value": 6, + "operator": [ + "=" + ], + "unit": "" + } ] }, { - "hpa-feature" : "ovsDpdk", - "mandatory" : "False", - "score" : "3", + "hpa-feature": "ovsDpdk", + "mandatory": false, + "score": 3, "architecture": "generic", "directives": [], "hpa-feature-attributes": [ - {"hpa-attribute-key":"dataProcessingAccelerationLibrary", "hpa-attribute-value":"ovsDpdk_version", "operator": "=", "unit":""} + { + "hpa-attribute-key": "dataProcessingAccelerationLibrary", + "hpa-attribute-value": "ovsDpdk_version", + "operator": [ + "=" + ], + "unit": "" + } ] }, { - "hpa-feature" : "cpuInstructionSetExtensions", - "mandatory" : "True", + "hpa-feature": "cpuInstructionSetExtensions", + "mandatory": true, "architecture": "INTEL-64", "directives": [], "hpa-feature-attributes": [ - {"hpa-attribute-key":"instructionSetExtensions", "hpa-attribute-value":["<CPUINST>", "<CPUINST>"], "operator": "ALL", "unit":""} + { + "hpa-attribute-key": "instructionSetExtensions", + "hpa-attribute-value": [ + "<CPUINST>", + "<CPUINST>" + ], + "operator": [ + "ALL" + ], + "unit": "" + } ] } ] @@ -99,7 +139,7 @@ {"hpa-attribute-key":"logicalCpuPinningPolicy", "hpa-attribute-value": "<CPUPOLICY>","operator": "=", "unit":""} ] }, - { + { "hpa-feature" : "basicCapabilities", "mandatory" : "True", "architecture": "generic", @@ -122,18 +162,17 @@ ] }, { - "hpa-feature" : "pcie", + "hpa-feature" : "pciePassthrough", "mandatory" : "True", "architecture": "generic", "directives": [], "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": ""} + {"hpa-attribute-key": "pciDeviceId", "hpa-attribute-value": "2", "operator": "=", "unit": ""} ] } - ] +] }, { "id": "vgmux_3", @@ -163,7 +202,7 @@ {"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", @@ -188,4 +227,5 @@ } ] } + } } diff --git a/test/policy-local-files/hpa_policy_vG_1.json b/test/policy-local-files/hpa_policy_vG_1.json index 2bdba31..59ba4b1 100644 --- a/test/policy-local-files/hpa_policy_vG_1.json +++ b/test/policy-local-files/hpa_policy_vG_1.json @@ -1,18 +1,27 @@ { - "service": "hpaPolicy", - "policyName": "OSDF_CASABLANCA.hpa_policy_vG_1", - "description": "HPA policy for vG", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "3", - "riskType": "test", - "riskLevel": "2", - "guard": "False", - "content": { - "resources": ["vG"], + "OSDF_FRANKFURT.hpa_policy_vG_1": { + "type": "onap.policies.optimization.resource.HpaPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.hpa_policy_vG_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], "identity": "hpa-vG", - "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vG"], - "policyType": "hpa", "flavorFeatures": [ { "id": "vg_1", @@ -28,8 +37,8 @@ ] } ], - "flavorProperties":[ - { + "flavorProperties": [ + { "hpa-feature" : "cpuTopology", "mandatory" : "True", "architecture": "generic", @@ -43,33 +52,64 @@ {"hpa-attribute-key":"numCpuThreads", "hpa-attribute-value": "8", "operator":"<=", "unit": ""} ] }, - { - "hpa-feature" : "basicCapabilities", - "mandatory" : "True", + { + "hpa-feature": "basicCapabilities", + "mandatory": true, "architecture": "generic", "directives": [], "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-attribute-key": "numVirtualCpu", + "hpa-attribute-value": 6, + "operator": [ + "=" + ], + "unit": "" + }, + { + "hpa-attribute-key": "virtualMemSize", + "hpa-attribute-value": 6, + "operator": [ + "=" + ], + "unit": "" + } ] }, { - "hpa-feature" : "ovsDpdk", - "mandatory" : "False", - "score" : "3", + "hpa-feature": "ovsDpdk", + "mandatory": false, + "score": 3, "architecture": "generic", "directives": [], "hpa-feature-attributes": [ - {"hpa-attribute-key":"dataProcessingAccelerationLibrary", "hpa-attribute-value":"ovsDpdk_version", "operator": "=", "unit":""} + { + "hpa-attribute-key": "dataProcessingAccelerationLibrary", + "hpa-attribute-value": "ovsDpdk_version", + "operator": [ + "=" + ], + "unit": "" + } ] }, { - "hpa-feature" : "cpuInstructionSetExtensions", - "mandatory" : "True", + "hpa-feature": "cpuInstructionSetExtensions", + "mandatory": true, "architecture": "INTEL-64", "directives": [], "hpa-feature-attributes": [ - {"hpa-attribute-key":"instructionSetExtensions", "hpa-attribute-value":["<CPUINST>", "<CPUINST>"], "operator": "ALL", "unit":""} + { + "hpa-attribute-key": "instructionSetExtensions", + "hpa-attribute-value": [ + "<CPUINST>", + "<CPUINST>" + ], + "operator": [ + "ALL" + ], + "unit": "" + } ] } ] @@ -99,7 +139,7 @@ {"hpa-attribute-key":"logicalCpuPinningPolicy", "hpa-attribute-value": "<CPUPOLICY>","operator": "=", "unit":""} ] }, - { + { "hpa-feature" : "basicCapabilities", "mandatory" : "True", "architecture": "generic", @@ -132,7 +172,7 @@ {"hpa-attribute-key": "pciDeviceId", "hpa-attribute-value": "2", "operator": "=", "unit": ""} ] } - ] +] }, { "id": "vg_3", @@ -162,7 +202,7 @@ {"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", @@ -187,4 +227,5 @@ } ] } + } } diff --git a/test/policy-local-files/meta-valid-policies-old.txt b/test/policy-local-files/meta-valid-policies-old.txt new file mode 100644 index 0000000..99e3e88 --- /dev/null +++ b/test/policy-local-files/meta-valid-policies-old.txt @@ -0,0 +1,16 @@ +Affinity_vCPE_1.json +Capacity_vGMuxInfra.json +Capacity_vG_1.json +Distance_vGMuxInfra_1.json +Distance_vG_1.json +Placement_Optimization_1.json +QueryPolicy_vCPE.json +QueryPolicy_vCPE_2.json +hpa_policy_vGMuxInfra_1.json +hpa_policy_vG_1.json +vnfPolicy_vG.json +vnfPolicy_vGMuxInfra.json +QueryPolicy_vFW_TD.json +vnfPolicy_vFW_TD.json +vnfPolicy_vPGN_TD.json +affinity_vFW_TD.json
\ No newline at end of file diff --git a/test/policy-local-files/meta-valid-policies.txt b/test/policy-local-files/meta-valid-policies.txt index 772ec1a..5f969bf 100644 --- a/test/policy-local-files/meta-valid-policies.txt +++ b/test/policy-local-files/meta-valid-policies.txt @@ -10,3 +10,8 @@ hpa_policy_vGMuxInfra_1.json hpa_policy_vG_1.json vnfPolicy_vG.json vnfPolicy_vGMuxInfra.json +QueryPolicy_vFW_TD.json +vnfPolicy_vFW_TD.json +vnfPolicy_vPGN_TD.json +Affinity_vFW_TD.json +Attribute_vNS_1.json
\ No newline at end of file diff --git a/test/policy-local-files/nst-selection-files/attribute_policy_nst.json b/test/policy-local-files/nst-selection-files/attribute_policy_nst.json new file mode 100644 index 0000000..0989927 --- /dev/null +++ b/test/policy-local-files/nst-selection-files/attribute_policy_nst.json @@ -0,0 +1,42 @@ +{ + "Threshold_nst": { + "metadata": { + "policy-id": "Threshold_nst", + "policy-version": 1 + }, + "properties": { + "geography": [], + "identity": "nst_Threshold", + "resources": [ + "nst" + ], + "scope": [ + "OSDF_GUILIN" + ], + "services": [ + "nst" + ], + "thresholdProperties": [ + { + "attribute": "latency", + "operator": "lte", + "threshold": { + "get_param": "latency" + }, + "unit": "ms" + }, + { + "attribute": "reliability", + "operator": "gte", + "threshold": { + "get_param": "reliability" + }, + "unit": "" + } + ] + }, + "type": "onap.policies.optimization.resource.ThresholdPolicy", + "type_version": "1.0.0", + "version": "1.0.0" + } +}
\ No newline at end of file diff --git a/test/policy-local-files/nst-selection-files/optimization_policy_nst.json b/test/policy-local-files/nst-selection-files/optimization_policy_nst.json new file mode 100644 index 0000000..27c1f7c --- /dev/null +++ b/test/policy-local-files/nst-selection-files/optimization_policy_nst.json @@ -0,0 +1,37 @@ +{ + "nst_minimize_latency": { + "metadata": { + "policy-id": "nst_minimize_latency", + "policy-version": 1 + }, + "properties": { + "geography": [], + "identity": "optimization", + "goal": "minimize", + "operation_function": { + "operator": "sum", + "operands": [ + { + "function": "attribute", + "params": { + "attribute": "latency", + "demand": "nst" + } + } + ] + }, + "resources": [ + "nst" + ], + "scope": [ + "OSDF_GUILIN" + ], + "services": [ + "nst" + ] + }, + "type": "onap.policies.optimization.resource.OptimizationPolicy", + "type_version": "2.0.0", + "version": "1.0.0" + } +}
\ No newline at end of file diff --git a/test/policy-local-files/nst-selection-files/query_policy_nst.json b/test/policy-local-files/nst-selection-files/query_policy_nst.json new file mode 100644 index 0000000..1955e7b --- /dev/null +++ b/test/policy-local-files/nst-selection-files/query_policy_nst.json @@ -0,0 +1,31 @@ +{ + "queryPolicy_nst": { + "type": "onap.policies.optimization.service.QueryPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "queryPolicy_nst", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_GUILIN" + ], + "services": [ + "nst" + ], + "geography": [], + "identity": "queryPolicy_nst", + "queryProperties": [ + { + "attribute": "latency", + "attribute_location": "latency" + }, + { + "attribute": "reliability", + "attribute_location": "reliability" + } + ] + } + } +}
\ No newline at end of file diff --git a/test/policy-local-files/nst-selection-files/vnf_policy_nst.json b/test/policy-local-files/nst-selection-files/vnf_policy_nst.json new file mode 100644 index 0000000..14906df --- /dev/null +++ b/test/policy-local-files/nst-selection-files/vnf_policy_nst.json @@ -0,0 +1,34 @@ +{ + "vnfPolicy_nst": { + "type": "onap.policies.optimization.resource.VnfPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "vnfPolicy_nst", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_GUILIN" + ], + "resources": [ + "nst" + ], + "services": [ + "nst" + ], + "identity": "vnf_nst", + "applicableResources": "any", + "vnfProperties": [ + { + "inventoryProvider": "aai", + "inventoryType": "nst", + "unique": "true", + "attributes": { + "model-role": "nst" + } + } + ] + } + } +}
\ No newline at end of file diff --git a/test/policy-local-files/old-policies/Affinity_vCPE_1.json b/test/policy-local-files/old-policies/Affinity_vCPE_1.json new file mode 100644 index 0000000..2953589 --- /dev/null +++ b/test/policy-local-files/old-policies/Affinity_vCPE_1.json @@ -0,0 +1,21 @@ +{ + "service": "affinityPolicy", + "policyName": "OSDF_DUBLIN.Affinity_vCPE_1", + "description": "Zone policy for vCPE", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "3", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "identity": "affinity_vCPE", + "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"], + "affinityProperty": { + "qualifier": "same", + "category": "complex" + }, + "policyType": "zone", + "resources": ["vGMuxInfra", "vG"] + } +} diff --git a/test/policy-local-files/old-policies/Attribute_vNS_1.json b/test/policy-local-files/old-policies/Attribute_vNS_1.json new file mode 100644 index 0000000..e4766db --- /dev/null +++ b/test/policy-local-files/old-policies/Attribute_vNS_1.json @@ -0,0 +1,49 @@ +{ + "service": "attributePolicy", + "policyName": "OSDF_FRANKFURT.AttributePolicy_vNS_1", + "description": "Attribute Policy for Network Slicing (NS)", + "templateVersion": "OpenSource.version.1", + "version": "OpenSource.version.1", + "priority": "1", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "attribute-vNS", + "policyScope": [ + "vNS", + "us", + "international", + "ip" + ], + "policyType": "attribute", + "resources": [ + "vNS", + "" + ], + "attributeProperties": { + "cloudRegion": { + "serviceRequests": [ + "", + "" + ], + "cloudRequests": [ + "", + "" + ] + }, + "networkRoles": { + "all": [ + "", + "" + ] + }, + "complex": { + "any": [ + "", + "" + ] + } + } + } +}
\ No newline at end of file diff --git a/test/policy-local-files/Capacity_vFW_1.json b/test/policy-local-files/old-policies/Capacity_vFW_1.json index 3393550..d5e80ab 100644 --- a/test/policy-local-files/Capacity_vFW_1.json +++ b/test/policy-local-files/old-policies/Capacity_vFW_1.json @@ -1,6 +1,6 @@ { "service": "vim_fit", - "policyName": "OSDF_CASABLANCA.Capacity_vFW_1", + "policyName": "OSDF_DUBLIN.Capacity_vFW_1", "description": "Capacity policy for vFW", "templateVersion": "OpenSource.version.1", "version": "test1", diff --git a/test/policy-local-files/old-policies/Capacity_vGMuxInfra.json b/test/policy-local-files/old-policies/Capacity_vGMuxInfra.json new file mode 100644 index 0000000..010cf3f --- /dev/null +++ b/test/policy-local-files/old-policies/Capacity_vGMuxInfra.json @@ -0,0 +1,22 @@ +{ + "service": "vim_fit", + "policyName": "OSDF_DUBLIN.Capacity_vGMuxInfra", + "description": "Capacity policy for vGMuxInfra", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "5", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "identity": "capacity_vGMuxInfra", + "policyScope": ["VCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"], + "resources": ["vGMuxInfra"], + "capacityProperty": { + "controller": "multicloud", + "request": "{\"vCPU\": 10, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"GB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}" + }, + "policyType": "vim_fit", + "applicableResources": "any" + } +} diff --git a/test/policy-local-files/old-policies/Capacity_vG_1.json b/test/policy-local-files/old-policies/Capacity_vG_1.json new file mode 100644 index 0000000..fedcc4f --- /dev/null +++ b/test/policy-local-files/old-policies/Capacity_vG_1.json @@ -0,0 +1,22 @@ +{ + "service": "vim_fit", + "policyName": "OSDF_DUBLIN.Capacity_vG_1", + "description": "Capacity policy for vG", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "5", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "identity": "capacity_vG", + "policyScope": ["VCPE", "US", "INTERNATIONAL", "ip", "vG"], + "resources": ["vG"], + "capacityProperty": { + "controller": "multicloud", + "request": "{\"vCPU\": 10, \"Memory\": {\"quantity\": {\"get_param\": \"REQUIRED_MEM\"}, \"unit\": \"GB\"}, \"Storage\": {\"quantity\": {\"get_param\": \"REQUIRED_DISK\"}, \"unit\": \"GB\"}}" + }, + "policyType": "vim_fit", + "applicableResources": "any" + } +} diff --git a/test/policy-local-files/Distance_vFW_1.json b/test/policy-local-files/old-policies/Distance_vFW_1.json index f6cb198..80e08d9 100644 --- a/test/policy-local-files/Distance_vFW_1.json +++ b/test/policy-local-files/old-policies/Distance_vFW_1.json @@ -1,6 +1,6 @@ { "service": "distancePolicy", - "policyName": "OSDF_CASABLANCA.Distance_vFW_1", + "policyName": "OSDF_DUBLIN.Distance_vFW_1", "description": "Distance Policy for vFW", "templateVersion": "OpenSource.version.1", "version": "test1", diff --git a/test/policy-local-files/old-policies/Distance_vGMuxInfra_1.json b/test/policy-local-files/old-policies/Distance_vGMuxInfra_1.json new file mode 100644 index 0000000..e3ba83c --- /dev/null +++ b/test/policy-local-files/old-policies/Distance_vGMuxInfra_1.json @@ -0,0 +1,22 @@ +{ + "service": "distancePolicy", + "policyName": "OSDF_DUBLIN.Distance_vGMuxInfra", + "description": "Distance Policy for vGMuxInfra", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "3", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "distanceProperties": { + "locationInfo": "customer_loc", + "distance": { "value": "500", "operator": "<", "unit": "km" } + }, + "identity": "distance-vGMuxInfra", + "resources": ["vGMuxInfra"], + "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"], + "policyType": "distance_to_location", + "applicableResources": "any" + } +} diff --git a/test/policy-local-files/old-policies/Distance_vG_1.json b/test/policy-local-files/old-policies/Distance_vG_1.json new file mode 100644 index 0000000..c498c7a --- /dev/null +++ b/test/policy-local-files/old-policies/Distance_vG_1.json @@ -0,0 +1,22 @@ +{ + "service": "distancePolicy", + "policyName": "OSDF_DUBLIN.Distance_vG_1", + "description": "Distance Policy for vG", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "3", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "distanceProperties": { + "locationInfo": "customer_loc", + "distance": { "value": "1500", "operator": "<", "unit": "km" } + }, + "identity": "distance-vG", + "resources": ["vG"], + "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vG"], + "policyType": "distance_to_location", + "applicableResources": "any" + } +} diff --git a/test/policy-local-files/old-policies/Placement_Optimization_1.json b/test/policy-local-files/old-policies/Placement_Optimization_1.json new file mode 100644 index 0000000..9b062b0 --- /dev/null +++ b/test/policy-local-files/old-policies/Placement_Optimization_1.json @@ -0,0 +1,55 @@ +{ + "service": "optimizationPolicy", + "policyName": "OSDF_DUBLIN.Placement_Optimization_1", + "description": "Placement Optimization Policy for vGMuxInfra", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "5", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "objectiveParameter": { + "parameterAttributes": [ + { + "resources": ["vGMuxInfra"], + "customerLocationInfo": "customer_loc", + "parameter": "distance", + "weight": "1", + "operator": "product" + }, + { + "resources": ["vG"], + "customerLocationInfo": "customer_loc", + "parameter": "distance", + "weight": "1", + "operator": "product" + }, + { + "resources": ["vG"], + "parameter": "hpa_score", + "weight": "200", + "operator": "product" + }, + { + "resources": ["vFW"], + "customerLocationInfo": "customer_loc", + "parameter": "distance", + "weight": "100", + "operator": "product" + }, + { + "resources": ["vFW"], + "parameter": "hpa_score", + "weight": "200", + "operator": "product" + } + ], + "operator": "sum" + }, + "identity": "optimization", + "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"], + "policyType": "placement_optimization", + "objective": "minimize" + } +} diff --git a/test/policy-local-files/old-policies/QueryPolicy_vCPE.json b/test/policy-local-files/old-policies/QueryPolicy_vCPE.json new file mode 100644 index 0000000..5097964 --- /dev/null +++ b/test/policy-local-files/old-policies/QueryPolicy_vCPE.json @@ -0,0 +1,21 @@ +{ + "service": "queryPolicy", + "policyName": "OSDF_DUBLIN.QueryPolicy_vCPE", + "description": "Query policy for vCPE", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "3", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "queryProperties": [ + {"attribute":"customerLatitude", "attribute_location": "customerLatitude"}, + {"attribute":"customerLongitude", "attribute_location": "customerLongitude"} + ], + "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"], + "policyType": "request_param_query", + "serviceName": "vCPE", + "identity": "vCPE_Query_Policy" + } +} diff --git a/test/policy-local-files/old-policies/QueryPolicy_vCPE_2.json b/test/policy-local-files/old-policies/QueryPolicy_vCPE_2.json new file mode 100644 index 0000000..e398f39 --- /dev/null +++ b/test/policy-local-files/old-policies/QueryPolicy_vCPE_2.json @@ -0,0 +1,24 @@ +{ + "service": "queryPolicy", + "policyName": "OSDF_DUBLIN.queryPolicy_vCPE", + "description": "Query policy for vCPE", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "3", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "queryProperties": [ + {"attribute":"locationId", "attribute_location": "customerLocation", "value": ""}, + {"attribute":"id", "attribute_location": "vpnInfo.vpnId", "value": ""}, + {"attribute":"upstreamBW", "attribute_location": "vpnInfo.upstreamBW", "value": ""}, + {"attribute":"customerLatitude", "attribute_location": "customerLatitude", "value": 1.1}, + {"attribute":"customerLongitude", "attribute_location": "customerLongitude", "value": 2.2} + ], + "serviceName": "vCPE", + "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"], + "policyType": "request_param_query", + "identity": "vCPE_Query_Policy" + } +} diff --git a/test/policy-local-files/QueryPolicy_vFW.json b/test/policy-local-files/old-policies/QueryPolicy_vFW.json index 443a82a..932074b 100644 --- a/test/policy-local-files/QueryPolicy_vFW.json +++ b/test/policy-local-files/old-policies/QueryPolicy_vFW.json @@ -1,6 +1,6 @@ { "service": "queryPolicy", - "policyName": "OSDF_CASABLANCA.QueryPolicy_vFW", + "policyName": "OSDF_DUBLIN.QueryPolicy_vFW", "description": "Query policy for vFW", "templateVersion": "OpenSource.version.1", "version": "test1", diff --git a/test/policy-local-files/old-policies/QueryPolicy_vFW_TD.json b/test/policy-local-files/old-policies/QueryPolicy_vFW_TD.json new file mode 100644 index 0000000..8866635 --- /dev/null +++ b/test/policy-local-files/old-policies/QueryPolicy_vFW_TD.json @@ -0,0 +1,32 @@ +{ + "service": "queryPolicy", + "policyName": "OSDF_DUBLIN.QueryPolicy_vFW_TD", + "description": "Query policy for vFW TD", + "templateVersion": "OpenSource.version.1", + "version": "oofDublin", + "priority": "3", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "queryProperties": [ + {"attribute":"customerLatitude", "attribute_location": "customerLatitude", "value": 1.1}, + {"attribute":"customerLongitude", "attribute_location": "customerLongitude", "value": 2.2}, + {"attribute":"chosen_region", "attribute_location": "chosenRegion"}, + {"attribute":"chosen_customer_id", "attribute_location": "chosenCustomerId"} + ], + "policyScope": [ + "td", + "us", + "vFW-SINK", + "vPGN" + ], + "policyType": "request_param_query", + "serviceName": "vFW_TD", + "identity": "vFW_TD_Query_Policy", + "resources": [ + "vFW-SINK", + "vPGN" + ] + } +} diff --git a/test/policy-local-files/old-policies/affinity_vFW_TD.json b/test/policy-local-files/old-policies/affinity_vFW_TD.json new file mode 100644 index 0000000..2df2d50 --- /dev/null +++ b/test/policy-local-files/old-policies/affinity_vFW_TD.json @@ -0,0 +1,29 @@ +{ + "service": "affinityPolicy", + "policyName": "OSDF_DUBLIN.Affinity_vFW_TD", + "description": "Affinity policy for vPGN Anchor and vFW destination point", + "templateVersion": "OpenSource.version.1", + "version": "oofDublin", + "priority": "3", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "identity": "affinity_vFW_TD", + "policyScope": [ + "td", + "us", + "vFW-SINK", + "vPGN" + ], + "affinityProperty": { + "qualifier": "same", + "category": "region" + }, + "policyType": "zone", + "resources": [ + "vFW-SINK", + "vPGN" + ] + } +}
\ No newline at end of file diff --git a/test/policy-local-files/hpa_policy_vFW_1.json b/test/policy-local-files/old-policies/hpa_policy_vFW_1.json index 4a81dc3..a60ad47 100644 --- a/test/policy-local-files/hpa_policy_vFW_1.json +++ b/test/policy-local-files/old-policies/hpa_policy_vFW_1.json @@ -1,6 +1,6 @@ { "service": "hpaPolicy", - "policyName": "OSDF_CASABLANCA.hpa_policy_vFW_1", + "policyName": "OSDF_DUBLIN.hpa_policy_vFW_1", "description": "HPA policy for vFW", "templateVersion": "OpenSource.version.1", "version": "test1", diff --git a/test/policy-local-files/old-policies/hpa_policy_vGMuxInfra_1.json b/test/policy-local-files/old-policies/hpa_policy_vGMuxInfra_1.json new file mode 100644 index 0000000..690f5dc --- /dev/null +++ b/test/policy-local-files/old-policies/hpa_policy_vGMuxInfra_1.json @@ -0,0 +1,191 @@ +{ + "service": "hpaPolicy", + "policyName": "OSDF_DUBLIN.hpa_policy_vGMuxInfra_1", + "description": "HPA policy for vGMuxInfra", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "3", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "resources": ["vGMuxInfra"], + "identity": "hpa-vGMuxInfra", + "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"], + "policyType": "hpa", + "flavorFeatures": [ + { + "id": "vgmux_1", + "type": "vnfc", + "directives": [ + { + "type": "flavor_directives", + "attributes": [ + { + "attribute_name": "flavor_label_vm_01", + "attribute_value": "" + } + ] + } + ], + "flavorProperties":[ + { + "hpa-feature" : "cpuTopology", + "mandatory" : "True", + "architecture": "generic", + "directives": [], + "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", + "directives": [], + "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", + "directives": [], + "hpa-feature-attributes": [ + {"hpa-attribute-key":"dataProcessingAccelerationLibrary", "hpa-attribute-value":"ovsDpdk_version", "operator": "=", "unit":""} + ] + }, + { + "hpa-feature" : "cpuInstructionSetExtensions", + "mandatory" : "True", + "architecture": "INTEL-64", + "directives": [], + "hpa-feature-attributes": [ + {"hpa-attribute-key":"instructionSetExtensions", "hpa-attribute-value":["<CPUINST>", "<CPUINST>"], "operator": "ALL", "unit":""} + ] + } + ] + }, + { + "id": "vgmux_2", + "type": "vnfc", + "directives": [ + { + "type": "flavor_directives", + "attributes": [ + { + "attribute_name": "flavor_label_vm_02", + "attribute_value": "" + } + ] + } + ], + "flavorProperties":[ + { + "hpa-feature" : "cpuPinningy", + "mandatory" : "True", + "architecture": "generic", + "directives": [], + "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", + "directives": [], + "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", + "directives": [], + "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", + "directives": [], + "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": ""} + ] + } + ] + }, + { + "id": "vgmux_3", + "type": "vnfc", + "directives": [ + { + "type": "flavor_directives", + "attributes": [ + { + "attribute_name": "flavor_label_vm_03", + "attribute_value": "" + } + ] + } + ], + "flavorProperties":[ + { + "hpa-feature" : "numa", + "mandatory" : "False", + "score" : "5", + "architecture": "generic", + "directives": [], + "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", + "directives": [], + "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", + "directives": [], + "hpa-feature-attributes": [ + {"hpa-attribute-key": "memoryPageSize", "hpa-attribute-value": "<MEMORYPAGESIZE>", "operator": "=", "unit": ""} + ] + } + ] + } + ] + } +} diff --git a/test/policy-local-files/old-policies/hpa_policy_vG_1.json b/test/policy-local-files/old-policies/hpa_policy_vG_1.json new file mode 100644 index 0000000..b29c67d --- /dev/null +++ b/test/policy-local-files/old-policies/hpa_policy_vG_1.json @@ -0,0 +1,190 @@ +{ + "service": "hpaPolicy", + "policyName": "OSDF_DUBLIN.hpa_policy_vG_1", + "description": "HPA policy for vG", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "3", + "riskType": "test", + "riskLevel": "2", + "guard": "False", + "content": { + "resources": ["vG"], + "identity": "hpa-vG", + "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vG"], + "policyType": "hpa", + "flavorFeatures": [ + { + "id": "vg_1", + "type": "vnfc", + "directives": [ + { + "type": "flavor_directives", + "attributes": [ + { + "attribute_name": "flavor_label_vm_01", + "attribute_value": "" + } + ] + } + ], + "flavorProperties":[ + { + "hpa-feature" : "cpuTopology", + "mandatory" : "True", + "architecture": "generic", + "directives": [], + "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", + "directives": [], + "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", + "directives": [], + "hpa-feature-attributes": [ + {"hpa-attribute-key":"dataProcessingAccelerationLibrary", "hpa-attribute-value":"ovsDpdk_version", "operator": "=", "unit":""} + ] + }, + { + "hpa-feature" : "cpuInstructionSetExtensions", + "mandatory" : "True", + "architecture": "INTEL-64", + "directives": [], + "hpa-feature-attributes": [ + {"hpa-attribute-key":"instructionSetExtensions", "hpa-attribute-value":["<CPUINST>", "<CPUINST>"], "operator": "ALL", "unit":""} + ] + } + ] + }, + { + "id": "vg_2", + "type": "vnfc", + "directives": [ + { + "type": "flavor_directives", + "attributes": [ + { + "attribute_name": "flavor_label_vm_02", + "attribute_value": "" + } + ] + } + ], + "flavorProperties":[ + { + "hpa-feature" : "cpuPinningy", + "mandatory" : "True", + "architecture": "generic", + "directives": [], + "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", + "directives": [], + "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", + "directives": [], + "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" : "pciePassthrough", + "mandatory" : "True", + "architecture": "generic", + "directives": [], + "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": ""} + ] + } + ] + }, + { + "id": "vg_3", + "type": "vnfc", + "directives": [ + { + "type": "flavor_directives", + "attributes": [ + { + "attribute_name": "flavor_label_vm_03", + "attribute_value": "" + } + ] + } + ], + "flavorProperties":[ + { + "hpa-feature" : "numa", + "mandatory" : "False", + "score" : "5", + "architecture": "generic", + "directives": [], + "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", + "directives": [], + "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", + "directives": [], + "hpa-feature-attributes": [ + {"hpa-attribute-key": "memoryPageSize", "hpa-attribute-value": "<MEMORYPAGESIZE>", "operator": "=", "unit": ""} + ] + } + ] + } + ] + } +} diff --git a/test/policy-local-files/old-policies/subscriber_policy_vCPE.json b/test/policy-local-files/old-policies/subscriber_policy_vCPE.json new file mode 100644 index 0000000..9359c20 --- /dev/null +++ b/test/policy-local-files/old-policies/subscriber_policy_vCPE.json @@ -0,0 +1,22 @@ +{ + "service": "subscriberPolicy", + "policyName": "OSDF_DUBLIN.SubscriberPolicy_v1", + "description": "Subscriber Policy for vCPE", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "1", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "subscriber_vCPE", + "policyScope": ["vCPE", "subscriber_x", "subscriber_y", "subscriberPolicy"], + "properties": { + "subscriberName": ["subscriber_x", "subscriber_y"], + "subscriberRole": ["PVT Homing"], + "provStatus": ["CAPPED"] + }, + "policyType": "subscriberPolicy", + "serviceName": "vCPE" + } +} diff --git a/test/policy-local-files/subscriber_policy_vFW.json b/test/policy-local-files/old-policies/subscriber_policy_vFW.json index 38e615c..299da04 100644 --- a/test/policy-local-files/subscriber_policy_vFW.json +++ b/test/policy-local-files/old-policies/subscriber_policy_vFW.json @@ -1,6 +1,6 @@ { "service": "subscriberPolicy", - "policyName": "OSDF_CASABLANCA.SubscriberPolicy_v1", + "policyName": "OSDF_DUBLIN.SubscriberPolicy_v1", "description": "Subscriber Policy for VFW", "templateVersion": "OpenSource.version.1", "version": "test1", diff --git a/test/policy-local-files/vnfPolicy_vFW.json b/test/policy-local-files/old-policies/vnfPolicy_vFW.json index a29d927..0b7d9a2 100644 --- a/test/policy-local-files/vnfPolicy_vFW.json +++ b/test/policy-local-files/old-policies/vnfPolicy_vFW.json @@ -1,6 +1,6 @@ { "service": "vnfPolicy", - "policyName": "OSDF_CASABLANCA.vnfPolicy_vFW", + "policyName": "OSDF_DUBLIN.vnfPolicy_vFW", "description": "vnfPolicy", "templateVersion": "OpenSource.version.1", "version": "test1", diff --git a/test/policy-local-files/old-policies/vnfPolicy_vFW_TD.json b/test/policy-local-files/old-policies/vnfPolicy_vFW_TD.json new file mode 100644 index 0000000..a471a77 --- /dev/null +++ b/test/policy-local-files/old-policies/vnfPolicy_vFW_TD.json @@ -0,0 +1,44 @@ +{ + "service": "vnfPolicy", + "policyName": "OSDF_DUBLIN.vnfPolicy_vFW_TD", + "description": "vnfPolicy", + "templateVersion": "OpenSource.version.1", + "version": "oofDublin", + "priority": "6", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "vnf_vFW_TD", + "policyScope": [ + "td", + "us", + "vFW-SINK" + ], + "policyType": "vnfPolicy", + "resources": ["vFW-SINK"], + "applicableResources": "any", + "vnfProperties": [{ + "inventoryProvider": "aai", + "serviceType": "", + "inventoryType": "vfmodule", + "customerId": { + "get_param": "chosen_customer_id" + }, + "equipmentRole": "", + "attributes": { + "orchestrationStatus": ["active"], + "provStatus": "ACTIVE", + "cloudRegionId": { + "get_param": "chosen_region" + }, + "service_instance_id": { + "get_param": "service_id" + } + }, + "passthroughAttributes": { + "td-role": "destination" + } + }] + } +} diff --git a/test/policy-local-files/old-policies/vnfPolicy_vG.json b/test/policy-local-files/old-policies/vnfPolicy_vG.json new file mode 100644 index 0000000..b047686 --- /dev/null +++ b/test/policy-local-files/old-policies/vnfPolicy_vG.json @@ -0,0 +1,29 @@ +{ + "service": "vnfPolicy", + "policyName": "OSDF_DUBLIN.vnfPolicy_vG", + "description": "vnfPolicy", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "6", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "vnf_vG", + "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vG"], + "policyType": "vnfPolicy", + "resources": ["vG"], + "applicableResources": "any", + "vnfProperties": [ + { + "inventoryProvider": "aai", + "serviceType": "", + "inventoryType": "cloud", + "customerId": "", + "orchestrationStatus": "", + "equipmentRole": "" + + } + ] + } +} diff --git a/test/policy-local-files/old-policies/vnfPolicy_vGMuxInfra.json b/test/policy-local-files/old-policies/vnfPolicy_vGMuxInfra.json new file mode 100644 index 0000000..45d67f6 --- /dev/null +++ b/test/policy-local-files/old-policies/vnfPolicy_vGMuxInfra.json @@ -0,0 +1,28 @@ +{ + "service": "vnfPolicy", + "policyName": "OSDF_DUBLIN.vnfPolicy_vGMuxInfra", + "description": "vnfPolicy", + "templateVersion": "OpenSource.version.1", + "version": "test1", + "priority": "6", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "vnf_vGMuxInfra", + "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"], + "policyType": "vnfPolicy", + "resources": ["vGMuxInfra"], + "applicableResources": "any", + "vnfProperties": [ + { + "inventoryProvider": "aai", + "serviceType": "vGMuxInfra-xx", + "inventoryType": "service", + "customerId": "SDN-ETHERNET-INTERNET", + "orchestrationStatus": "", + "equipmentRole": "" + } + ] + } +} diff --git a/test/policy-local-files/old-policies/vnfPolicy_vPGN_TD.json b/test/policy-local-files/old-policies/vnfPolicy_vPGN_TD.json new file mode 100644 index 0000000..2e79f2f --- /dev/null +++ b/test/policy-local-files/old-policies/vnfPolicy_vPGN_TD.json @@ -0,0 +1,51 @@ +{ + "service": "vnfPolicy", + "policyName": "OSDF_DUBLIN.vnfPolicy_vPGN_TD", + "description": "vnfPolicy", + "templateVersion": "OpenSource.version.1", + "version": "oofDublin", + "priority": "6", + "riskType": "test", + "riskLevel": "3", + "guard": "False", + "content": { + "identity": "vnf_vPGN_TD", + "policyScope": [ + "td", + "us", + "vPGN" + ], + "policyType": "vnfPolicy", + "resources": [ + "vPGN" + ], + "applicableResources": "any", + "vnfProperties": [ + { + "inventoryProvider": "aai", + "serviceType": "", + "inventoryType": "vfmodule", + "customerId": { + "get_param": "chosen_customer_id" + }, + "equipmentRole": "", + "unique": "False", + "attributes": { + "orchestrationStatus": [ + "active" + ], + "provStatus": "ACTIVE", + "cloudRegionId": { + "get_param": "chosen_region" + }, + "service_instance_id": { + "get_param": "service_id" + } + }, + "passthroughAttributes": { + "td-role": "anchor" + } + } + ] + } +}
\ No newline at end of file diff --git a/test/policy-local-files/queryPolicy_URLLC_.json b/test/policy-local-files/queryPolicy_URLLC_.json new file mode 100644 index 0000000..3114234 --- /dev/null +++ b/test/policy-local-files/queryPolicy_URLLC_.json @@ -0,0 +1,29 @@ +{ + "OSDF_FRANKFURT.queryPolicy_URLLC_1": { + "type": "onap.policies.optimization.service.QueryPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.queryPolicy_URLLC_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "URLLC_1" + ], + "geography": [ + "US" + ], + "identity": "queryPolicy_URLLC_1", + "queryProperties": [ + { + "attribute": "latency", + "attribute_location": "latency" + } + ] + } + } +} diff --git a/test/policy-local-files/slice-selection-files/opt_policy_nsi_reuse.json b/test/policy-local-files/slice-selection-files/opt_policy_nsi_reuse.json new file mode 100644 index 0000000..fa02d4e --- /dev/null +++ b/test/policy-local-files/slice-selection-files/opt_policy_nsi_reuse.json @@ -0,0 +1,37 @@ +{ + "OSDF_FRANKFURT.minimizeCost_URLLC": { + "metadata": { + "policy-id": "OSDF_FRANKFURT.minimizeCost_URLLC", + "policy-version": 1 + }, + "properties": { + "geography": [], + "identity": "optimization", + "goal": "minimize", + "operation_function": { + "operator": "sum", + "operands": [ + { + "function": "attribute", + "params": { + "attribute": "creation_cost", + "demand": "embb-nst" + } + } + ] + }, + "resources": [ + "embb-nst" + ], + "scope": [ + "shared,reuse" + ], + "services": [ + "embb-nst" + ] + }, + "type": "onap.policies.optimization.resource.OptimizationPolicy", + "type_version": "2.0.0", + "version": "1.0.0" + } +} diff --git a/test/policy-local-files/slice-selection-files/opt_policy_nssi.json b/test/policy-local-files/slice-selection-files/opt_policy_nssi.json new file mode 100644 index 0000000..196add0 --- /dev/null +++ b/test/policy-local-files/slice-selection-files/opt_policy_nssi.json @@ -0,0 +1,37 @@ +{ + "OSDF_FRANKFURT.minimizeCost_URLLC": { + "metadata": { + "policy-id": "OSDF_FRANKFURT.minimizeCost_URLLC", + "policy-version": 1 + }, + "properties": { + "geography": [], + "identity": "optimization", + "goal": "minimize", + "operation_function": { + "operator": "sum", + "operands": [ + { + "function": "attribute", + "params": { + "attribute": "latency", + "demand": "embb-cn" + } + } + ] + }, + "resources": [ + "embb-cn" + ], + "scope": [ + "OSDF_GUILIN" + ], + "services": [ + "embb-cn" + ] + }, + "type": "onap.policies.optimization.resource.OptimizationPolicy", + "type_version": "2.0.0", + "version": "1.0.0" + } +} diff --git a/test/policy-local-files/slice-selection-files/query_policy_nsi.json b/test/policy-local-files/slice-selection-files/query_policy_nsi.json new file mode 100644 index 0000000..c370ccd --- /dev/null +++ b/test/policy-local-files/slice-selection-files/query_policy_nsi.json @@ -0,0 +1,54 @@ + + { + "OSDF_GUILIN.queryPolicy_URLLC":{ + "type":"onap.policies.optimization.service.QueryPolicy", + "version":"1.0.0", + "type_version":"1.0.0", + "metadata":{ + "policy-id":"OSDF_GUILIN.queryPolicy_URLLC", + "policy-version":1 + }, + "properties":{ + "scope":[ + "shared,reuse", + "shared,create_new", + "not-shared" + ], + "services":[ + "embb-nst" + ], + "geography":[], + "identity":"queryPolicy_URLLC", + "queryProperties":[ + { + "attribute":"latency", + "attribute_location":"latency" + }, + { + "attribute":"reliability", + "attribute_location":"reliability" + }, + { + "attribute":"an_latency", + "attribute_location":"an_latency" + }, + { + "attribute":"cn_latency", + "attribute_location":"cn_latency" + }, + { + "attribute":"tn_bh_latency", + "attribute_location":"tn_bh_latency" + }, + { + "attribute":"model_invariant_id", + "attribute_location":"invariantUUID" + }, + { + "attribute":"model_version_id", + "attribute_location":"UUID" + } + ] + } + } + } diff --git a/test/policy-local-files/slice-selection-files/query_policy_nssi.json b/test/policy-local-files/slice-selection-files/query_policy_nssi.json new file mode 100644 index 0000000..c1e941f --- /dev/null +++ b/test/policy-local-files/slice-selection-files/query_policy_nssi.json @@ -0,0 +1,40 @@ + + { + "OSDF_GUILIN.queryPolicy_URLLC":{ + "type":"onap.policies.optimization.service.QueryPolicy", + "version":"1.0.0", + "type_version":"1.0.0", + "metadata":{ + "policy-id":"OSDF_GUILIN.queryPolicy_URLLC", + "policy-version":1 + }, + "properties":{ + "scope":[ + "OSDF_GUILIN" + ], + "services":[ + "embb-cn" + ], + "geography":[], + "identity":"queryPolicy_URLLC", + "queryProperties":[ + { + "attribute":"latency", + "attribute_location":"latency" + }, + { + "attribute":"reliability", + "attribute_location":"reliability" + }, + { + "attribute":"model_invariant_id", + "attribute_location":"invariantUUID" + }, + { + "attribute":"model_version_id", + "attribute_location":"UUID" + } + ] + } + } + } diff --git a/test/policy-local-files/slice-selection-files/threshold_policy_nsi.json b/test/policy-local-files/slice-selection-files/threshold_policy_nsi.json new file mode 100644 index 0000000..8769641 --- /dev/null +++ b/test/policy-local-files/slice-selection-files/threshold_policy_nsi.json @@ -0,0 +1,48 @@ + + { + "OSDF_GUILIN.Threshold_URLLC":{ + "metadata":{ + "policy-id":"OSDF_GUILIN.Threshold_URLLC", + "policy-version":1 + }, + "properties":{ + "geography":[ + + ], + "identity":"Threshold_URLLC", + "resources":[ + "embb-nst" + ], + "scope":[ + "shared,reuse", + "shared,create_new", + "not-shared" + ], + "services":[ + "embb-nst" + ], + "thresholdProperties":[ + { + "attribute":"latency", + "operator":"lte", + "threshold":{ + "get_param":"latency" + }, + "unit":"ms" + }, + { + "attribute":"reliability", + "operator":"gte", + "threshold":{ + "get_param":"reliability" + }, + "unit":"" + } + ] + }, + "type":"onap.policies.optimization.resource.ThresholdPolicy", + "type_version":"1.0.0", + "version":"1.0.0" + } + } + diff --git a/test/policy-local-files/slice-selection-files/threshold_policy_nssi.json b/test/policy-local-files/slice-selection-files/threshold_policy_nssi.json new file mode 100644 index 0000000..bf8690f --- /dev/null +++ b/test/policy-local-files/slice-selection-files/threshold_policy_nssi.json @@ -0,0 +1,46 @@ + + { + "OSDF_GUILIN.Threshold_URLLC":{ + "metadata":{ + "policy-id":"OSDF_GUILIN.Threshold_URLLC", + "policy-version":1 + }, + "properties":{ + "geography":[ + + ], + "identity":"Threshold_URLLC", + "resources":[ + "embb-cn" + ], + "scope":[ + "OSDF_GUILIN" + ], + "services":[ + "embb-cn" + ], + "thresholdProperties":[ + { + "attribute":"latency", + "operator":"lte", + "threshold":{ + "get_param":"latency" + }, + "unit":"ms" + }, + { + "attribute":"reliability", + "operator":"gte", + "threshold":{ + "get_param":"reliability" + }, + "unit":"" + } + ] + }, + "type":"onap.policies.optimization.resource.ThresholdPolicy", + "type_version":"1.0.0", + "version":"1.0.0" + } + } + diff --git a/test/policy-local-files/slice-selection-files/vnf_policy_nsi_non_shared_case.json b/test/policy-local-files/slice-selection-files/vnf_policy_nsi_non_shared_case.json new file mode 100644 index 0000000..09aba6e --- /dev/null +++ b/test/policy-local-files/slice-selection-files/vnf_policy_nsi_non_shared_case.json @@ -0,0 +1,81 @@ + + { + "OSDF_GUILIN.vnfPolicy_URLLC":{ + "metadata":{ + "policy-id":"OSDF_GUILIN.vnfPolicy_URLLC", + "policy-version":1 + }, + "properties":{ + "identity":"vnf_URLLC", + "resources":["embb-nst"], + "scope":[ + "not-shared" + ], + "services":[ + "embb-nst" + ], + "geography":[], + "vnfProperties":[ + { + "attributes":{ + "service_profile": { + "latency": {"value": {"get_param": "latency"}, "operator": "lte"}, + "reliability": {"value": {"get_param": "reliability"}, "operator": "gte"} + }, + "subnets": { + "core":{ + "latency":{ + "max":{"get_param":"latency"}, + "min":{"get_param":"cn_latency"}, + "steps":1 + }, + "reliability":{ + "values":[ + 99.9, + 99.999 + ] + } + }, + "ran":{ + "latency":{ + "max":{"get_param":"latency"}, + "min":{"get_param":"an_latency"}, + "steps":1 + }, + "reliability":{ + "values":[ + 99.9, + 99.9 + ] + } + }, + "transport":{ + "latency":{ + "max":{"get_param":"latency"}, + "min":{"get_param":"tn_bh_latency"}, + "steps":1 + }, + "reliability":{ + "values":[ + 99.9, + 99.99 + ] + } + } + } + }, + "inventoryProvider":"generator", + "inventoryType":"slice_profiles", + "unique":"true", + "defaultAttributes":{ + "creation-cost" : 0.9 + } + } + ] + }, + "type":"onap.policies.optimization.resource.VnfPolicy", + "type_version":"1.0.0", + "version":"1.0.0" + } + } + diff --git a/test/policy-local-files/slice-selection-files/vnf_policy_nsi_shared_case.json b/test/policy-local-files/slice-selection-files/vnf_policy_nsi_shared_case.json new file mode 100644 index 0000000..0446748 --- /dev/null +++ b/test/policy-local-files/slice-selection-files/vnf_policy_nsi_shared_case.json @@ -0,0 +1,96 @@ + + { + "OSDF_GUILIN.vnfPolicy_URLLC":{ + "metadata":{ + "policy-id":"OSDF_GUILIN.vnfPolicy_URLLC", + "policy-version":1 + }, + "properties":{ + "identity":"vnf_URLLC", + "resources":["embb-nst"], + "scope":[ + "shared,reuse", + "shared,create_new" + ], + "services":[ + "embb-nst" + ], + "geography":[], + "vnfProperties":[ + { + "attributes":{ + "modelInvariantId":{"get_param":"model_invariant_id"}, + "modelVersionId":{"get_param":"model_version_id"}, + "environment-context":"shared", + "service-role":"nsi" + }, + "inventoryProvider":"aai", + "inventoryType":"nsi", + "unique":"true", + "defaultAttributes":{ + "creation-cost" : 0.1 + } + }, + { + "attributes":{ + "service_profile": { + "latency": {"value": {"get_param": "latency"}, "operator": "lte"}, + "reliability": {"value": {"get_param": "reliability"}, "operator": "gte"} + }, + "subnets": { + "core":{ + "latency":{ + "max":{"get_param":"latency"}, + "min":{"get_param":"cn_latency"}, + "steps":1 + }, + "reliability":{ + "values":[ + 99.9, + 99.999 + ] + } + }, + "ran":{ + "latency":{ + "max":{"get_param":"latency"}, + "min":{"get_param":"an_latency"}, + "steps":1 + }, + "reliability":{ + "values":[ + 99.9, + 99.9 + ] + } + }, + "transport":{ + "latency":{ + "max":{"get_param":"latency"}, + "min":{"get_param":"tn_bh_latency"}, + "steps":1 + }, + "reliability":{ + "values":[ + 99.9, + 99.99 + ] + } + } + } + }, + "inventoryProvider":"generator", + "inventoryType":"slice_profiles", + "unique":"true", + "defaultAttributes":{ + "creation-cost" : 0.9 + } + } + ] + }, + "type":"onap.policies.optimization.resource.VnfPolicy", + "type_version":"1.0.0", + "version":"1.0.0" + } + } + diff --git a/test/policy-local-files/slice-selection-files/vnf_policy_nssi_shared.json b/test/policy-local-files/slice-selection-files/vnf_policy_nssi_shared.json new file mode 100644 index 0000000..b5c81d1 --- /dev/null +++ b/test/policy-local-files/slice-selection-files/vnf_policy_nssi_shared.json @@ -0,0 +1,37 @@ + + { + "OSDF_GUILIN.vnfPolicy_URLLC":{ + "metadata":{ + "policy-id":"OSDF_GUILIN.vnfPolicy_URLLC", + "policy-version":1 + }, + "properties":{ + "identity":"vnf_URLLC", + "resources":["embb-cn"], + "scope":[ + "OSDF_GUILIN" + ], + "services":[ + "embb-cn" + ], + "geography":[], + "vnfProperties":[ + { + "attributes":{ + "modelInvariantId":{"get_param":"model_invariant_id"}, + "modelVersionId":{"get_param":"model_version_id"}, + "environment-context":"shared", + "service-role":"nssi" + }, + "inventoryProvider":"aai", + "inventoryType":"nssi", + "unique":"true" + } + ] + }, + "type":"onap.policies.optimization.resource.VnfPolicy", + "type_version":"1.0.0", + "version":"1.0.0" + } + } + diff --git a/test/policy-local-files/subscriber_policy_URLLC_1.json b/test/policy-local-files/subscriber_policy_URLLC_1.json new file mode 100644 index 0000000..d147273 --- /dev/null +++ b/test/policy-local-files/subscriber_policy_URLLC_1.json @@ -0,0 +1,26 @@ +{ + "OSDF_FRANKFURT.SubscriberPolicy_URLLC_1": { + "type": "onap.policies.optimization.service.SubscriberPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.SubscriberPolicy_URLLC_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "URLLC_1" + ], + "services": [ + "URLLC_1" + ], + "identity": "subscriber_URLLC_1", + "properties": { + "subscriberName": [ + "URLLC_Core_1" + ] + } + } +} +} diff --git a/test/policy-local-files/subscriber_policy_vCPE.json b/test/policy-local-files/subscriber_policy_vCPE.json index bd56dfc..c02d8d6 100644 --- a/test/policy-local-files/subscriber_policy_vCPE.json +++ b/test/policy-local-files/subscriber_policy_vCPE.json @@ -1,22 +1,32 @@ { - "service": "subscriberPolicy", - "policyName": "OSDF_CASABLANCA.SubscriberPolicy_v1", - "description": "Subscriber Policy for vCPE", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "1", - "riskType": "test", - "riskLevel": "3", - "guard": "False", - "content": { - "identity": "subscriber_vCPE", - "policyScope": ["vCPE", "subscriber_x", "subscriber_y", "subscriberPolicy"], - "properties": { - "subscriberName": ["subscriber_x", "subscriber_y"], - "subscriberRole": ["PVT Homing"], - "provStatus": ["CAPPED"] - }, - "policyType": "subscriberPolicy", - "serviceName": "vCPE" + "OSDF_FRANKFURT.SubscriberPolicy_v1": { + "type": "onap.policies.optimization.service.SubscriberPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.SubscriberPolicy_v1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "identity": "subscriber_vCPE", + "properties": { + "subscriberName": [ + "subscriber_x", + "subscriber_y" + ], + "subscriberRole": [ + "PVT Homing" + ], + "provStatus": [ + "CAPPED" + ] + } } + } } diff --git a/test/policy-local-files/thresholdPolicy_URLLC_Core_1.json b/test/policy-local-files/thresholdPolicy_URLLC_Core_1.json new file mode 100644 index 0000000..6c602ee --- /dev/null +++ b/test/policy-local-files/thresholdPolicy_URLLC_Core_1.json @@ -0,0 +1,41 @@ +{ + "OSDF_FRANKFURT.Threshold_URLLC_Core_1":{ + "type":"onap.policies.optimization.resource.ThresholdPolicy", + "version":"1.0.0", + "type_version":"1.0.0", + "metadata":{ + "policy-id":"OSDF_FRANKFURT.Threshold_URLLC_Core_1", + "policy-version":1 + }, + "properties":{ + "scope":[ + "OSDF_FRANKFURT", + "URLLC_1", + "URLLC_Core_1" + ], + "resources":[ + "URLLC_Core_1" + ], + "services":[ + "URLLC_1" + ], + "geography": [], + "identity":"Threshold_URLLC_Core_1", + "thresholdProperties":[ + { + "attribute":"latency", + "operator":"lte", + "threshold":5, + "unit":"ms" + }, + { + "attribute":"reliability", + "operator":"gte", + "threshold":99.999, + "unit":"" + } + + ] + } + } +}
\ No newline at end of file diff --git a/test/policy-local-files/vnfPolicy_URLLC_Core_1.json b/test/policy-local-files/vnfPolicy_URLLC_Core_1.json new file mode 100644 index 0000000..0fa69fa --- /dev/null +++ b/test/policy-local-files/vnfPolicy_URLLC_Core_1.json @@ -0,0 +1,39 @@ +{ + "OSDF_FRANKFURT.vnfPolicy_URLLC_Core_1": { + "type": "onap.policies.optimization.resource.VnfPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.vnfPolicy_URLLC_Core_1", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "URLLC_1", + "URLLC_Core_1" + ], + "resources": [ + "URLLC_Core_1" + ], + "services": [ + "URLLC_1" + ], + "identity": "vnf_URLLC_Core_1", + "applicableResources": "any", + "vnfProperties": [ + { + "inventoryProvider": "aai", + "inventoryType": "nssi", + "region": "RegionOne", + "attributes": { + "orchestrationStatus": "active", + "service-role": "nssi", + "modelInvariantId":"bfbg3636-e39c-iidd-0987-27c28f4oo3", + "modelVersionId":"bfbg3636-e39c-iidd-0987-27c28f4d33" + } + } + ] + } + } +} diff --git a/test/policy-local-files/vnfPolicy_vFW_TD.json b/test/policy-local-files/vnfPolicy_vFW_TD.json new file mode 100644 index 0000000..e63e2c2 --- /dev/null +++ b/test/policy-local-files/vnfPolicy_vFW_TD.json @@ -0,0 +1,47 @@ +{ + "OSDF_FRANKFURT.vnfPolicy_vFW_TD": { + "type": "onap.policies.optimization.resource.VnfPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.vnfPolicy_vFW_TD", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "TD" + ], + "resources": [ + "vFW-SINK" + ], + "geography": [ + "US" + ], + "identity": "vnf_vFW_TD", + "applicableResources": "any", + "vnfProperties": [{ + "inventoryProvider": "aai", + "serviceType": "", + "inventoryType": "vfmodule", + "customerId": { + "get_param": "chosen_customer_id" + }, + "equipmentRole": "", + "attributes": { + "orchestrationStatus": ["active"], + "provStatus": "ACTIVE", + "cloudRegionId": { + "get_param": "chosen_region" + }, + "service_instance_id": { + "get_param": "service_id" + } + }, + "passthroughAttributes": { + "td-role": "destination" + } + }] + } + } +} diff --git a/test/policy-local-files/vnfPolicy_vG.json b/test/policy-local-files/vnfPolicy_vG.json index 2a56426..2dea670 100644 --- a/test/policy-local-files/vnfPolicy_vG.json +++ b/test/policy-local-files/vnfPolicy_vG.json @@ -1,29 +1,38 @@ { - "service": "vnfPolicy", - "policyName": "OSDF_CASABLANCA.vnfPolicy_vG", - "description": "vnfPolicy", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "6", - "riskType": "test", - "riskLevel": "3", - "guard": "False", - "content": { - "identity": "vnf_vG", - "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vG"], - "policyType": "vnfPolicy", - "resources": ["vG"], - "applicableResources": "any", - "vnfProperties": [ - { - "inventoryProvider": "aai", - "serviceType": "", - "inventoryType": "cloud", - "customerId": "", - "orchestrationStatus": "", - "equipmentRole": "" - - } - ] + "OSDF_FRANKFURT.vnfPolicy_vG": { + "type": "onap.policies.optimization.resource.VnfPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.vnfPolicy_vG", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vG" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "vnf_vG", + "applicableResources": "any", + "vnfProperties": [ + { + "inventoryProvider": "aai", + "serviceType": "", + "inventoryType": "cloud", + "customerId": "", + "orchestrationStatus": "", + "equipmentRole": "" + } + ] } + } } diff --git a/test/policy-local-files/vnfPolicy_vGMuxInfra.json b/test/policy-local-files/vnfPolicy_vGMuxInfra.json index c8fd604..65475a9 100644 --- a/test/policy-local-files/vnfPolicy_vGMuxInfra.json +++ b/test/policy-local-files/vnfPolicy_vGMuxInfra.json @@ -1,28 +1,38 @@ { - "service": "vnfPolicy", - "policyName": "OSDF_CASABLANCA.vnfPolicy_vGMuxInfra", - "description": "vnfPolicy", - "templateVersion": "OpenSource.version.1", - "version": "test1", - "priority": "6", - "riskType": "test", - "riskLevel": "3", - "guard": "False", - "content": { - "identity": "vnf_vGMuxInfra", - "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"], - "policyType": "vnfPolicy", - "resources": ["vGMuxInfra"], - "applicableResources": "any", - "vnfProperties": [ - { - "inventoryProvider": "aai", - "serviceType": "vGMuxInfra-xx", - "inventoryType": "service", - "customerId": "SDN-ETHERNET-INTERNET", - "orchestrationStatus": "", - "equipmentRole": "" - } - ] + "OSDF_FRANKFURT.vnfPolicy_vGMuxInfra": { + "type": "onap.policies.optimization.resource.VnfPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.vnfPolicy_vGMuxInfra", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT" + ], + "services": [ + "vCPE" + ], + "resources": [ + "vGMuxInfra" + ], + "geography": [ + "US", + "INTERNATIONAL" + ], + "identity": "vnf_vGMuxInfra", + "applicableResources": "any", + "vnfProperties": [ + { + "inventoryProvider": "aai", + "serviceType": "vGMuxInfra-xx", + "inventoryType": "service", + "customerId": "SDN-ETHERNET-INTERNET", + "orchestrationStatus": "", + "equipmentRole": "" + } + ] } + } } diff --git a/test/policy-local-files/vnfPolicy_vPGN_TD.json b/test/policy-local-files/vnfPolicy_vPGN_TD.json new file mode 100644 index 0000000..077901a --- /dev/null +++ b/test/policy-local-files/vnfPolicy_vPGN_TD.json @@ -0,0 +1,52 @@ +{ + "OSDF_FRANKFURT.vnfPolicy_vPGN_TD": { + "type": "onap.policies.optimization.resource.VnfPolicy", + "version": "1.0.0", + "type_version": "1.0.0", + "metadata": { + "policy-id": "OSDF_FRANKFURT.vnfPolicy_vPGN_TD", + "policy-version": 1 + }, + "properties": { + "scope": [ + "OSDF_FRANKFURT", + "TD" + ], + "resources": [ + "vPGN" + ], + "geography": [ + "US" + ], + "identity": "vnf_vPGN_TD", + "applicableResources": "any", + "vnfProperties": [ + { + "inventoryProvider": "aai", + "serviceType": "", + "inventoryType": "vfmodule", + "customerId": { + "get_param": "chosen_customer_id" + }, + "equipmentRole": "", + "unique": "False", + "attributes": { + "orchestrationStatus": [ + "active" + ], + "provStatus": "ACTIVE", + "cloudRegionId": { + "get_param": "chosen_region" + }, + "service_instance_id": { + "get_param": "service_id" + } + }, + "passthroughAttributes": { + "td-role": "anchor" + } + } + ] + } + } +} diff --git a/test/policy/test_policy_interface.py b/test/policy/test_policy_interface.py index 4f1efcf..082b7f9 100644 --- a/test/policy/test_policy_interface.py +++ b/test/policy/test_policy_interface.py @@ -15,16 +15,16 @@ # # ------------------------------------------------------------------------- # -import mock import os import unittest -from osdf.adapters.local_data import local_policies +import mock + import osdf.config.loader as config_loader +from osdf.adapters.local_data import local_policies +from osdf.adapters.policy import interface as pol from osdf.utils.interfaces import json_from_file from osdf.utils.programming_utils import DotDict -from osdf.optimizers.placementopt.conductor import translation as tr -from osdf.adapters.policy import interface as pol class TestPolicyInterface(unittest.TestCase): diff --git a/test/simple_route_opt/AAI.json b/test/simple_route_opt/AAI.json new file mode 100644 index 0000000..6ef264b --- /dev/null +++ b/test/simple_route_opt/AAI.json @@ -0,0 +1,164 @@ +{ + "logical-link": [ + { + "link-name": "link-id-1", + "in-maint": true, + "link-type": "example-link-type-val-16287", + "resource-version": "1585009311719", + "operational-status": "UP", + "relationship-list": { + "relationship": [ + { + "related-to": "p-interface", + "relationship-label": "tosca.relationships.network.LinksTo", + "related-link": "/aai/v16/network/pnfs/pnf/20.20.20.20/p-interfaces/p-interface/p-interface-3", + "relationship-data": [ + { + "relationship-key": "pnf.pnf-name", + "relationship-value": "20.20.20.20" + }, + { + "relationship-key": "p-interface.interface-name", + "relationship-value": "p-interface-3" + } + ], + "related-to-property": [ + { + "property-key": "p-interface.prov-status" + } + ] + }, + { + "related-to": "p-interface", + "relationship-label": "tosca.relationships.network.LinksTo", + "related-link": "/aai/v16/network/pnfs/pnf/10.10.10.10/p-interfaces/p-interface/p-interface-2", + "relationship-data": [ + { + "relationship-key": "pnf.pnf-name", + "relationship-value": "10.10.10.10" + }, + { + "relationship-key": "p-interface.interface-name", + "relationship-value": "p-interface-2" + } + ], + "related-to-property": [ + { + "property-key": "p-interface.prov-status" + } + ] + } + ] + } + }, + { + "link-name": "link-id-2", + "in-maint": true, + "link-type": "example-link-type-val-16287", + "resource-version": "1584943281792", + "operational-status": "UP", + "relationship-list": { + "relationship": [ + { + "related-to": "p-interface", + "relationship-label": "tosca.relationships.network.LinksTo", + "related-link": "/aai/v16/network/pnfs/pnf/22.22.22.22/p-interfaces/p-interface/p-interface-7", + "relationship-data": [ + { + "relationship-key": "pnf.pnf-name", + "relationship-value": "22.22.22.22" + }, + { + "relationship-key": "p-interface.interface-name", + "relationship-value": "p-interface-7" + } + ], + "related-to-property": [ + { + "property-key": "p-interface.prov-status" + } + ] + }, + { + "related-to": "p-interface", + "relationship-label": "tosca.relationships.network.LinksTo", + "related-link": "/aai/v16/network/pnfs/pnf/11.11.11.11/p-interfaces/p-interface/p-interface-6", + "relationship-data": [ + { + "relationship-key": "pnf.pnf-name", + "relationship-value": "11.11.11.11" + }, + { + "relationship-key": "p-interface.interface-name", + "relationship-value": "p-interface-6" + } + ], + "related-to-property": [ + { + "property-key": "p-interface.prov-status" + } + ] + } + ] + } + }, + { + "link-name": "link-id-3", + "in-maint": true, + "link-type": "example-link-type-val-16287", + "resource-version": "1584943345290", + "operational-status": "UP", + "relationship-list": { + "relationship": [ + { + "related-to": "p-interface", + "relationship-label": "tosca.relationships.network.LinksTo", + "related-link": "/aai/v16/network/pnfs/pnf/11.11.11.11/p-interfaces/p-interface/p-interface-5", + "relationship-data": [ + { + "relationship-key": "pnf.pnf-name", + "relationship-value": "11.11.11.11" + }, + { + "relationship-key": "p-interface.interface-name", + "relationship-value": "p-interface-5" + } + ], + "related-to-property": [ + { + "property-key": "p-interface.prov-status" + } + ] + }, + { + "related-to": "p-interface", + "relationship-label": "tosca.relationships.network.LinksTo", + "related-link": "/aai/v16/network/pnfs/pnf/20.20.20.20/p-interfaces/p-interface/p-interface-4", + "relationship-data": [ + { + "relationship-key": "pnf.pnf-name", + "relationship-value": "20.20.20.20" + }, + { + "relationship-key": "p-interface.interface-name", + "relationship-value": "p-interface-4" + } + ], + "related-to-property": [ + { + "property-key": "p-interface.prov-status" + } + ] + } + ] + } + }, + { + "link-name": "rahul", + "in-maint": true, + "link-type": "example-link-type-val-rahul", + "resource-version": "1585023629505", + "operational-status": "UP" + } + ] +}
\ No newline at end of file diff --git a/test/simple_route_opt/routeOpt.json b/test/simple_route_opt/routeOpt.json new file mode 100644 index 0000000..887b85b --- /dev/null +++ b/test/simple_route_opt/routeOpt.json @@ -0,0 +1,34 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestId": "yyy-yyy-yyyy", + "callbackUrl": "https://wiki.onap.org:5000/callbackUrl", + "sourceId": "", + "requestType": "create", + "numSolutions": 1, + "optimizers": [ + "route" + ], + "timeout": 600 + }, + "routeInfo": { + "routeRequests": [ + { + "srcPort": { + "accessTopologyId": "Topo113", + "accessClientId": "clientU12", + "accessProviderId": "VDF1234", + "accessNodeId": "22.22.22.22", + "accessLtpId": "1345" + }, + "dstPort": { + "accessTopologyId": "Topo3421", + "accessClientId": "clientD123", + "accessProviderId": "VDF3214", + "accessNodeId": "10.10.10.10", + "accessLtpId": "3452" + } + } + ] + } +} diff --git a/test/test-requirements.txt b/test/test-requirements.txt index 043d87a..2c801e2 100644 --- a/test/test-requirements.txt +++ b/test/test-requirements.txt @@ -3,3 +3,5 @@ moto pytest pytest-tap requests-mock +pylint +mock diff --git a/test/test_ConductorApiBuilder.py b/test/test_ConductorApiBuilder.py index f8683a3..34f6989 100644 --- a/test/test_ConductorApiBuilder.py +++ b/test/test_ConductorApiBuilder.py @@ -1,5 +1,6 @@ # ------------------------------------------------------------------------- # Copyright (c) 2017-2018 AT&T Intellectual Property +# Copyright (C) 2020 Wipro Limited. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,8 +20,8 @@ import unittest import json import yaml +from osdf.adapters.conductor.api_builder import conductor_api_builder from osdf.adapters.local_data import local_policies -from osdf.optimizers.placementopt.conductor.api_builder import conductor_api_builder from osdf.utils.interfaces import json_from_file @@ -28,28 +29,52 @@ class TestConductorApiBuilder(unittest.TestCase): def setUp(self): self.main_dir = "" - conductor_api_template = self.main_dir + "osdf/templates/conductor_interface.json" - parameter_data_file = self.main_dir + "test/placement-tests/request.json" # "test/placement-tests/request.json" + self.conductor_api_template = self.main_dir + "osdf/adapters/conductor/templates/conductor_interface.json" + self.local_config_file = self.main_dir + "config/common_config.yaml" policy_data_path = self.main_dir + "test/policy-local-files" # "test/policy-local-files" - local_config_file = self.main_dir + "config/common_config.yaml" valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt' valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file) + parameter_data_file = self.main_dir + "test/placement-tests/request.json" # "test/placement-tests/request.json" self.request_json = json_from_file(parameter_data_file) + parameter_data_file = self.main_dir + "test/placement-tests/request_vfmod.json" + self.request_vfmod_json = json_from_file(parameter_data_file) + parameter_data_file = self.main_dir + "test/placement-tests/request_placement_vfmod.json" + self.request_placement_vfmod_json = json_from_file(parameter_data_file) self.policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files] + self.template_fields = { + 'location_enabled': True, + 'version': '2017-10-10' + } def test_conductor_api_call_builder(self): main_dir = self.main_dir - conductor_api_template = main_dir + "osdf/templates/conductor_interface.json" # "osdf/templates/conductor_interface.json" - local_config_file = main_dir + "config/common_config.yaml" request_json = self.request_json policies = self.policies - local_config = yaml.load(open(local_config_file)) - templ_string = conductor_api_builder(request_json, policies, local_config, conductor_api_template) + local_config = yaml.safe_load(open(self.local_config_file)) + req_info = request_json['requestInfo'] + demands = request_json['placementInfo']['placementDemands'] + request_parameters = request_json['placementInfo']['requestParameters'] + service_info = request_json['serviceInfo'] + templ_string = conductor_api_builder(req_info, demands, request_parameters, service_info, self.template_fields, + policies, local_config, self.conductor_api_template) templ_json = json.loads(templ_string) self.assertEqual(templ_json["name"], "yyy-yyy-yyyy") + def test_conductor_api_call_builder_vfmod(self): + request_json = self.request_vfmod_json + policies = self.policies + local_config = yaml.safe_load(open(self.local_config_file)) + req_info = request_json['requestInfo'] + demands = request_json['placementInfo']['placementDemands'] + request_parameters = request_json['placementInfo']['requestParameters'] + service_info = request_json['serviceInfo'] + templ_string = conductor_api_builder(req_info, demands, request_parameters, service_info, self.template_fields, + policies, local_config, self.conductor_api_template) + templ_json = json.loads(templ_string) + self.assertEqual(templ_json, self.request_placement_vfmod_json) + if __name__ == "__main__": unittest.main() diff --git a/test/test_PolicyCalls.py b/test/test_PolicyCalls.py index 4c9366a..1ca14dc 100644 --- a/test/test_PolicyCalls.py +++ b/test/test_PolicyCalls.py @@ -1,5 +1,6 @@ # ------------------------------------------------------------------------- # Copyright (c) 2017-2018 AT&T Intellectual Property +# Copyright (C) 2020 Wipro Limited. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,7 +25,7 @@ from osdf.adapters.policy import interface from osdf.utils.interfaces import RestClient, json_from_file import yaml from mock import patch -from osdf.optimizers.placementopt.conductor import translation +from osdf.adapters.conductor import translation from osdf.operation.exceptions import BusinessException @@ -63,7 +64,7 @@ class TestPolicyCalls(unittest.TestCase): "test/placement-tests/policy_response2.json") 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") - policy_type = [policy['content']['policyType'] for policy in policy_list] + policy_type = [policy[list(policy.keys())[0]]['type'] for policy in policy_list] #self.assertEqual(set(policy_type), {'hpaPolicy', 'SubscriberPolicy'}) def failure_policy_call(self, req_json_file, resp_json_file): @@ -91,7 +92,7 @@ class TestPolicyCalls(unittest.TestCase): 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.assertFalse(policies_list) self.assertRaises(Exception) def test_gen_demands(self): @@ -99,14 +100,16 @@ class TestPolicyCalls(unittest.TestCase): req_json = "./test/placement-tests/request.json" req_json = json.loads(open(req_json).read()) # need to run this only on vnf policies - vnf_policies = [x for x in self.policies if x["content"]["policyType"] == "vnfPolicy"] - gen_demands = translation.gen_demands(req_json, vnf_policies) + vnf_policies = [x for x in self.policies if x[list(x.keys())[0]]["type"] == + "onap.policies.optimization.resource.VnfPolicy"] + gen_demands = translation.gen_demands(req_json['placementInfo']['placementDemands'], vnf_policies) + for action in req_json['placementInfo']['placementDemands']: actions_list.append(action['resourceModuleName']) for key2,value in gen_demands.items(): gen_demands_list.append(key2) self.assertListEqual(gen_demands_list, actions_list, 'generated demands are not equal to the passed input' - '[placementDemand][resourceModuleName] list') + '[placementDemand][resourceModuleName] list') def test_local_policy_location(self): req_json = json_from_file("./test/placement-tests/request.json") diff --git a/test/test_aaf_authentication.py b/test/test_aaf_authentication.py index f20a860..6911337 100644 --- a/test/test_aaf_authentication.py +++ b/test/test_aaf_authentication.py @@ -16,6 +16,7 @@ # ------------------------------------------------------------------------- # import os + from flask import Flask from mock import mock @@ -33,7 +34,7 @@ class TestAafAuthentication(): def mock_aaf_response(*args, **kwargs): return {"perm": [{"instance": "menu_ecd", "action": "*", "type": "org.onap.oof.controller.dev.menu"}, - {"instance": "*", "action": "*", "type": "org.onap.osdf.access"}, + {"instance": "*", "action": "read", "type": "org.onap.oof.access"}, {"instance": "aaf", "action": "request", "type": "org.onap.osdf.certman"}, {"instance": "*", "action": "*", "type": "org.onap.osdf.dev.access"}, {"instance": ":*:*", "action": "*", "type": "org.onap.osdf.dev.k8"}, @@ -48,8 +49,8 @@ class TestAafAuthentication(): auth.clear_cache() def mock_aaf_response(*args, **kwargs): - return {"perm": [{"instance": "menu_ecd", "action": "*", "type": "org.onap.oof.controller.dev.menu"}, - {"instance": "*", "action": "*", "type": "org.onap.osdf.access"}, + return {"perm": [{"instance": "menu_ecd", "action": "*", "type": "org.onap.osdf.controller.dev.menu"}, + {"instance": "*", "action": "read", "type": "org.onap.oof.access"}, {"instance": "aaf", "action": "request", "type": "org.onap.osdf.certman"}, {"instance": "*", "action": "*", "type": "org.onap.osdf.dev.access"}, {"instance": ":*:*", "action": "*", "type": "org.onap.osdf.dev.k8"}, @@ -77,7 +78,7 @@ class TestAafAuthentication(): def mock_aaf_response(*args, **kwargs): return {"perm": [{"instance": "menu_ecd", "action": "*", "type": "org.onap.oof.controller.dev.menu"}, - {"instance": "*", "action": "*", "type": "org.onap.osdf.access"}, + {"instance": "*", "action": "*", "type": "org.onap.oof.access"}, {"instance": "aaf", "action": "request", "type": "org.onap.osdf.certman"}, {"instance": "*", "action": "*", "type": "org.onap.osdf.dev.access"}, {"instance": ":*:*", "action": "*", "type": "org.onap.osdf.dev.k8"}, diff --git a/test/test_api_validation.py b/test/test_api_validation.py index 80e0ba0..3a20262 100644 --- a/test/test_api_validation.py +++ b/test/test_api_validation.py @@ -18,9 +18,13 @@ import json import unittest -from osdf.models.api.placementRequest import PlacementAPI -from osdf.models.api.placementResponse import PlacementResponse -from schematics.exceptions import ModelValidationError +from schematics.exceptions import DataError + +from apps.placement.models.api.placementRequest import PlacementAPI +from apps.placement.models.api.placementResponse import PlacementResponse +from apps.slice_selection.models.api.nsi_selection_request import NSISelectionAPI +from apps.slice_selection.models.api.nssi_selection_request import NSSISelectionAPI +from apps.nxi_termination.models.api.nxi_termination_request import NxiTerminationApi class TestReqValidation(unittest.TestCase): @@ -30,9 +34,44 @@ class TestReqValidation(unittest.TestCase): req_json = json.loads(open(req_file).read()) self.assertEqual(PlacementAPI(req_json).validate(), None) + def test_req_vfmod_validation(self): + req_file = "./test/placement-tests/request_vfmod.json" + req_json = json.loads(open(req_file).read()) + self.assertEqual(PlacementAPI(req_json).validate(), None) + + def test_req_nsi_validation(self): + req_file = "./test/apps/slice_selection/nsi_selection_request.json" + req_json = json.loads(open(req_file).read()) + self.assertEqual(NSISelectionAPI(req_json).validate(), None) + + def test_req_invalid_nsi(self): + req_file = "./test/apps/slice_selection/nsi_selection_invalid_request.json" + req_json = json.loads(open(req_file).read()) + self.assertRaises(DataError, lambda: NSISelectionAPI(req_json).validate()) + + def test_req_nssi_validation(self): + req_file = "./test/apps/slice_selection/nssi_selection_request.json" + req_json = json.loads(open(req_file).read()) + self.assertEqual(NSSISelectionAPI(req_json).validate(), None) + + def test_req_invalid_nssi(self): + req_file = "./test/apps/slice_selection/nssi_selection_invalid_request.json" + req_json = json.loads(open(req_file).read()) + self.assertRaises(DataError, lambda: NSSISelectionAPI(req_json).validate()) + def test_req_failure(self): req_json = {} - self.assertRaises(ModelValidationError, lambda: PlacementAPI(req_json).validate()) + self.assertRaises(DataError, lambda: PlacementAPI(req_json).validate()) + + def test_req_nxi_validation(self): + req_file = "./test/apps/nxi_termination/nxi_termination.json" + req_json = json.loads(open(req_file).read()) + self.assertEqual(NxiTerminationApi(req_json).validate(), None) + + def test_req_invalid_nxi(self): + req_file = "./test/apps/nxi_termination/invalid_request.json" + req_json = json.loads(open(req_file).read()) + self.assertRaises(DataError, lambda: NxiTerminationApi(req_json).validate()) class TestResponseValidation(unittest.TestCase): @@ -42,9 +81,14 @@ class TestResponseValidation(unittest.TestCase): req_json = json.loads(open(req_file).read()) self.assertEqual(PlacementResponse(req_json).validate(), None) + def test_res_vfmod_validation(self): + req_file = "./test/placement-tests/response_vfmod.json" + req_json = json.loads(open(req_file).read()) + self.assertEqual(PlacementResponse(req_json).validate(), None) + def test_invalid_response(self): resp_json = {} - self.assertRaises(ModelValidationError, lambda: PlacementResponse(resp_json).validate()) + self.assertRaises(DataError, lambda: PlacementResponse(resp_json).validate()) if __name__ == "__main__": diff --git a/test/test_get_opt_query_data.py b/test/test_get_opt_query_data.py index 880f93f..8e6c324 100644 --- a/test/test_get_opt_query_data.py +++ b/test/test_get_opt_query_data.py @@ -1,40 +1,53 @@ -# -------------------------------------------------------------------------
-# Copyright (c) 2017-2018 AT&T Intellectual Property
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# -------------------------------------------------------------------------
-#
-import unittest
-import json
-from osdf.optimizers.placementopt.conductor.translation import get_opt_query_data
-
-
-class TestGetOptQueryData(unittest.TestCase):
-
- def test_get_opt_query_data(self):
- main_dir = ""
- parameter_data_file = main_dir + "test/placement-tests/request.json"
- policy_data_path = main_dir + "test/policy-local-files/"
-
- query_policy_data_file = ["QueryPolicy_vCPE.json"]
- request_json = json.loads(open(parameter_data_file).read())
- policies = [json.loads(open(policy_data_path + file).read()) for file in query_policy_data_file]
- req_param_dict = get_opt_query_data(request_json, policies)
-
- self.assertTrue(req_param_dict is not None)
-
-
-if __name__ == "__main__":
- unittest.main()
-
+# ------------------------------------------------------------------------- +# Copyright (c) 2017-2018 AT&T Intellectual Property +# Copyright (C) 2020 Wipro Limited. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# +import unittest +import json +from osdf.adapters.conductor.translation import get_opt_query_data + + +class TestGetOptQueryData(unittest.TestCase): + + def test_get_opt_query_data(self): + main_dir = "" + parameter_data_file = main_dir + "test/placement-tests/request.json" + policy_data_path = main_dir + "test/policy-local-files/" + + query_policy_data_file = ["QueryPolicy_vCPE.json"] + request_json = json.loads(open(parameter_data_file).read()) + policies = [json.loads(open(policy_data_path + file).read()) for file in query_policy_data_file] + req_param_dict = get_opt_query_data(request_json['placementInfo']['requestParameters'], policies) + + self.assertTrue(req_param_dict is not None) + + def test_get_opt_query_data_vfmod(self): + main_dir = "" + parameter_data_file = main_dir + "test/placement-tests/request_vfmod.json" + policy_data_path = main_dir + "test/policy-local-files/" + + query_policy_data_file = ["QueryPolicy_vFW_TD.json"] + request_json = json.loads(open(parameter_data_file).read()) + policies = [json.loads(open(policy_data_path + file).read()) for file in query_policy_data_file] + req_param_dict = get_opt_query_data(request_json['placementInfo']['requestParameters'], policies) + + self.assertTrue(req_param_dict is not None) + + +if __name__ == "__main__": + unittest.main() + diff --git a/test/test_inter_domain_route_opt.py b/test/test_inter_domain_route_opt.py new file mode 100644 index 0000000..3d18abc --- /dev/null +++ b/test/test_inter_domain_route_opt.py @@ -0,0 +1,151 @@ +# ------------------------------------------------------------------------- +# Copyright (c) 2020 Fujitsu Limited Intellectual Property +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +import unittest + +from unittest.mock import patch +from apps.route.optimizers.inter_domain_route_opt import InterDomainRouteOpt +import osdf.config.loader as config_loader +from osdf.utils.interfaces import json_from_file +from osdf.utils.programming_utils import DotDict + +count = 1 + +def mocked_requests_get(*args, **kwargs): + class MockResponse: + def __init__(self, json_data, status_code): + self.json_data = json_data + self.status_code = status_code + + def json(self): + return self.json_data + + main_dir = "" + response_data_file = main_dir + "test/inter_domain_route_opt/get_links.json" + bandwidth_attributes = main_dir + "test/inter_domain_route_opt/bandwidth_attributes.json" + bandwidth_attribute_values = json_from_file(bandwidth_attributes) + + controllers_list = main_dir + "test/inter_domain_route_opt/controllers_list.json" + + if args[0] == 'https://api.url:30233/aai/v19/network/logical-links?link-type=inter-domain&operational-status=up': + return MockResponse(json_from_file(response_data_file), 200) + elif args[0] == 'https://api.url:30233/aai/v19/network/pnfs/pnf/pnf1/p-interfaces/p-interface/int1?depth=all': + return MockResponse(bandwidth_attribute_values["int-1-bw"], 200) + elif args[0] == 'https://api.url:30233/aai/v19/network/pnfs/pnf/pnf2/p-interfaces/p-interface/int3?depth=all': + return MockResponse(bandwidth_attribute_values["int-3-bw"], 200) + elif args[0] == 'https://api.url:30233/aai/v19/network/pnfs/pnf/pnf2/p-interfaces/p-interface/int4?depth=all': + return MockResponse(bandwidth_attribute_values["int-4-bw"], 200) + elif args[0] == 'https://api.url:30233/aai/v19/network/pnfs/pnf/pnf3/p-interfaces/p-interface/int5?depth=all': + return MockResponse(bandwidth_attribute_values["int-5-bw"], 200) + elif args[0] == 'https://api.url:30233/aai/v19/network/pnfs/pnf/pnf3/p-interfaces/p-interface/int6?depth=all': + return MockResponse(bandwidth_attribute_values["int-6-bw"], 200) + elif args[0] == 'https://api.url:30233/aai/v19/network/pnfs/pnf/pnf4/p-interfaces/p-interface/int7?depth=all': + return MockResponse(bandwidth_attribute_values["int-7-bw"], 200) + elif args[0] == 'https://api.url:30233/aai/v19/external-system/esr-thirdparty-sdnc-list': + return MockResponse(json_from_file(controllers_list), 200) + return MockResponse(None, 404) + + +def mocked_requests_put(*args, **kwargs): + class MockResponse: + def __init__(self, json_data, status_code): + self.json_data = json_data + self.status_code = status_code + + def json(self): + return self.json_data + main_dir = "" + controllers_for_interfaces = main_dir + "test/inter_domain_route_opt/controllers_for_interfaces.json" + controllers_for_interfaces_values = json_from_file(controllers_for_interfaces) + + global count + + if count == 1: + count += 1 + return MockResponse(controllers_for_interfaces_values["int-1-cont"], 200) + elif count == 2: + count += 1 + return MockResponse(controllers_for_interfaces_values["int-3-cont"], 200) + elif count == 3: + count += 1 + return MockResponse(controllers_for_interfaces_values["int-4-cont"], 200) + elif count == 4: + count += 1 + return MockResponse(controllers_for_interfaces_values["int-5-cont"], 200) + elif count == 5: + count += 1 + return MockResponse(controllers_for_interfaces_values["int-6-cont"], 200) + elif count == 6: + count += 1 + return MockResponse(controllers_for_interfaces_values["int-7-cont"], 200) + + return MockResponse(None, 404) + + + +class TestInterDomainRouteOpt(unittest.TestCase): + @patch('apps.route.optimizers.inter_domain_route_opt.requests.get', side_effect=mocked_requests_get) + @patch('apps.route.optimizers.inter_domain_route_opt.requests.put', side_effect=mocked_requests_put) + @patch('apps.route.optimizers.simple_route_opt.pymzn.minizinc') + def test_process_get_route(self, mock_solve , mock_put, mock_get): + main_dir = "" + mock_solve.return_value = [{'x': [1, 1, 0, 0, 0, 0]}] + self.config_spec = { + "deployment": "test/functest/simulators/simulated-config/osdf_config.yaml", + "core": "test/functest/simulators/simulated-config/common_config.yaml" + } + self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec)) + parameter_data_file = main_dir + "test/inter_domain_route_opt/request.json" + request_json = json_from_file(parameter_data_file) + routopt = InterDomainRouteOpt() + actual_response = routopt.get_route(request_json,self.osdf_config) + mock_response = { + "requestId":"789456", + "transactionId":"123456", + "statusMessage":"SUCCESS", + "requestStatus":"accepted", + "solutions":{ + "routeInfo":{ + "serviceRoute":[ + { + "srcInterfaceId":"int19", + "dstInterfaceId":"int1", + "controllerId":"Controller1" + }, + { + "srcInterfaceId":"int3", + "dstInterfaceId":"int4", + "controllerId":"Controller2" + }, + { + "srcInterfaceId":"int5", + "dstInterfaceId":"int20", + "controllerId":"Controller3" + } + ], + "linkList":[ + "link1", + "link2" + ] + } + } + } + self.assertEqual(mock_response, actual_response) + + +if __name__ == '__main__': + unittest.main() +
\ No newline at end of file diff --git a/test/test_model_api.py b/test/test_model_api.py new file mode 100644 index 0000000..2a1cecf --- /dev/null +++ b/test/test_model_api.py @@ -0,0 +1,71 @@ +# ------------------------------------------------------------------------- +# Copyright (c) 2020 AT&T Intellectual Property +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# + +import json +import os + +import pytest +from mock import patch +from schematics.exceptions import DataError + +from runtime.model_api import create_model_data, get_model_data, delete_model_data, retrieve_all_models +from runtime.models.api.model_request import OptimModelRequestAPI +from runtime.optim_engine import validate_request + +BASE_DIR = os.path.dirname(__file__) + +ret_val = {'modelId': 'test', 'description': 'desc', 'solver': 'mzn'} + + +class TestModelApi(): + + def test_valid_mapi_request(self): + req_json = json.loads(open("./test/optengine-tests/test_modelapi_valid.json").read()) + + assert OptimModelRequestAPI(req_json).validate() is None + + def test_invalid_mapi_request(self): + req_json = json.loads(open("./test/optengine-tests/test_modelapi_invalid.json").read()) + with pytest.raises(DataError): + validate_request(req_json) + + @patch('runtime.model_api.build_model_dict') + @patch('mysql.connector.connect') + @patch('runtime.model_api.osdf_config') + def test_create_model(self, config, conn, model_data): + model_data.return_value = ret_val + req_json = json.loads(open("./test/optengine-tests/test_modelapi_valid.json").read()) + + create_model_data(req_json) + + @patch('runtime.model_api.build_model_dict') + @patch('mysql.connector.connect') + @patch('runtime.model_api.osdf_config') + def test_retrieve_model(self, config, conn, model_data): + model_data.return_value = ret_val + get_model_data('test') + + @patch('mysql.connector.connect') + @patch('runtime.model_api.osdf_config') + def test_delete_model(self, config, conn): + delete_model_data('test') + + @patch('mysql.connector.connect') + @patch('runtime.model_api.osdf_config') + def test_retrieve_all_model(self, config, conn): + retrieve_all_models() diff --git a/test/test_optim_engine.py b/test/test_optim_engine.py new file mode 100644 index 0000000..e1756f8 --- /dev/null +++ b/test/test_optim_engine.py @@ -0,0 +1,78 @@ +# ------------------------------------------------------------------------- +# Copyright (c) 2020 AT&T Intellectual Property +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# + +import json +import os + +import pytest +from mock import patch +from schematics.exceptions import DataError + +from osdf.operation.exceptions import BusinessException +from runtime.optim_engine import validate_request, process_request + +BASE_DIR = os.path.dirname(__file__) + + +class TestOptimEngine(): + + def test_valid_optim_request(self): + req_json = json.loads(open("./test/optengine-tests/test_optengine_valid.json").read()) + + assert validate_request(req_json) == True + + def test_invalid_optim_request(self): + req_json = json.loads(open("./test/optengine-tests/test_optengine_invalid.json").read()) + with pytest.raises(DataError): + validate_request(req_json) + + def test_invalid_optim_request_without_modelid(self): + req_json = json.loads(open("./test/optengine-tests/test_optengine_invalid2.json").read()) + with pytest.raises(BusinessException): + validate_request(req_json) + + def test_invalid_optim_request_no_optdata(self): + req_json = json.loads(open("./test/optengine-tests/test_optengine_no_optdata.json").read()) + with pytest.raises(BusinessException): + validate_request(req_json) + + def test_process_request(self): + req_json = json.loads(open("./test/optengine-tests/test_optengine_valid.json").read()) + + res = process_request(req_json) + assert res.status_code == 400 + + def test_py_process_request(self): + req_json = json.loads(open("./test/optengine-tests/test_py_optengine_valid.json").read()) + + res = process_request(req_json) + assert res.status_code == 200 + + def test_invalid_solver(self): + req_json = json.loads(open("./test/optengine-tests/test_optengine_invalid_solver.json").read()) + + with pytest.raises(BusinessException): + process_request(req_json) + + @patch('runtime.optim_engine.get_model_data') + def test_process_solverid_request(self, mocker): + req_json = json.loads(open("./test/optengine-tests/test_optengine_modelId.json").read()) + + data = 200, ('junk', '', '', 'py') + mocker.return_value = data + process_request(req_json) diff --git a/test/test_process_fixed_pci.py b/test/test_process_fixed_pci.py new file mode 100644 index 0000000..3d805c5 --- /dev/null +++ b/test/test_process_fixed_pci.py @@ -0,0 +1,79 @@ +# ------------------------------------------------------------------------- +# Copyright (c) 2018 AT&T Intellectual Property +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# +import mock +import unittest + +from flask import Response +from mock import patch +from osdf.adapters.local_data import local_policies +from apps.pci.optimizers.pci_opt_processor import process_pci_optimation +import osdf.config.loader as config_loader +from osdf.utils.interfaces import json_from_file +from osdf.utils.programming_utils import DotDict + + +class TestProcessPlacementOpt(unittest.TestCase): + + def setUp(self): + mock_req_accept_message = Response("Accepted Request", content_type='application/json; charset=utf-8') + self.patcher_req = patch('apps.pci.optimizers.config_request.request', + return_value={"solutionInfo": {"placementInfo": "dummy"}}) + self.patcher_req_accept = patch('osdf.operation.responses.osdf_response_for_request_accept', + return_value=mock_req_accept_message) + self.patcher_callback = patch( + 'apps.pci.optimizers.pci_opt_processor.process_pci_optimation', + return_value=mock_req_accept_message) + + mock_mzn_response = [{'pci': {0: 2, 1: 0, 2: 1, 3:3, 4:0} , 'used_ignorables': [0]}] + + self.patcher_minizinc_callback = patch( + 'apps.pci.optimizers.solver.optimizer.solve', + return_value=mock_mzn_response ) + self.patcher_RestClient = patch( + 'osdf.utils.interfaces.RestClient', return_value=mock.MagicMock()) + self.Mock_req = self.patcher_req.start() + self.Mock_req_accept = self.patcher_req_accept.start() + self.Mock_callback = self.patcher_callback.start() + self.Mock_RestClient = self.patcher_RestClient.start() + self.Mock_mzn_callback = self.patcher_minizinc_callback.start() + + def tearDown(self): + patch.stopall() + + def test_process_pci_opt_solutions(self): + main_dir = "" + parameter_data_file = main_dir + "test/pci-optimization-tests/fixed_pci.json" + policy_data_path = main_dir + "test/policy-local-files/" + self.config_spec = { + "deployment": "test/functest/simulators/simulated-config/osdf_config.yaml", + "core": "test/functest/simulators/simulated-config/common_config.yaml" + } + self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec)) + + valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt' + valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file) + + request_json = json_from_file(parameter_data_file) + policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files] + + templ_string = process_pci_optimation(request_json, self.osdf_config,policies) + + +if __name__ == "__main__": + unittest.main() + diff --git a/test/test_process_pci_anr_opt.py b/test/test_process_pci_anr_opt.py new file mode 100644 index 0000000..17c3e6d --- /dev/null +++ b/test/test_process_pci_anr_opt.py @@ -0,0 +1,79 @@ +# ------------------------------------------------------------------------- +# Copyright (c) 2018 AT&T Intellectual Property +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# +import unittest + +import mock +from flask import Response +from mock import patch + +import osdf.config.loader as config_loader +from apps.pci.optimizers.pci_opt_processor import process_pci_optimation +from osdf.adapters.local_data import local_policies +from osdf.utils.interfaces import json_from_file +from osdf.utils.programming_utils import DotDict + + +class TestProcessPlacementOpt(unittest.TestCase): + + def setUp(self): + mock_req_accept_message = Response("Accepted Request", content_type='application/json; charset=utf-8') + self.patcher_req = patch('apps.pci.optimizers.config_request.request', + return_value={"solutionInfo": {"placementInfo": "dummy"}}) + self.patcher_req_accept = patch('osdf.operation.responses.osdf_response_for_request_accept', + return_value=mock_req_accept_message) + self.patcher_callback = patch( + 'apps.pci.optimizers.pci_opt_processor.process_pci_optimation', + return_value=mock_req_accept_message) + + mock_mzn_response = [{'pci': {0: 0, 1: 1, 2: 2, 3: 3, 4: 0}, 'used_ignorables': [0]}] + + self.patcher_minizinc_callback = patch( + 'apps.pci.optimizers.solver.optimizer.solve', + return_value=mock_mzn_response) + self.patcher_RestClient = patch( + 'osdf.utils.interfaces.RestClient', return_value=mock.MagicMock()) + self.Mock_req = self.patcher_req.start() + self.Mock_req_accept = self.patcher_req_accept.start() + self.Mock_callback = self.patcher_callback.start() + self.Mock_RestClient = self.patcher_RestClient.start() + self.Mock_mzn_callback = self.patcher_minizinc_callback.start() + + def tearDown(self): + patch.stopall() + + def test_process_pci_anr_opt_solutions(self): + main_dir = "" + parameter_data_file = main_dir + "test/pci-optimization-tests/pci_anr_request.json" + policy_data_path = main_dir + "test/policy-local-files/" + self.config_spec = { + "deployment": "test/functest/simulators/simulated-config/osdf_config.yaml", + "core": "test/functest/simulators/simulated-config/common_config.yaml" + } + self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec)) + + valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt' + valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file) + + request_json = json_from_file(parameter_data_file) + policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files] + + templ_string = process_pci_optimation(request_json, self.osdf_config, policies) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_process_pci_opt.py b/test/test_process_pci_opt.py index 31aa5fb..d52599d 100644 --- a/test/test_process_pci_opt.py +++ b/test/test_process_pci_opt.py @@ -21,7 +21,7 @@ import unittest from flask import Response from mock import patch from osdf.adapters.local_data import local_policies -from osdf.optimizers.pciopt.pci_opt_processor import process_pci_optimation +from apps.pci.optimizers.pci_opt_processor import process_pci_optimation import osdf.config.loader as config_loader from osdf.utils.interfaces import json_from_file from osdf.utils.programming_utils import DotDict @@ -31,18 +31,18 @@ class TestProcessPlacementOpt(unittest.TestCase): def setUp(self): mock_req_accept_message = Response("Accepted Request", content_type='application/json; charset=utf-8') - self.patcher_req = patch('osdf.optimizers.pciopt.configdb.request', + self.patcher_req = patch('apps.pci.optimizers.config_request.request', return_value={"solutionInfo": {"placementInfo": "dummy"}}) self.patcher_req_accept = patch('osdf.operation.responses.osdf_response_for_request_accept', return_value=mock_req_accept_message) self.patcher_callback = patch( - 'osdf.optimizers.pciopt.pci_opt_processor.process_pci_optimation', + 'apps.pci.optimizers.pci_opt_processor.process_pci_optimation', return_value=mock_req_accept_message) mock_mzn_response = [{'pci': {0: 0, 1: 1, 2: 2}}] self.patcher_minizinc_callback = patch( - 'osdf.optimizers.pciopt.solver.optimizer.solve', + 'apps.pci.optimizers.solver.optimizer.solve', return_value=mock_mzn_response ) self.patcher_RestClient = patch( 'osdf.utils.interfaces.RestClient', return_value=mock.MagicMock()) diff --git a/test/test_process_placement_opt.py b/test/test_process_placement_opt.py index 3219675..8a29100 100644 --- a/test/test_process_placement_opt.py +++ b/test/test_process_placement_opt.py @@ -1,5 +1,6 @@ # ------------------------------------------------------------------------- # Copyright (c) 2017-2018 AT&T Intellectual Property +# Copyright (C) 2020 Wipro Limited. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,8 +21,9 @@ import unittest from flask import Response from mock import patch + +from apps.placement.optimizers.conductor.remote_opt_processor import process_placement_opt from osdf.adapters.local_data import local_policies -from osdf.optimizers.placementopt.conductor.remote_opt_processor import process_placement_opt from osdf.utils.interfaces import json_from_file, yaml_from_file @@ -29,12 +31,14 @@ class TestProcessPlacementOpt(unittest.TestCase): def setUp(self): mock_req_accept_message = Response("Accepted Request", content_type='application/json; charset=utf-8') - self.patcher_req = patch('osdf.optimizers.placementopt.conductor.conductor.request', - return_value={"solutionInfo": {"placementInfo": "dummy"}}) + conductor_response_file = 'test/placement-tests/conductor_response.json' + conductor_response = json_from_file(conductor_response_file) + self.patcher_req = patch('osdf.adapters.conductor.conductor.request', + return_value=conductor_response) self.patcher_req_accept = patch('osdf.operation.responses.osdf_response_for_request_accept', return_value=mock_req_accept_message) self.patcher_callback = patch( - 'osdf.optimizers.placementopt.conductor.remote_opt_processor.process_placement_opt', + 'apps.placement.optimizers.conductor.remote_opt_processor.process_placement_opt', return_value=mock_req_accept_message) self.patcher_RestClient = patch( 'osdf.utils.interfaces.RestClient', return_value=mock.MagicMock()) @@ -76,6 +80,20 @@ class TestProcessPlacementOpt(unittest.TestCase): local_config = yaml_from_file(local_config_file) templ_string = process_placement_opt(request_json, policies, local_config) + def test_process_placement_opt_placementDemand_vfmodule(self): + main_dir = "" + parameter_data_file = main_dir + "test/placement-tests/request_vfmod.json" + policy_data_path = main_dir + "test/policy-local-files/" + local_config_file = main_dir + "config/common_config.yaml" + + valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt' + valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file) + + request_json = json_from_file(parameter_data_file) + policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files] + local_config = yaml_from_file(local_config_file) + templ_string = process_placement_opt(request_json, policies, local_config) + if __name__ == "__main__": unittest.main() diff --git a/test/test_simple_route_opt.py b/test/test_simple_route_opt.py new file mode 100644 index 0000000..3b4facc --- /dev/null +++ b/test/test_simple_route_opt.py @@ -0,0 +1,57 @@ +from apps.route.optimizers.simple_route_opt import RouteOpt +from osdf.utils.interfaces import json_from_file +from unittest.mock import patch +import osdf.config.loader as config_loader +from osdf.utils.programming_utils import DotDict +import unittest + + +class TestSimpleRouteOptimization(unittest.TestCase): + @patch('apps.route.optimizers.simple_route_opt.requests.get') + @patch('apps.route.optimizers.simple_route_opt.pymzn.minizinc') + def test_process_nst_selection_solutions( self, mock_solve, mock_get): + + main_dir = "" + response_data_file = main_dir + "test/simple_route_opt/AAI.json" + mock_get.return_value.json.return_value = json_from_file(response_data_file) + mock_get.return_value.status_code = 200 + mock_solve.return_value = [{'x': [1, 1, 1]}] + self.config_spec = { + "deployment": "test/functest/simulators/simulated-config/osdf_config.yaml", + "core": "test/functest/simulators/simulated-config/common_config.yaml" + } + self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec)) + parameter_data_file = main_dir + "test/simple_route_opt/routeOpt.json" + request_json = json_from_file(parameter_data_file) + mock_response = { + "requestId": "yyy-yyy-yyyy", + "requestStatus": "accepted", + "solutions": [ + { + "end_node": "10.10.10.10", + "link": "link-id-1", + "start_node": "20.20.20.20" + }, + { + "end_node": "11.11.11.11", + "link": "link-id-2", + "start_node": "22.22.22.22" + }, + { + "end_node": "20.20.20.20", + "link": "link-id-3", + "start_node": "11.11.11.11" + } + ], + "statusMessage": " ", + "transactionId": "xxx-xxx-xxxx" + } + routopt = RouteOpt() + actual_response = routopt.get_route(request_json,self.osdf_config) + self.assertEqual(mock_response, actual_response) + + + +if __name__ == '__main__': + unittest.main() + diff --git a/test/test_so_response_gen.py b/test/test_so_response_gen.py index ab73ef6..1e6079b 100644 --- a/test/test_so_response_gen.py +++ b/test/test_so_response_gen.py @@ -1,5 +1,6 @@ # ------------------------------------------------------------------------- # Copyright (c) 2017-2018 AT&T Intellectual Property +# Copyright (C) 2020 Wipro Limited. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,10 +17,9 @@ # ------------------------------------------------------------------------- # import unittest -import json -import yaml + +from apps.placement.optimizers.conductor.remote_opt_processor import conductor_response_processor from osdf.utils.interfaces import json_from_file -from osdf.optimizers.placementopt.conductor.conductor import conductor_response_processor from osdf.utils.interfaces import RestClient @@ -36,4 +36,4 @@ class TestSoResponseGen(unittest.TestCase): if __name__ == "__main__": - unittest.main()
\ No newline at end of file + unittest.main() |