aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/templates/template.demo/src/test
diff options
context:
space:
mode:
authorHockla, Ali (ah999m) <ah999m@att.com>2017-09-05 14:01:04 -0500
committerAli Hockla <ah999m@att.com>2017-09-08 13:11:17 +0000
commit9641684f3084e3e6a0ce8b8594258c25c1092c2d (patch)
tree4ec335b3dfffc96931d9c5f4767db52b9857e3fd /controlloop/templates/template.demo/src/test
parent66e82ed4ee7bfb98758d62647ef2e771f869b280 (diff)
Added changes for vDNS Use Case - MSO Interface
Rebased and fixed merge conflicts Issue-ID: POLICY-102 Change-Id: Icc36a2cf6391aa9137593bc04f0d4543798b7ccd Signed-off-by: Ali Hockla <ah999m@att.com> Signed-off-by: Hockla, Ali (ah999m) <ah999m@att.com> Signed-off-by: HOCKLA <ah999m@att.com> Signed-off-by: Hockla, Ali (ah999m) <ah999m@att.com>
Diffstat (limited to 'controlloop/templates/template.demo/src/test')
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulator.java4
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorTest.java4
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java405
-rw-r--r--controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO-test.yaml26
4 files changed, 435 insertions, 4 deletions
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulator.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulator.java
index f4ed267b4..74b8bde0e 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulator.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/AaiSimulator.java
@@ -39,7 +39,7 @@ public class AaiSimulator {
@Path("/search/named-query")
public String aaiPostQuery()
{
- return "{\"inventory-response-item\":[{\"vserver\":{\"vserver-id\": \"vserver-id-Manisha-01\",\"vserver-name\": \"vserver-name-16102016-aai3255-data-11-1\",\"vserver-name2\": \"example-vserver-name2-val-68608\",\"prov-status\": \"example-prov-status-val-59118\",\"vserver-selflink\": \"example-vserver-selflink-val-10902\",\"in-maint\": true,\"is-closed-loop-disabled\": false,\"resource-version\": \"1477946963\"},\"model-name\": \"service-instance\",\"generic-vnf\": {\"vnf-id\": \"de7cc3ab-0212-47df-9e64-da1c79234deb\",\"vnf-name\": \"ZRDM2MMEX39\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1503082370097\",\"model-invariant-id\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\",\"model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\"},\"extra-properties\": {},\"inventory-response-items\":{\"inventory-response-item\":[{\"generic-vnf\":{\"vnf-id\": \"generic-vnf-id-Manisha-01\",\"vnf-name\": \"bpsx0001v-16102016-aai3255-data-11\",\"vnf-name2\": \"example-vnf-name2-val-8204\",\"vnf-type\": \"my-vnf-type\",\"service-id\": \"c7611ebe-c324-48f1-8085-94aef0c6ef3d\",\"regional-resource-zone\": \"example-regional-resource-zone-val-8204\",\"prov-status\": \"ACTIVE\",\"operational-state\": \"example-operational-state-val-3289\",\"license-key\": \"example-license-key-val-3289\",\"equipment-role\": \"example-equipment-role-val-3289\",\"orchestration-status\": \"example-orchestration-status-val-3289\",\"heat-stack-id\": \"example-heat-stack-id-val-3289\",\"mso-catalog-key\": \"example-mso-catalog-key-val-3289\",\"management-option\": \"example-management-option-val-8204\",\"ipv4-oam-address\": \"example-ipv4-oam-address-val-8204\",\"ipv4-loopback0-address\": \"example-ipv4-loopback0-address-val-8204\",\"nm-lan-v6-address\": \"example-nm-lan-v6-address-val-8204\",\"management-v6-address\": \"example-management-v6-address-val-8204\",\"vcpu\": 7957,\"vcpu-units\": \"example-vcpu-units-val-8204\",\"vmemory\": 168,\"vmemory-units\": \"example-vmemory-units-val-8204\",\"vdisk\": 3227,\"vdisk-units\": \"example-vdisk-units-val-8204\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1477946966\"},\"model-name\": \"service-instance\",\"service-instance\": {\"service-instance-id\": \"37b8cdb7-94eb-468f-a0c2-4e3c3546578e\",\"service-instance-name\": \"Changed Service Instance NAME\",\"model-invariant-id\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\",\"model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\",\"resource-version\": \"1503082993532\",\"orchestration-status\": \"Active\"},\"extra-properties\": {},\"inventory-response-items\":{\"inventory-response-item\":[{\"service-instance\":{\"service-instance-id\": \"service-instance-id-Manisha-01\",\"service-instance-name\": \"example-service-instance-name-val-5008-1\",\"widget-model-id\": \"example-widget-model-id-val-52958\",\"widget-model-version\": \"example-widget-model-version-val-42840\",\"bandwidth-total\": \"example-bandwidth-total-val-99587\",\"bandwidth-up-wan1\": \"example-bandwidth-up-wan1-val-73709\",\"bandwidth-down-wan1\": \"example-bandwidth-down-wan1-val-20007\",\"bandwidth-up-wan2\": \"example-bandwidth-up-wan2-val-16857\",\"bandwidth-down-wan2\": \"example-bandwidth-down-wan2-val-95839\",\"vhn-portal-url\": \"example-vhn-portal-url-val-21541\",\"operational-status\": \"example-operational-status-val-48090\",\"service-instance-location-id\": \"example-service-instance-location-id-val-9684\",\"resource-version\": \"1477946961\"},\"extra-properties\": {}},{\"model-name\": \"pnf\",\"generic-vnf\": {\"vnf-id\": \"jimmy-test\",\"vnf-name\": \"jimmy-test-vnf\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1504013830207\",\"model-invariant-id\": \"862b25a1-262a-4961-bdaa-cdc55d69785a\",\"model-version-id\": \"e9f1fa7d-c839-418a-9601-03dc0d2ad687\"},\"extra-properties\": {}},{\"model-name\": \"service-instance\",\"generic-vnf\": {\"vnf-id\": \"jimmy-test-vnf2\",\"vnf-name\": \"jimmy-test-vnf2-named\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1504014833841\",\"model-invariant-id\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\",\"model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\"},\"extra-properties\": {}}]}}]}}]}";
+// return "{\"inventory-response-item\":[{\"vserver\":{\"vserver-id\": \"vserver-id-Manisha-01\",\"vserver-name\": \"vserver-name-16102016-aai3255-data-11-1\",\"vserver-name2\": \"example-vserver-name2-val-68608\",\"prov-status\": \"example-prov-status-val-59118\",\"vserver-selflink\": \"example-vserver-selflink-val-10902\",\"in-maint\": true,\"is-closed-loop-disabled\": false,\"resource-version\": \"1477946963\"},\"model-name\": \"service-instance\",\"generic-vnf\": {\"vnf-id\": \"de7cc3ab-0212-47df-9e64-da1c79234deb\",\"vnf-name\": \"ZRDM2MMEX39\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1503082370097\",\"model-invariant-id\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\",\"model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\"},\"extra-properties\": {},\"inventory-response-items\":{\"inventory-response-item\":[{\"generic-vnf\":{\"vnf-id\": \"generic-vnf-id-Manisha-01\",\"vnf-name\": \"bpsx0001v-16102016-aai3255-data-11\",\"vnf-name2\": \"example-vnf-name2-val-8204\",\"vnf-type\": \"my-vnf-type\",\"service-id\": \"c7611ebe-c324-48f1-8085-94aef0c6ef3d\",\"regional-resource-zone\": \"example-regional-resource-zone-val-8204\",\"prov-status\": \"ACTIVE\",\"operational-state\": \"example-operational-state-val-3289\",\"license-key\": \"example-license-key-val-3289\",\"equipment-role\": \"example-equipment-role-val-3289\",\"orchestration-status\": \"example-orchestration-status-val-3289\",\"heat-stack-id\": \"example-heat-stack-id-val-3289\",\"mso-catalog-key\": \"example-mso-catalog-key-val-3289\",\"management-option\": \"example-management-option-val-8204\",\"ipv4-oam-address\": \"example-ipv4-oam-address-val-8204\",\"ipv4-loopback0-address\": \"example-ipv4-loopback0-address-val-8204\",\"nm-lan-v6-address\": \"example-nm-lan-v6-address-val-8204\",\"management-v6-address\": \"example-management-v6-address-val-8204\",\"vcpu\": 7957,\"vcpu-units\": \"example-vcpu-units-val-8204\",\"vmemory\": 168,\"vmemory-units\": \"example-vmemory-units-val-8204\",\"vdisk\": 3227,\"vdisk-units\": \"example-vdisk-units-val-8204\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1477946966\"},\"model-name\": \"service-instance\",\"service-instance\": {\"service-instance-id\": \"37b8cdb7-94eb-468f-a0c2-4e3c3546578e\",\"service-instance-name\": \"Changed Service Instance NAME\",\"model-invariant-id\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\",\"model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\",\"resource-version\": \"1503082993532\",\"orchestration-status\": \"Active\"},\"extra-properties\": {},\"inventory-response-items\":{\"inventory-response-item\":[{\"service-instance\":{\"service-instance-id\": \"service-instance-id-Manisha-01\",\"service-instance-name\": \"example-service-instance-name-val-5008-1\",\"widget-model-id\": \"example-widget-model-id-val-52958\",\"widget-model-version\": \"example-widget-model-version-val-42840\",\"bandwidth-total\": \"example-bandwidth-total-val-99587\",\"bandwidth-up-wan1\": \"example-bandwidth-up-wan1-val-73709\",\"bandwidth-down-wan1\": \"example-bandwidth-down-wan1-val-20007\",\"bandwidth-up-wan2\": \"example-bandwidth-up-wan2-val-16857\",\"bandwidth-down-wan2\": \"example-bandwidth-down-wan2-val-95839\",\"vhn-portal-url\": \"example-vhn-portal-url-val-21541\",\"operational-status\": \"example-operational-status-val-48090\",\"service-instance-location-id\": \"example-service-instance-location-id-val-9684\",\"resource-version\": \"1477946961\"},\"extra-properties\": {}},{\"model-name\": \"pnf\",\"generic-vnf\": {\"vnf-id\": \"jimmy-test\",\"vnf-name\": \"jimmy-test-vnf\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1504013830207\",\"model-invariant-id\": \"862b25a1-262a-4961-bdaa-cdc55d69785a\",\"model-version-id\": \"e9f1fa7d-c839-418a-9601-03dc0d2ad687\"},\"extra-properties\": {}},{\"model-name\": \"service-instance\",\"generic-vnf\": {\"vnf-id\": \"jimmy-test-vnf2\",\"vnf-name\": \"jimmy-test-vnf2-named\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1504014833841\",\"model-invariant-id\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\",\"model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\"},\"extra-properties\": {}}]}}]}}]}";
+ return "{\n\t\"inventory-response-item\": [{\n\t\t\t\"extra-properties\": {},\n\t\t\t\"inventory-response-items\": {\n\t\t\t\t\"inventory-response-item\": [{\n\t\t\t\t\t\t\"extra-properties\": {\n\t\t\t\t\t\t\t\"extra-property\": [{\n\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-name\",\n\t\t\t\t\t\t\t\t\t\"property-value\": \"c15ce9e1-e914-4c8f-b8bb\"\n\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-type\",\n\t\t\t\t\t\t\t\t\t\"property-value\": \"resource\"\n\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-version\",\n\t\t\t\t\t\t\t\t\t\"property-value\": \"1\"\n\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-id\",\n\t\t\t\t\t\t\t\t\t\"property-value\": \"033a32ed-aa65-4764-a736-36f2942f1aa0\"\n\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-name-version-id\",\n\t\t\t\t\t\t\t\t\t\"property-value\": \"d4d072dc-4e21-4a03-9524-628985819a8e\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"generic-vnf\": {\n\t\t\t\t\t\t\t\"in-maint\": false,\n\t\t\t\t\t\t\t\"is-closed-loop-disabled\": false,\n\t\t\t\t\t\t\t\"orchestration-status\": \"Created\",\n\t\t\t\t\t\t\t\"persona-model-id\": \"033a32ed-aa65-4764-a736-36f2942f1aa0\",\n\t\t\t\t\t\t\t\"persona-model-version\": \"1.0\",\n\t\t\t\t\t\t\t\"resource-version\": \"1485542422\",\n\t\t\t\t\t\t\t\"service-id\": \"b3f70641-bdb9-4030-825e-6abb73a1f929\",\n\t\t\t\t\t\t\t\"vnf-id\": \"594e2fe0-48b8-41ff-82e2-3d4bab69b192\",\n\t\t\t\t\t\t\t\"vnf-name\": \"Vnf_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8\",\n\t\t\t\t\t\t\t\"vnf-type\": \"8330e932-2a23-4943-8606/c15ce9e1-e914-4c8f-b8bb 1\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"inventory-response-items\": {\n\t\t\t\t\t\t\t\"inventory-response-item\": [{\n\t\t\t\t\t\t\t\t\t\"extra-properties\": {\n\t\t\t\t\t\t\t\t\t\t\"extra-property\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-name\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"8330e932-2a23-4943-8606\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"service\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-version\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"1\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-id\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-name-version-id\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"5c996219-b2e2-4c76-9b43-7e8672a33c1d\"\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\"service-instance\": {\n\t\t\t\t\t\t\t\t\t\t\"persona-model-id\": \"4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b\",\n\t\t\t\t\t\t\t\t\t\t\"persona-model-version\": \"1.0\",\n\t\t\t\t\t\t\t\t\t\t\"resource-version\": \"1485542400\",\n\t\t\t\t\t\t\t\t\t\t\"service-instance-id\": \"cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5\",\n\t\t\t\t\t\t\t\t\t\t\"service-instance-name\": \"Service_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\"extra-properties\": {\n\t\t\t\t\t\t\t\t\t\t\"extra-property\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-name\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"C15ce9e1E9144c8fB8bb..base_vlb..module-0\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"resource\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-version\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"1\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-id\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"79ee24cd-fc9a-4f14-afae-5e1dd2ab2941\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-name-version-id\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"5484cabb-1a0d-4f29-a616-094a3f643d73\"\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\"model-name\": \"C15ce9e1E9144c8fB8bb..base_vlb..module-0\",\n\t\t\t\t\t\t\t\t\t\"vf-module\": {\n\t\t\t\t\t\t\t\t\t\t\"heat-stack-id\": \"Vfmodule_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8/5845f37b-6cda-4e91-8ca3-f5572d226488\",\n\t\t\t\t\t\t\t\t\t\t\"is-base-vf-module\": true,\n\t\t\t\t\t\t\t\t\t\t\"orchestration-status\": \"active\",\n\t\t\t\t\t\t\t\t\t\t\"persona-model-id\": \"79ee24cd-fc9a-4f14-afae-5e1dd2ab2941\",\n\t\t\t\t\t\t\t\t\t\t\"persona-model-version\": \"1\",\n\t\t\t\t\t\t\t\t\t\t\"resource-version\": \"1485542667\",\n\t\t\t\t\t\t\t\t\t\t\"vf-module-id\": \"b0eff878-e2e1-4947-9597-39afdd0f51dd\",\n\t\t\t\t\t\t\t\t\t\t\"vf-module-name\": \"Vfmodule_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\"extra-properties\": {\n\t\t\t\t\t\t\t\t\t\t\"extra-property\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-name\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"C15ce9e1E9144c8fB8bb..dnsscaling..module-1\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"resource\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-version\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"1\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-id\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"f32568ec-2f1c-458a-864b-0593d53d141a\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-name-version-id\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"69615025-879d-4f0d-afe3-b7d1a7eeed1f\"\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\"vf-module\": {\n\t\t\t\t\t\t\t\t\t\t\"is-base-vf-module\": false,\n\t\t\t\t\t\t\t\t\t\t\"persona-model-id\": \"f32568ec-2f1c-458a-864b-0593d53d141a\",\n\t\t\t\t\t\t\t\t\t\t\"persona-model-version\": \"1.0\",\n\t\t\t\t\t\t\t\t\t\t\"resource-version\": \"1485561752\",\n\t\t\t\t\t\t\t\t\t\t\"vf-module-id\": \"dummy\",\n\t\t\t\t\t\t\t\t\t\t\"vf-module-name\": \"dummy\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\"extra-properties\": {\n\t\t\t\t\t\t\t\t\t\t\"extra-property\": [{\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-name\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"C15ce9e1E9144c8fB8bb..dnsscaling..module-1\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-type\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"resource\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-version\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"1\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-id\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"f32568ec-2f1c-458a-864b-0593d53d141a\"\n\t\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-name\": \"model.model-name-version-id\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"property-value\": \"69615025-879d-4f0d-afe3-b7d1a7eeed1f\"\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\"vf-module\": {\n\t\t\t\t\t\t\t\t\t\t\"heat-stack-id\": \"vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8/f447ce51-14dd-4dcd-9957-68a047c79673\",\n\t\t\t\t\t\t\t\t\t\t\"is-base-vf-module\": false,\n\t\t\t\t\t\t\t\t\t\t\"orchestration-status\": \"active\",\n\t\t\t\t\t\t\t\t\t\t\"persona-model-id\": \"f32568ec-2f1c-458a-864b-0593d53d141a\",\n\t\t\t\t\t\t\t\t\t\t\"persona-model-version\": \"1.0\",\n\t\t\t\t\t\t\t\t\t\t\"resource-version\": \"1485562712\",\n\t\t\t\t\t\t\t\t\t\t\"vf-module-id\": \"8cd79e44-1fae-48c1-a160-609f90b46749\",\n\t\t\t\t\t\t\t\t\t\t\"vf-module-name\": \"vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}, {\n\t\t\t\t\t\t\"extra-properties\": {},\n\t\t\t\t\t\t\"inventory-response-items\": {\n\t\t\t\t\t\t\t\"inventory-response-item\": [{\n\t\t\t\t\t\t\t\t\t\"cloud-region\": {\n\t\t\t\t\t\t\t\t\t\t\"cloud-owner\": \"Rackspace\",\n\t\t\t\t\t\t\t\t\t\t\"cloud-region-id\": \"DFW\",\n\t\t\t\t\t\t\t\t\t\t\"cloud-region-version\": \"v1\",\n\t\t\t\t\t\t\t\t\t\t\"cloud-type\": \"SharedNode\",\n\t\t\t\t\t\t\t\t\t\t\"cloud-zone\": \"CloudZone\",\n\t\t\t\t\t\t\t\t\t\t\"owner-defined-type\": \"OwnerType\",\n\t\t\t\t\t\t\t\t\t\t\"resource-version\": \"1485465545\"\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\"extra-properties\": {}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"tenant\": {\n\t\t\t\t\t\t\t\"resource-version\": \"1485465545\",\n\t\t\t\t\t\t\t\"tenant-id\": \"1015548\",\n\t\t\t\t\t\t\t\"tenant-name\": \"1015548\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t\"vserver\": {\n\t\t\t\t\"in-maint\": false,\n\t\t\t\t\"is-closed-loop-disabled\": false,\n\t\t\t\t\"prov-status\": \"ACTIVE\",\n\t\t\t\t\"resource-version\": \"1485546436\",\n\t\t\t\t\"vserver-id\": \"70f081eb-2a87-4c81-9296-4b93d7d145c6\",\n\t\t\t\t\"vserver-name\": \"vlb-lb-32c8\",\n\t\t\t\t\"vserver-name2\": \"vlb-lb-32c8\",\n\t\t\t\t\"vserver-selflink\": \"https://dfw.servers.api.rackspacecloud.com/v2/1015548/servers/70f081eb-2a87-4c81-9296-4b93d7d145c6\"\n\t\t\t}\n\t\t}\n\t]\n}";
}
-
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorTest.java
index e2b1114be..7696cbe73 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/MsoSimulatorTest.java
@@ -28,7 +28,7 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.drools.http.server.HttpServletServer;
-import org.onap.policy.mso.MSOResponse;
+import org.onap.policy.mso.SOResponse;
import org.onap.policy.mso.util.Serialization;
import org.onap.policy.rest.RESTManager;
import org.onap.policy.rest.RESTManager.Pair;
@@ -53,7 +53,7 @@ public class MsoSimulatorTest {
public void testResponse(){
Pair<Integer, String> httpDetails = RESTManager.post("http://localhost:6667/serviceInstances/v2/12345/vnfs/12345/vfModulesHTTPS/1.1", "username", "password", new HashMap<String, String>(), "application/json", "Some Request Here");
assertNotNull(httpDetails);
- MSOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, MSOResponse.class);
+ SOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, SOResponse.class);
assertNotNull(response);
}
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
new file mode 100644
index 000000000..0738aadcf
--- /dev/null
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
@@ -0,0 +1,405 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * demo
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.template.demo;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.kie.api.KieServices;
+import org.kie.api.builder.KieBuilder;
+import org.kie.api.builder.KieFileSystem;
+import org.kie.api.builder.Message;
+import org.kie.api.builder.ReleaseId;
+import org.kie.api.builder.Results;
+import org.kie.api.builder.model.KieModuleModel;
+import org.kie.api.runtime.KieContainer;
+import org.kie.api.runtime.KieSession;
+import org.kie.api.runtime.rule.FactHandle;
+import org.onap.policy.controlloop.ControlLoopEventStatus;
+import org.onap.policy.controlloop.ControlLoopLogger;
+import org.onap.policy.controlloop.ControlLoopTargetType;
+import org.onap.policy.controlloop.VirtualControlLoopEvent;
+import org.onap.policy.controlloop.impl.ControlLoopLoggerStdOutImpl;
+import org.onap.policy.controlloop.policy.ControlLoopPolicy;
+import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
+import org.onap.policy.mso.util.Serialization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class TestSO {
+
+ private static final Logger log = LoggerFactory.getLogger(TestSO.class);
+
+ @Ignore
+ @Test
+ public void testvDNS() throws IOException {
+
+ final String yaml = "src/test/resources/yaml/policy_ControlLoop_SO-test.yaml";
+
+ //
+ // Pull info from the yaml
+ //
+ final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml(yaml);
+ assertNotNull(pair);
+ assertNotNull(pair.a);
+ assertNotNull(pair.a.getControlLoop());
+ assertNotNull(pair.a.getControlLoop().getControlLoopName());
+ assertTrue(pair.a.getControlLoop().getControlLoopName().length() > 0);
+
+ //
+ // Build a container
+ //
+ final String closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
+ final KieSession kieSession = buildContainer("src/main/resources/ControlLoop_Template_xacml_guard.drl",
+ closedLoopControlName,
+ "type=operational",
+ "myVDNSDemoPolicy",
+ "v1.0",
+ "SO",
+ "POLICY-CL-MGT",
+ "APPC-CL",
+ URLEncoder.encode(pair.b, "UTF-8")
+ );
+
+ log.debug("============ PRINTING YAML ============");
+ log.debug(URLEncoder.encode(pair.b, "UTF-8"));
+ log.debug("================ DONE =================");
+
+ //
+ // Insert our globals
+ //
+ final ControlLoopLogger logger = new ControlLoopLoggerStdOutImpl();
+ kieSession.setGlobal("Logger", logger);
+ final PolicyEngineJUnitImpl engine = new PolicyEngineJUnitImpl();
+ kieSession.setGlobal("Engine", engine);
+
+ //
+ // Initial fire of rules
+ //
+ kieSession.fireAllRules();
+ //
+ // Kick a thread that starts testing
+ //
+ new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+
+ log.debug("\n***** Starting AAI Simulator ***** ");
+ AaiSimulatorTest.setUpSimulator();
+ log.debug("\n***** AAI Simulator started ***** ");
+
+ log.debug("\n************ Starting vDNS Test *************\n");
+
+ //
+ // Generate an invalid DCAE Event with requestID=null
+ //
+ VirtualControlLoopEvent invalidEvent = new VirtualControlLoopEvent();
+ invalidEvent.closedLoopControlName = closedLoopControlName;
+ invalidEvent.requestID = null;
+ invalidEvent.closedLoopEventClient = "tca.instance00001";
+ invalidEvent.target_type = ControlLoopTargetType.VNF;
+ invalidEvent.target = "generic-vnf.vnf-id";
+ invalidEvent.from = "DCAE";
+ invalidEvent.closedLoopAlarmStart = Instant.now();
+ invalidEvent.AAI = new HashMap<String, String>();
+ invalidEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
+ invalidEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+
+ log.debug("-------- Sending Invalid ONSET --------");
+ log.debug(Serialization.gsonPretty.toJson(invalidEvent));
+
+ //
+ // Insert invalid DCAE Event into memory
+ //
+ kieSession.insert(invalidEvent);
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ }
+ //
+ // Generate first DCAE ONSET Event
+ //
+ VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
+ onsetEvent.closedLoopControlName = closedLoopControlName;
+ onsetEvent.requestID = UUID.randomUUID();
+ onsetEvent.closedLoopEventClient = "tca.instance00001";
+ onsetEvent.target_type = ControlLoopTargetType.VNF;
+ onsetEvent.target = "VNF_NAME";
+ onsetEvent.from = "DCAE";
+ onsetEvent.closedLoopAlarmStart = Instant.now();
+ onsetEvent.AAI = new HashMap<String, String>();
+ onsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
+ onsetEvent.AAI.put("vserver.is-closed-loop-disabled", "false");
+ onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+
+ log.debug("-------- Sending Valid ONSET --------");
+ log.debug(Serialization.gsonPretty.toJson(onsetEvent));
+
+ //
+ // Insert first DCAE ONSET Event into memory
+ //
+ kieSession.insert(onsetEvent);
+ //
+ // We have test for subsequent ONSET Events in testvFirewall()
+ // So no need to test it again here
+ //
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ }
+ //
+ // Test is finished, so stop the kieSession
+ //
+ kieSession.halt();
+ }
+ //
+ }).start();
+ //
+ // Start firing rules
+ //
+ kieSession.fireUntilHalt();
+ //
+ // Dump working memory
+ //
+ dumpFacts(kieSession);
+
+ log.debug("\n***** Stopping AAI Simulator ***** ");
+ AaiSimulatorTest.tearDownSimulator();
+ log.debug("\n***** AAI Simulator stopped ***** ");
+
+ //
+ // See if there is anything left in memory, there SHOULD only be
+ // a params fact.
+ //
+ assertEquals("There should only be 1 Fact left in memory.", 1, kieSession.getFactCount());
+ for (FactHandle handle : kieSession.getFactHandles()) {
+ Object fact = kieSession.getObject(handle);
+ assertEquals("Non-Param Fact left in working memory", "org.onap.policy.controlloop.Params", fact.getClass().getName());
+ }
+
+ }
+
+ public static void dumpFacts(KieSession kieSession) {
+ log.debug("Fact Count: " + kieSession.getFactCount());
+ for (FactHandle handle : kieSession.getFactHandles()) {
+ log.debug("FACT: " + handle);
+ }
+ }
+
+ public static KieSession buildContainer(String droolsTemplate,
+ String closedLoopControlName,
+ String policyScope,
+ String policyName,
+ String policyVersion,
+ String actor,
+ String notificationTopic,
+ String appcTopic,
+ String yamlSpecification) throws IOException {
+ //
+ // Get our Drools Kie factory
+ //
+ KieServices ks = KieServices.Factory.get();
+
+ KieModuleModel kModule = ks.newKieModuleModel();
+
+ log.debug("KMODULE:" + System.lineSeparator() + kModule.toXML());
+
+ //
+ // Generate our drools rule from our template
+ //
+ KieFileSystem kfs = ks.newKieFileSystem();
+
+ kfs.writeKModuleXML(kModule.toXML());
+ {
+ Path rule = Paths.get(droolsTemplate);
+ String ruleTemplate = new String(Files.readAllBytes(rule));
+ String drlContents = generatePolicy(ruleTemplate,
+ closedLoopControlName,
+ policyScope,
+ policyName,
+ policyVersion,
+ actor,
+ notificationTopic,
+ appcTopic,
+ yamlSpecification
+ );
+
+ kfs.write("src/main/resources/" + policyName + ".drl", ks.getResources().newByteArrayResource(drlContents.getBytes()));
+ }
+ //
+ // Compile the rule
+ //
+ KieBuilder builder = ks.newKieBuilder(kfs).buildAll();
+ Results results = builder.getResults();
+ if (results.hasMessages(Message.Level.ERROR)) {
+ for (Message msg : results.getMessages()) {
+ System.err.println(msg.toString());
+ }
+ throw new RuntimeException("Drools Rule has Errors");
+ }
+ for (Message msg : results.getMessages()) {
+ log.debug(msg.toString());
+ }
+ //
+ // Create our kie Session and container
+ //
+ ReleaseId releaseId = ks.getRepository().getDefaultReleaseId();
+ log.debug("ReleaseId: " + releaseId);
+ KieContainer kContainer = ks.newKieContainer(releaseId);
+
+ return kContainer.newKieSession();
+ }
+ public static String generatePolicy(String ruleContents,
+ String closedLoopControlName,
+ String policyScope,
+ String policyName,
+ String policyVersion,
+ String actor,
+ String notificationTopic,
+ String appcTopic,
+ String controlLoopYaml) {
+
+ Pattern p = Pattern.compile("\\$\\{closedLoopControlName\\}");
+ Matcher m = p.matcher(ruleContents);
+ ruleContents = m.replaceAll(closedLoopControlName);
+
+ p = Pattern.compile("\\$\\{policyScope\\}");
+ m = p.matcher(ruleContents);
+ ruleContents = m.replaceAll(policyScope);
+
+ p = Pattern.compile("\\$\\{policyName\\}");
+ m = p.matcher(ruleContents);
+ ruleContents = m.replaceAll(policyName);
+
+ p = Pattern.compile("\\$\\{policyVersion\\}");
+ m = p.matcher(ruleContents);
+ ruleContents = m.replaceAll(policyVersion);
+
+ p = Pattern.compile("\\$\\{actor\\}");
+ m = p.matcher(ruleContents);
+ ruleContents = m.replaceAll(actor);
+
+// p = Pattern.compile("\\$\\{aaiURL\\}");
+// m = p.matcher(ruleContents);
+// if (aaiURL == null) {
+// ruleContents = m.replaceAll("null");
+// } else {
+// ruleContents = m.replaceAll(aaiURL);
+// }
+//
+// p = Pattern.compile("\\$\\{aaiUsername\\}");
+// m = p.matcher(ruleContents);
+// if (aaiUsername == null) {
+// ruleContents = m.replaceAll("null");
+// } else {
+// ruleContents = m.replaceAll(aaiUsername);
+// }
+//
+// p = Pattern.compile("\\$\\{aaiPassword\\}");
+// m = p.matcher(ruleContents);
+// if (aaiPassword == null) {
+// ruleContents = m.replaceAll("null");
+// } else {
+// ruleContents = m.replaceAll(aaiPassword);
+// }
+//
+// p = Pattern.compile("\\$\\{msoURL\\}");
+// m = p.matcher(ruleContents);
+// if (msoURL == null) {
+// ruleContents = m.replaceAll("null");
+// } else {
+// ruleContents = m.replaceAll(msoURL);
+// }
+//
+// p = Pattern.compile("\\$\\{msoUsername\\}");
+// m = p.matcher(ruleContents);
+// if (msoUsername == null) {
+// ruleContents = m.replaceAll("null");
+// } else {
+// ruleContents = m.replaceAll(msoUsername);
+// }
+//
+// p = Pattern.compile("\\$\\{msoPassword\\}");
+// m = p.matcher(ruleContents);
+// if (msoPassword == null) {
+// ruleContents = m.replaceAll("null");
+// } else {
+// ruleContents = m.replaceAll(msoPassword);
+// }
+//
+// p = Pattern.compile("\\$\\{aaiNamedQueryUUID\\}");
+// m = p.matcher(ruleContents);
+// if (aaiNamedQueryUUID == null) {
+// ruleContents = m.replaceAll("null");
+// } else {
+// ruleContents = m.replaceAll(aaiNamedQueryUUID);
+// }
+//
+// p = Pattern.compile("\\$\\{aaiPatternMatch\\}");
+// m = p.matcher(ruleContents);
+// if (aaiPatternMatch == 1) {
+// ruleContents = m.replaceAll("1");
+// } else {
+// ruleContents = m.replaceAll("0");
+// }
+
+ p = Pattern.compile("\\$\\{notificationTopic\\}");
+ m = p.matcher(ruleContents);
+ if (notificationTopic == null) {
+ ruleContents = m.replaceAll("null");
+ } else {
+ ruleContents = m.replaceAll(notificationTopic);
+ }
+
+ p = Pattern.compile("\\$\\{appcTopic\\}");
+ m = p.matcher(ruleContents);
+ if (appcTopic == null) {
+ ruleContents = m.replaceAll("null");
+ } else {
+ ruleContents = m.replaceAll(appcTopic);
+ }
+
+ p = Pattern.compile("\\$\\{controlLoopYaml\\}");
+ m = p.matcher(ruleContents);
+ ruleContents = m.replaceAll(controlLoopYaml);
+
+ log.debug(ruleContents);
+
+ return ruleContents;
+ }
+
+}
diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO-test.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO-test.yaml
new file mode 100644
index 000000000..d3ae91650
--- /dev/null
+++ b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO-test.yaml
@@ -0,0 +1,26 @@
+controlLoop:
+ version: 2.0.0
+ controlLoopName: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
+ services:
+ - serviceName: d4738992-6497-4dca-9db9
+ serviceInvariantUUID: dc112d6e-7e73-4777-9c6f-1a7fb5fd1b6f
+ serviceUUID: 2eea06c6-e1d3-4c3a-b9c4-478c506eeedf
+ trigger_policy: unique-policy-id-1-scale-up
+ timeout: 1200
+
+policies:
+ - id: unique-policy-id-1-scale-up
+ name: Create a new VF Module
+ description:
+ actor: SO
+ recipe: VF Module Create
+ target:
+ type: VNF
+ retry: 0
+ timeout: 1200
+ success: final_success
+ failure: final_failure
+ failure_timeout: final_failure_timeout
+ failure_retries: final_failure_retries
+ failure_exception: final_failure_exception
+ failure_guard: final_failure_guard \ No newline at end of file