aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--.gitreview4
-rw-r--r--LICENSE.txt16
-rw-r--r--README.md3
-rw-r--r--aai/pom.xml51
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAIGETResponse.java40
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199CloudRegion.java51
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ExtraProperties.java42
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ExtraProperty.java48
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199GenericVNF.java82
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199InstanceFilters.java43
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199InventoryResponseItem.java64
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199InventoryResponseItems.java42
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Manager.java108
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199NamedQuery.java41
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199QueryParameters.java40
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Request.java65
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199RequestWrapper.java39
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Response.java42
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ResponseWrapper.java40
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ServiceInstance.java55
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Tenant.java45
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199VServer.java54
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199VfModule.java69
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/RelatedToPropertyItem.java35
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/RelationshipItem.java36
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/RelationshipList.java36
-rw-r--r--aai/src/main/java/org/openecomp/policy/aai/util/Serialization.java32
-rw-r--r--aai/src/test/java/org/openecomp/policy/aai/TestDemo.java240
-rw-r--r--aai/src/test/resources/response.json69
-rw-r--r--appc/pom.xml46
-rw-r--r--appc/src/main/java/org/openecomp/policy/appc/CommonHeader.java124
-rw-r--r--appc/src/main/java/org/openecomp/policy/appc/Request.java104
-rw-r--r--appc/src/main/java/org/openecomp/policy/appc/Response.java112
-rw-r--r--appc/src/main/java/org/openecomp/policy/appc/ResponseCode.java63
-rw-r--r--appc/src/main/java/org/openecomp/policy/appc/ResponseStatus.java70
-rw-r--r--appc/src/main/java/org/openecomp/policy/appc/ResponseValue.java61
-rw-r--r--appc/src/main/java/org/openecomp/policy/appc/util/Serialization.java82
-rw-r--r--appc/src/main/resources/definitions.yaml118
-rw-r--r--archetype-closedloop-demo-rules/pom.xml58
-rw-r--r--archetype-closedloop-demo-rules/src/main/resources/META-INF/maven/archetype-metadata.xml77
-rw-r--r--archetype-closedloop-demo-rules/src/main/resources/archetype-resources/pom.xml75
-rw-r--r--archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties55
-rw-r--r--archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json37
-rw-r--r--archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/dcae.onset.json14
-rw-r--r--archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/vFWsim-controller.properties49
-rw-r--r--archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/vFWsim-controller.rest.json31
-rw-r--r--archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/vfwsim-onset.json5
-rw-r--r--archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/resources/ControlLoopDemo__closedLoopControlName__.drl1092
-rw-r--r--archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/resources/META-INF/kmodule.xml29
-rw-r--r--archetype-closedloop-demo-rules/src/test/resources/projects/basic/archetype.properties50
-rw-r--r--archetype-closedloop-demo-rules/src/test/resources/projects/basic/goal.txt0
-rw-r--r--controlloop/pom.xml46
-rw-r--r--controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopEvent.java69
-rw-r--r--controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopEventStatus.java54
-rw-r--r--controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopNotification.java62
-rw-r--r--controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopNotificationType.java72
-rw-r--r--controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopOperation.java139
-rw-r--r--controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopOperationWrapper.java38
-rw-r--r--controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopTargetType.java55
-rw-r--r--controlloop/src/main/java/org/openecomp/policy/controlloop/PhysicalControlLoopEvent.java41
-rw-r--r--controlloop/src/main/java/org/openecomp/policy/controlloop/PhysicalControlLoopNotification.java40
-rw-r--r--controlloop/src/main/java/org/openecomp/policy/controlloop/VirtualControlLoopEvent.java52
-rw-r--r--controlloop/src/main/java/org/openecomp/policy/controlloop/VirtualControlLoopNotification.java53
-rw-r--r--controlloop/src/main/java/org/openecomp/policy/controlloop/util/Serialization.java124
-rw-r--r--controlloop/src/main/resources/definitions.yaml96
-rw-r--r--mso/pom.xml51
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSOAsyncRequestStatus.java63
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSOCloudConfiguration.java44
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSOInstanceReferences.java44
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSOManager.java102
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSOModelInfo.java56
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSOPolicyException.java43
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSORelatedInstance.java49
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSORelatedInstanceListElement.java42
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSORequest.java60
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSORequestDetails.java57
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSORequestError.java59
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSORequestInfo.java66
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSORequestParameters.java47
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSORequestReferences.java38
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSORequestStatus.java51
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSOResponse.java48
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSOServiceException.java48
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/MSOSubscriberInfo.java47
-rw-r--r--mso/src/main/java/org/openecomp/policy/mso/util/Serialization.java32
-rw-r--r--mso/src/test/java/org/openecomp/policy/mso/TestDemo.java164
-rw-r--r--packages/apps/pom.xml77
-rw-r--r--packages/apps/src/assembly/zip.xml40
-rw-r--r--packages/apps/src/files/README.apps.txt8
-rw-r--r--packages/artifacts/pom.xml124
-rw-r--r--packages/artifacts/src/assembly/zip.xml33
-rw-r--r--packages/basex/pom.xml61
-rw-r--r--packages/basex/src/assembly/zip.xml36
-rw-r--r--packages/basex/src/files/bin/create-closed-loop-demo.sh315
-rw-r--r--packages/basex/src/files/config/vDNS-controller.properties55
-rw-r--r--packages/basex/src/files/config/vFW-controller.properties55
-rw-r--r--packages/pom.xml43
-rw-r--r--pom.xml167
-rw-r--r--rest/pom.xml52
-rw-r--r--rest/src/main/java/org/openecomp/policy/rest/RESTManager.java115
-rw-r--r--sdnc/pom.xml51
-rw-r--r--sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequest.java42
-rw-r--r--sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequestHeader.java47
-rw-r--r--sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequestInformation.java52
-rw-r--r--sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequestInput.java46
-rw-r--r--sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCVnfAssignments.java50
-rw-r--r--sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCVnfTopologyIdentifier.java53
-rw-r--r--sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCVnfTopologyInformation.java49
-rw-r--r--sdnc/src/main/java/org/openecomp/policy/sdnc/util/Serialization.java32
-rw-r--r--sdnc/src/test/java/org/openecomp/policy/sdnc/TestDemo.java81
-rw-r--r--template.demo/pom.xml94
-rw-r--r--template.demo/src/main/java/org/openecomp/policy/template/demo/ControlLoopException.java51
-rw-r--r--template.demo/src/main/java/org/openecomp/policy/template/demo/EventManager.java210
-rw-r--r--template.demo/src/main/java/org/openecomp/policy/template/demo/PolicyEngine.java81
-rw-r--r--template.demo/src/main/resources/archetype-resources/src/main/resources/ControlLoopDemo__closedLoopControlName__.drl1270
-rw-r--r--template.demo/src/test/java/org/openecomp/policy/template/demo/TestAPPCPayload.java58
-rw-r--r--template.demo/src/test/java/org/openecomp/policy/template/demo/TestFirewallDemo.java595
-rw-r--r--template.demo/src/test/java/org/openecomp/policy/template/demo/TestMSO.java159
-rw-r--r--template.demo/src/test/resources/aairesponse.json227
-rw-r--r--trafficgenerator/pom.xml46
-rw-r--r--trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGRequest.java41
-rw-r--r--trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStream.java42
-rw-r--r--trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStreams.java42
-rw-r--r--trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/util/Serialization.java32
-rw-r--r--trafficgenerator/src/test/java/org/openecomp/policy/vnf/trafficgenerator/TestDemo.java52
-rw-r--r--vfwsim/pom.xml80
-rw-r--r--vfwsim/src/main/java/org/openecomp/policy/sim/vfw/AppcResponseEvent.java97
-rw-r--r--vfwsim/src/main/java/org/openecomp/policy/sim/vfw/OnsetEvent.java257
-rw-r--r--vfwsim/src/main/resources/META-INF/kmodule.xml27
-rw-r--r--vfwsim/src/main/resources/vFWsim.drl69
131 files changed, 11255 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..a7f6406cf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+target
+.project
+.settings
+.classpath
+.metadata/
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 000000000..81743ce69
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,4 @@
+[gerrit]
+host=gerrit.openecomp.org
+port=29418
+project=policy/drools-applications.git
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 000000000..bcde1da35
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,16 @@
+Copyright © 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.
+
+ECOMP and OpenECOMP are trademarks and service marks of AT&T Intellectual Property.
diff --git a/README.md b/README.md
new file mode 100644
index 000000000..01d56b4ee
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+This source repository contains OpenECOMP Policy application code. The settings file only needs to support the standard Maven repositories (e.g. central = http://repo1.maven.org/maven2/), and any proxy settings needed in your environment.
+
+To build it using Maven 3, run: mvn clean install
diff --git a/aai/pom.xml b/aai/pom.xml
new file mode 100644
index 000000000..d12926304
--- /dev/null
+++ b/aai/pom.xml
@@ -0,0 +1,51 @@
+<!--
+ ============LICENSE_START=======================================================
+ Drools PDP Application Models
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>aai</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>rest</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAIGETResponse.java b/aai/src/main/java/org/openecomp/policy/aai/AAIGETResponse.java
new file mode 100644
index 000000000..c5100cb5b
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAIGETResponse.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAIGETResponse implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7311418432051756161L;
+
+ @SerializedName("relationship-list")
+ public RelationshipList relationshipList;
+
+ public AAIGETResponse() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199CloudRegion.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199CloudRegion.java
new file mode 100644
index 000000000..62737df9c
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199CloudRegion.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199CloudRegion implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -897231529157222683L;
+
+ @SerializedName("cloud-owner")
+ public String cloudOwner;
+
+ @SerializedName("cloud-region-id")
+ public String cloudRegionId;
+
+ @SerializedName("cloud-region-version")
+ public String cloudRegionVersion;
+
+ @SerializedName("complex-name")
+ public String complexName;
+
+ @SerializedName("resource-version")
+ public String resourceVersion;
+
+ public AAINQF199CloudRegion() {
+ }
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ExtraProperties.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ExtraProperties.java
new file mode 100644
index 000000000..8151a2d71
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ExtraProperties.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199ExtraProperties implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4109625574744702319L;
+
+ @SerializedName("extra-property")
+ public List<AAINQF199ExtraProperty> extraProperty = new LinkedList<AAINQF199ExtraProperty>();
+
+ public AAINQF199ExtraProperties() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ExtraProperty.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ExtraProperty.java
new file mode 100644
index 000000000..d3c4a7c8f
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ExtraProperty.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199ExtraProperty implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3861240617222397736L;
+
+ @SerializedName("property-name")
+ public String propertyName;
+
+ @SerializedName("property-value")
+ public String propertyValue;
+
+ public AAINQF199ExtraProperty() {
+ }
+
+ public AAINQF199ExtraProperty(String propertyName, String propertyValue) {
+ this.propertyName = propertyName;
+ this.propertyValue = propertyValue;
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199GenericVNF.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199GenericVNF.java
new file mode 100644
index 000000000..09359c1a9
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199GenericVNF.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199GenericVNF implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 834322706248060559L;
+
+ @SerializedName("vnf-id")
+ public String vnfID;
+
+ @SerializedName("vnf-name")
+ public String vnfName;
+
+ @SerializedName("vnf-name2")
+ public String vnfName2;
+
+ @SerializedName("vnf-type")
+ public String vnfType;
+
+ @SerializedName("service-id")
+ public String serviceId;
+
+ @SerializedName("prov-status")
+ public String provStatus;
+
+ @SerializedName("operational-state")
+ public String operationalState;
+
+ @SerializedName("ipv4-oam-address")
+ public String ipv4OamAddress;
+
+ @SerializedName("ipv4-loopback0-address")
+ public String ipv4Loopback0Address;
+
+ @SerializedName("in-maint")
+ public Boolean inMaint;
+
+ @SerializedName("is-closed-loop-disabled")
+ public Boolean isClosedLoopDisabled;
+
+ @SerializedName("resource-version")
+ public String resourceVersion;
+
+ @SerializedName("encrypted-access-flag")
+ public Boolean encrypedAccessFlag;
+
+ @SerializedName("persona-model-id")
+ public String personaModelId;
+
+ @SerializedName("persona-model-version")
+ public String personaModelVersion;
+
+ public AAINQF199GenericVNF() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199InstanceFilters.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199InstanceFilters.java
new file mode 100644
index 000000000..58b6ad1ef
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199InstanceFilters.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199InstanceFilters implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8993824591338121185L;
+
+ @SerializedName("instance-filter")
+ public List<Map<String, Map<String, String>>> instanceFilter = new LinkedList<Map<String, Map<String, String>>>();
+
+ public AAINQF199InstanceFilters() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199InventoryResponseItem.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199InventoryResponseItem.java
new file mode 100644
index 000000000..9174f4f91
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199InventoryResponseItem.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199InventoryResponseItem implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7142072567154675183L;
+
+ @SerializedName("model-name")
+ public String modelName;
+
+ @SerializedName("vf-module")
+ public AAINQF199VfModule vfModule;
+
+ @SerializedName("service-instance")
+ public AAINQF199ServiceInstance serviceInstance;
+
+ @SerializedName("vserver")
+ public AAINQF199VServer vserver;
+
+ @SerializedName("tenant")
+ public AAINQF199Tenant tenant;
+
+ @SerializedName("cloud-region")
+ public AAINQF199CloudRegion cloudRegion;
+
+ @SerializedName("generic-vnf")
+ public AAINQF199GenericVNF genericVNF;
+
+ @SerializedName("extra-properties")
+ public AAINQF199ExtraProperties extraProperties;
+
+ @SerializedName("inventory-response-items")
+ public AAINQF199InventoryResponseItems items;
+
+ public AAINQF199InventoryResponseItem() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199InventoryResponseItems.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199InventoryResponseItems.java
new file mode 100644
index 000000000..2ce43fc84
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199InventoryResponseItems.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199InventoryResponseItems implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7602807659381179004L;
+
+ @SerializedName("inventory-response-item")
+ public List<AAINQF199InventoryResponseItem> inventoryResponseItems = new LinkedList<AAINQF199InventoryResponseItem>();
+
+ public AAINQF199InventoryResponseItems() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Manager.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Manager.java
new file mode 100644
index 000000000..00110e8ca
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Manager.java
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.openecomp.policy.aai.AAIGETResponse;
+import org.openecomp.policy.aai.util.Serialization;
+import org.openecomp.policy.rest.RESTManager;
+import org.openecomp.policy.rest.RESTManager.Pair;
+
+import com.google.gson.JsonSyntaxException;
+
+public final class AAINQF199Manager {
+
+ public static AAINQF199Response postQuery(String url, String username, String password, AAINQF199Request request, UUID requestID) {
+
+ Map<String, String> headers = new HashMap<String, String>();
+ headers.put("X-FromAppId", "POLICY");
+ headers.put("X-TransactionId", requestID.toString());
+ headers.put("Accept", "application/json");
+
+ url = url + "/aai/search/named-query";
+
+ Pair<Integer, String> httpDetails = RESTManager.post(url, username, password, headers, "application/json", Serialization.gsonPretty.toJson(request));
+
+ if (httpDetails == null) {
+ System.out.println("AAI POST Null Response to " + url);
+ return null;
+ }
+
+ System.out.println(url);
+ System.out.println(httpDetails.a);
+ System.out.println(httpDetails.b);
+ if (httpDetails.a == 200) {
+ try {
+ AAINQF199Response response = Serialization.gsonPretty.fromJson(httpDetails.b, AAINQF199Response.class);
+ return response;
+ } catch (JsonSyntaxException e) {
+ System.err.println("Failed to deserialize into AAIResponse" + e.getLocalizedMessage());
+ }
+ }
+
+ return null;
+ }
+
+ public static AAIGETResponse getQuery(String urlGet, String username, String password, UUID requestID, String vnfId) {
+
+ Map<String, String> headers = new HashMap<String, String>();
+ headers.put("X-FromAppId", "POLICY");
+ headers.put("X-TransactionId", requestID.toString());
+ headers.put("Accept", "application/json");
+
+ urlGet = urlGet + "/aai/v8/network/generic-vnfs/generic-vnf/" + vnfId;
+
+ int attemptsLeft = 3;
+ AAIGETResponse responseGet = null;
+
+ while(attemptsLeft-- > 0){
+
+ Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
+ if (httpDetailsGet == null) {
+ System.out.println("AAI GET Null Response to " + urlGet);
+ return null;
+ }
+
+ System.out.println(urlGet);
+ System.out.println(httpDetailsGet.a);
+ System.out.println(httpDetailsGet.b);
+
+ if (httpDetailsGet.a == 200) {
+ try {
+ responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETResponse.class);
+ return responseGet;
+ } catch (JsonSyntaxException e) {
+ System.err.println("Failed to deserialize into AAIResponse" + e.getLocalizedMessage());
+ }
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {}
+
+ }
+
+ return null;
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199NamedQuery.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199NamedQuery.java
new file mode 100644
index 000000000..61bad5f17
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199NamedQuery.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+import java.util.UUID;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199NamedQuery implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3277980060302645333L;
+
+ @SerializedName("named-query-uuid")
+ public UUID namedQueryUUID;
+
+ public AAINQF199NamedQuery() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199QueryParameters.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199QueryParameters.java
new file mode 100644
index 000000000..113a3d17e
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199QueryParameters.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199QueryParameters implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4291227193197126982L;
+
+ @SerializedName("named-query")
+ public AAINQF199NamedQuery namedQuery;
+
+ public AAINQF199QueryParameters() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Request.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Request.java
new file mode 100644
index 000000000..6b504640d
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Request.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+
+/*
+ *
+ * {
+ "query-parameters": {
+ "named-query": {
+ "named-query-uuid": "f199cb88-5e69-4b1f-93e0-6f257877d066"
+ }
+ },
+ "instance-filters": {
+ "instance-filter": [
+ {
+ "vserver": {
+ "vserver-name": "dfw1lb01lb01"
+ }
+ }
+ ]
+ }
+}
+
+ *
+ */
+
+public class AAINQF199Request implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("query-parameters")
+ public AAINQF199QueryParameters queryParameters;
+ @SerializedName("instance-filters")
+ public AAINQF199InstanceFilters instanceFilters;
+
+ public AAINQF199Request() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199RequestWrapper.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199RequestWrapper.java
new file mode 100644
index 000000000..651d6750f
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199RequestWrapper.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.util.UUID;
+
+public class AAINQF199RequestWrapper {
+
+ public UUID requestID;
+ public AAINQF199Request aainqf199request;
+
+ public AAINQF199RequestWrapper() {
+
+ }
+
+ public AAINQF199RequestWrapper(UUID requestID, AAINQF199Request aainqf199request){
+ this.requestID = requestID;
+ this.aainqf199request = aainqf199request;
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Response.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Response.java
new file mode 100644
index 000000000..c85e942c7
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Response.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199Response implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8411407444051746101L;
+
+ @SerializedName("inventory-response-item")
+ public List<AAINQF199InventoryResponseItem> inventoryResponseItems = new LinkedList<AAINQF199InventoryResponseItem>();
+
+ public AAINQF199Response() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ResponseWrapper.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ResponseWrapper.java
new file mode 100644
index 000000000..908b57d11
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ResponseWrapper.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.util.UUID;
+
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Response;
+
+public class AAINQF199ResponseWrapper {
+
+ public UUID requestID;
+ public AAINQF199Response aainqf199response;
+
+ public AAINQF199ResponseWrapper() {
+
+ }
+
+ public AAINQF199ResponseWrapper(UUID requestID, AAINQF199Response aainqf199response){
+ this.requestID = requestID;
+ this.aainqf199response = aainqf199response;
+ }
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ServiceInstance.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ServiceInstance.java
new file mode 100644
index 000000000..6e7c008e3
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199ServiceInstance.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199ServiceInstance implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -8000944396593889586L;
+
+ @SerializedName("service-instance-id")
+ public String serviceInstanceID;
+
+ @SerializedName("service-instance-name")
+ public String serviceInstanceName;
+
+ @SerializedName("persona-model-id")
+ public String personaModelId;
+
+ @SerializedName("persona-model-version")
+ public String personaModelVersion;
+
+ @SerializedName("service-instance-location-id")
+ public String serviceInstanceLocationId;
+
+ @SerializedName("resource-version")
+ public String resourceVersion;
+
+ public AAINQF199ServiceInstance() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Tenant.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Tenant.java
new file mode 100644
index 000000000..473cb9e7a
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199Tenant.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199Tenant implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4702784101671984364L;
+
+ @SerializedName("tenant-id")
+ public String tenantId;
+
+ @SerializedName("tenant-name")
+ public String tenantName;
+
+ @SerializedName("resource-version")
+ public String resourceVersion;
+
+ public AAINQF199Tenant() {
+ }
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199VServer.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199VServer.java
new file mode 100644
index 000000000..9704b4b83
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199VServer.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199VServer {
+
+ @SerializedName("vserver-id")
+ public String vserverId;
+
+ @SerializedName("vserver-name")
+ public String vserverName;
+
+ @SerializedName("vserver-name2")
+ public String vserverName2;
+
+ @SerializedName("prov-status")
+ public String provStatus;
+
+ @SerializedName("vserver-selflink")
+ public String vserverSelflink;
+
+ @SerializedName("in-maint")
+ public Boolean inMaint;
+
+ @SerializedName("is-closed-loop-disabled")
+ public Boolean isClosedLoopDisabled;
+
+ @SerializedName("resource-version")
+ public String resourceVersion;
+
+ public AAINQF199VServer() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199VfModule.java b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199VfModule.java
new file mode 100644
index 000000000..d03f8daf2
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/AAINQF199/AAINQF199VfModule.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.AAINQF199;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AAINQF199VfModule implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8019133081429638231L;
+
+ @SerializedName("vf-module-id")
+ public String vfModuleId;
+
+ @SerializedName("vf-module-name")
+ public String vfModuleName;
+
+ @SerializedName("heat-stack-id")
+ public String heatStackId;
+
+ @SerializedName("orchestration-status")
+ public String orchestrationStatus;
+
+ @SerializedName("is-base-vf-module")
+ public Boolean isBaseVfModule;
+
+ @SerializedName("resource-version")
+ public String resourceVersion;
+
+ @SerializedName("persona-model-id")
+ public String personaModelId;
+
+ @SerializedName("persona-model-version")
+ public String personaModelVersion;
+
+ @SerializedName("widget-model-id")
+ public String widgetModelId;
+
+ @SerializedName("widget-model-version")
+ public String widgetModelVersion;
+
+ @SerializedName("contrail-service-instance-fqdn")
+ public String contrailServiceInstanceFqdn;
+
+ public AAINQF199VfModule() {
+ }
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/RelatedToPropertyItem.java b/aai/src/main/java/org/openecomp/policy/aai/RelatedToPropertyItem.java
new file mode 100644
index 000000000..6a6a4a6bc
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/RelatedToPropertyItem.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai;
+
+import com.google.gson.annotations.SerializedName;
+
+public class RelatedToPropertyItem {
+
+ @SerializedName("property-key")
+ public String propertyKey;
+ @SerializedName("property-value")
+ public String propertyValue;
+
+ public RelatedToPropertyItem() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/RelationshipItem.java b/aai/src/main/java/org/openecomp/policy/aai/RelationshipItem.java
new file mode 100644
index 000000000..dd057d6d4
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/RelationshipItem.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import com.google.gson.annotations.SerializedName;
+
+public class RelationshipItem {
+
+ @SerializedName("related-to-property")
+ public List<RelatedToPropertyItem> relatedToProperty = new LinkedList<RelatedToPropertyItem>();
+
+ public RelationshipItem() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/RelationshipList.java b/aai/src/main/java/org/openecomp/policy/aai/RelationshipList.java
new file mode 100644
index 000000000..1f7658df9
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/RelationshipList.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import com.google.gson.annotations.SerializedName;
+
+public class RelationshipList {
+
+ @SerializedName("relationship")
+ public List<RelationshipItem> relationship = new LinkedList<RelationshipItem>();
+
+ public RelationshipList() {
+ }
+
+}
diff --git a/aai/src/main/java/org/openecomp/policy/aai/util/Serialization.java b/aai/src/main/java/org/openecomp/policy/aai/util/Serialization.java
new file mode 100644
index 000000000..d7a10db2d
--- /dev/null
+++ b/aai/src/main/java/org/openecomp/policy/aai/util/Serialization.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai.util;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public final class Serialization {
+
+ final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
+ .setPrettyPrinting()
+// .registerTypeAdapter(AAIQueryParameters.class, new notificationTypeAdapter())
+ .create();
+}
diff --git a/aai/src/test/java/org/openecomp/policy/aai/TestDemo.java b/aai/src/test/java/org/openecomp/policy/aai/TestDemo.java
new file mode 100644
index 000000000..f2fb24702
--- /dev/null
+++ b/aai/src/test/java/org/openecomp/policy/aai/TestDemo.java
@@ -0,0 +1,240 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * aai
+ * ================================================================================
+ * 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.openecomp.policy.aai;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.UUID;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199CloudRegion;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperties;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperty;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199GenericVNF;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199VServer;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199VfModule;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InstanceFilters;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Manager;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199NamedQuery;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199QueryParameters;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Response;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ServiceInstance;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Tenant;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Request;
+import org.openecomp.policy.aai.util.Serialization;
+
+public class TestDemo {
+
+ @Test
+ public void test() {
+
+ //
+ // Test AAINQF199Request
+ //
+ AAINQF199Request request = new AAINQF199Request();
+ request.queryParameters = new AAINQF199QueryParameters();
+ request.queryParameters.namedQuery = new AAINQF199NamedQuery();
+ request.queryParameters.namedQuery.namedQueryUUID = UUID.fromString("f199cb88-5e69-4b1f-93e0-6f257877d066");
+ request.instanceFilters = new AAINQF199InstanceFilters();
+ Map<String, Map<String, String>> vserver = new HashMap<String, Map<String, String>>();
+ Map<String, String> values = new HashMap<String, String>();
+ values.put("vserver-name", "dfw1lb01lb01");
+ vserver.put("vserver", values);
+ request.instanceFilters.instanceFilter.add(vserver);
+
+ String body = Serialization.gsonPretty.toJson(request);
+
+ System.out.println(body);
+
+ System.out.println();
+
+
+/*
+ AAINQF199InventoryResponseItem serviceItem = new AAINQF199InventoryResponseItem();
+ serviceItem.serviceInstance = new AAINQF199ServiceInstance();
+ serviceItem.serviceInstance.serviceInstanceID = "service-instance-id-Manisha-01";
+
+ AAINQF199InventoryResponseItem genericVNFItem = new AAINQF199InventoryResponseItem();
+ genericVNFItem.genericVNF = new AAINQF199GenericVNF();
+ genericVNFItem.genericVNF.vnfID = "generic-vnf-id-Manisha-01";
+ genericVNFItem.items = new AAINQF199InventoryResponseItems();
+ genericVNFItem.items.inventoryResponseItems = new LinkedList<AAINQF199InventoryResponseItem>();
+ genericVNFItem.items.inventoryResponseItems.add(serviceItem);
+
+ AAINQF199InventoryResponseItem vserverItem = new AAINQF199InventoryResponseItem();
+ vserverItem.vserver = new AAINQF199VServer();
+ vserverItem.vserver.vserverId = "vserver-id-Manisha-01";
+ vserverItem.vserver.vserverName = "vserver-name-16102016-aai3255-data-11-1";
+ vserverItem.items = new AAINQF199InventoryResponseItems();
+ vserverItem.items.inventoryResponseItems = new LinkedList<AAINQF199InventoryResponseItem>();
+ vserverItem.items.inventoryResponseItems.add(genericVNFItem);
+*/
+
+
+ //
+ // Test AAINQF199Response
+ //
+ AAINQF199InventoryResponseItem serviceItem = new AAINQF199InventoryResponseItem();
+ serviceItem.modelName = "service-instance";
+ serviceItem.serviceInstance = new AAINQF199ServiceInstance();
+ serviceItem.serviceInstance.serviceInstanceID = "dhv-test-vhnfportal-service-instance-id";
+ serviceItem.serviceInstance.serviceInstanceName = "dhv-test-service-instance-name1";
+ serviceItem.serviceInstance.personaModelId = "82194af1-3c2c-485a-8f44-420e22a9eaa4";
+ serviceItem.serviceInstance.personaModelVersion = "1.0";
+ serviceItem.serviceInstance.serviceInstanceLocationId = "dhv-test-service-instance-location-id1";
+ serviceItem.serviceInstance.resourceVersion = "1485366092";
+ serviceItem.extraProperties = new AAINQF199ExtraProperties();
+ serviceItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name", "service-instance"));
+ serviceItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-type", "widget"));
+ serviceItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-version", "1.0"));
+ serviceItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4"));
+ serviceItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9"));
+
+
+ AAINQF199InventoryResponseItem vfModuleItem = new AAINQF199InventoryResponseItem();
+ vfModuleItem.modelName = "vf-module";
+ vfModuleItem.vfModule = new AAINQF199VfModule();
+ vfModuleItem.vfModule.vfModuleId = "example-vf-module-id-val-49261";
+ vfModuleItem.vfModule.vfModuleName = "example-vf-module-name-val-73074";
+ vfModuleItem.vfModule.heatStackId = "example-heat-stack-id-val-86300";
+ vfModuleItem.vfModule.orchestrationStatus = "example-orchestration-status-val-56523";
+ vfModuleItem.vfModule.isBaseVfModule = true;
+ vfModuleItem.vfModule.resourceVersion = "1485366450";
+ vfModuleItem.vfModule.personaModelId = "ef86f9c5-2165-44f3-8fc3-96018b609ea5";
+ vfModuleItem.vfModule.personaModelVersion = "1.0";
+ vfModuleItem.vfModule.widgetModelId = "example-widget-model-id-val-92571";
+ vfModuleItem.vfModule.widgetModelVersion = "example-widget-model-version-val-83317";
+ vfModuleItem.vfModule.contrailServiceInstanceFqdn = "example-contrail-service-instance-fqdn-val-86796";
+ vfModuleItem.extraProperties = new AAINQF199ExtraProperties();
+ vfModuleItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name", "vf-module"));
+ vfModuleItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-type", "widget"));
+ vfModuleItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-version", "1.0"));
+ vfModuleItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5"));
+ vfModuleItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a"));
+
+
+ AAINQF199InventoryResponseItem genericVNFItem = new AAINQF199InventoryResponseItem();
+ genericVNFItem.modelName = "generic-vnf";
+ genericVNFItem.genericVNF = new AAINQF199GenericVNF();
+ genericVNFItem.genericVNF.vnfID = "dhv-test-gvnf";
+ genericVNFItem.genericVNF.vnfName = "dhv-test-gvnf-name";
+ genericVNFItem.genericVNF.vnfName2 = "dhv-test-gvnf-name2";
+ genericVNFItem.genericVNF.vnfType = "SW";
+ genericVNFItem.genericVNF.serviceId = "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4";
+ genericVNFItem.genericVNF.provStatus = "PREPROV";
+ genericVNFItem.genericVNF.operationalState = "dhv-test-operational-state";
+ genericVNFItem.genericVNF.ipv4OamAddress = "dhv-test-gvnf-ipv4-oam-address";
+ genericVNFItem.genericVNF.ipv4Loopback0Address = "dhv-test-gvnfipv4-loopback0-address";
+ genericVNFItem.genericVNF.inMaint = false;
+ genericVNFItem.genericVNF.isClosedLoopDisabled = false;
+ genericVNFItem.genericVNF.resourceVersion = "1485366450";
+ genericVNFItem.genericVNF.encrypedAccessFlag = true;
+ genericVNFItem.genericVNF.personaModelId = "acc6edd8-a8d4-4b93-afaa-0994068be14c";
+ genericVNFItem.genericVNF.personaModelVersion = "1.0";
+ genericVNFItem.extraProperties = new AAINQF199ExtraProperties();
+ genericVNFItem.extraProperties.extraProperty = new LinkedList<AAINQF199ExtraProperty>();
+ genericVNFItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name", "generic-vnf"));
+ genericVNFItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-type", "widget"));
+ genericVNFItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-version", "1.0"));
+ genericVNFItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c"));
+ genericVNFItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9"));
+ genericVNFItem.items = new AAINQF199InventoryResponseItems();
+ genericVNFItem.items.inventoryResponseItems = new LinkedList<AAINQF199InventoryResponseItem>();
+ genericVNFItem.items.inventoryResponseItems.add(serviceItem);
+ genericVNFItem.items.inventoryResponseItems.add(vfModuleItem);
+
+
+ AAINQF199InventoryResponseItem cloudItem = new AAINQF199InventoryResponseItem();
+ cloudItem.cloudRegion = new AAINQF199CloudRegion();
+ cloudItem.cloudRegion.cloudOwner = "OWNER";
+ cloudItem.cloudRegion.cloudRegionId = "REGIONID";
+ cloudItem.cloudRegion.cloudRegionVersion = "2.5";
+ cloudItem.cloudRegion.complexName = "COMPLEXNAME";
+ cloudItem.cloudRegion.resourceVersion = "1485365988";
+
+
+ AAINQF199InventoryResponseItem tenantItem = new AAINQF199InventoryResponseItem();
+ tenantItem.tenant = new AAINQF199Tenant();
+ tenantItem.tenant.tenantId = "dhv-test-tenant";
+ tenantItem.tenant.tenantName = "dhv-test-tenant-name";
+ tenantItem.tenant.resourceVersion = "1485366334";
+ tenantItem.items = new AAINQF199InventoryResponseItems();
+ tenantItem.items.inventoryResponseItems = new LinkedList<AAINQF199InventoryResponseItem>();
+ tenantItem.items.inventoryResponseItems.add(cloudItem);
+
+
+ AAINQF199InventoryResponseItem vserverItem = new AAINQF199InventoryResponseItem();
+ vserverItem.vserver = new AAINQF199VServer();
+ vserverItem.vserver.vserverId = "dhv-test-vserver";
+ vserverItem.vserver.vserverName = "dhv-test-vserver-name";
+ vserverItem.vserver.vserverName2 = "dhv-test-vserver-name2";
+ vserverItem.vserver.provStatus = "PREPROV";
+ vserverItem.vserver.vserverSelflink = "dhv-test-vserver-selflink";
+ vserverItem.vserver.inMaint = false;
+ vserverItem.vserver.isClosedLoopDisabled = false;
+ vserverItem.vserver.resourceVersion = "1485366417";
+ vserverItem.items = new AAINQF199InventoryResponseItems();
+ vserverItem.items.inventoryResponseItems = new LinkedList<AAINQF199InventoryResponseItem>();
+ vserverItem.items.inventoryResponseItems.add(genericVNFItem);
+ vserverItem.items.inventoryResponseItems.add(tenantItem);
+
+
+ AAINQF199Response aaiResponse = new AAINQF199Response();
+ aaiResponse.inventoryResponseItems.add(vserverItem);
+
+ body = Serialization.gsonPretty.toJson(aaiResponse);
+
+ System.out.println(body);
+
+
+ }
+
+ @Ignore
+ @Test
+ public void testHttp() {
+ AAINQF199Request request = new AAINQF199Request();
+ request.queryParameters = new AAINQF199QueryParameters();
+ request.queryParameters.namedQuery = new AAINQF199NamedQuery();
+ request.queryParameters.namedQuery.namedQueryUUID = UUID.fromString("f199cb88-5e69-4b1f-93e0-6f257877d066");
+ request.instanceFilters = new AAINQF199InstanceFilters();
+ Map<String, Map<String, String>> vserver = new HashMap<String, Map<String, String>>();
+ Map<String, String> values = new HashMap<String, String>();
+ values.put("vserver-name", "dfw1lb01lb01");
+ vserver.put("vserver", values);
+ request.instanceFilters.instanceFilter.add(vserver);
+
+ String body = Serialization.gsonPretty.toJson(request);
+
+ System.out.println(body);
+
+ AAINQF199Response response = AAINQF199Manager.postQuery("http://localhost:8080/TestREST/Test", "POLICY", "POLICY", request, UUID.randomUUID());
+
+ body = Serialization.gsonPretty.toJson(response);
+
+ System.out.println(body);
+
+ }
+
+}
diff --git a/aai/src/test/resources/response.json b/aai/src/test/resources/response.json
new file mode 100644
index 000000000..3d7a2c1f0
--- /dev/null
+++ b/aai/src/test/resources/response.json
@@ -0,0 +1,69 @@
+{
+ "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": true,
+ "resource-version": "1477946963"
+ },
+ "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"
+ },
+ "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": {}
+ }]
+ }
+ }]
+ }
+ }]
+}
diff --git a/appc/pom.xml b/appc/pom.xml
new file mode 100644
index 000000000..893706c1d
--- /dev/null
+++ b/appc/pom.xml
@@ -0,0 +1,46 @@
+<!--
+ ============LICENSE_START=======================================================
+ Drools PDP Application Models
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>appc</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project> \ No newline at end of file
diff --git a/appc/src/main/java/org/openecomp/policy/appc/CommonHeader.java b/appc/src/main/java/org/openecomp/policy/appc/CommonHeader.java
new file mode 100644
index 000000000..dd743099c
--- /dev/null
+++ b/appc/src/main/java/org/openecomp/policy/appc/CommonHeader.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.openecomp.policy.appc;
+
+import java.io.Serializable;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.UUID;
+
+public class CommonHeader implements Serializable {
+
+ private static final long serialVersionUID = -3581658269910980336L;
+
+ public Instant TimeStamp = Instant.now();
+ public String APIver = "1.01";
+ public String OriginatorID;
+ public UUID RequestID;
+ public String SubRequestID;
+ public Collection<String> RequestTrack = new ArrayList<String>();
+ public Collection<Map<String, String>> Flags = new ArrayList<Map<String, String>>();
+
+ public CommonHeader() {
+
+ }
+
+ public CommonHeader(CommonHeader commonHeader) {
+ this.OriginatorID = commonHeader.OriginatorID;
+ this.RequestID = commonHeader.RequestID;
+ this.SubRequestID = commonHeader.SubRequestID;
+ if (commonHeader.RequestTrack != null) {
+ this.RequestTrack.addAll(commonHeader.RequestTrack);
+ }
+ if (commonHeader.Flags != null) {
+ this.Flags.addAll(commonHeader.Flags);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "CommonHeader [TimeStamp=" + TimeStamp + ", APIver=" + APIver + ", OriginatorID=" + OriginatorID
+ + ", RequestID=" + RequestID + ", SubrequestID=" + SubRequestID + ", RequestTrack=" + RequestTrack
+ + ", Flags=" + Flags + "]";
+ }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((APIver == null) ? 0 : APIver.hashCode());
+ result = prime * result + ((Flags == null) ? 0 : Flags.hashCode());
+ result = prime * result + ((OriginatorID == null) ? 0 : OriginatorID.hashCode());
+ result = prime * result + ((RequestID == null) ? 0 : RequestID.hashCode());
+ result = prime * result + ((RequestTrack == null) ? 0 : RequestTrack.hashCode());
+ result = prime * result + ((SubRequestID == null) ? 0 : SubRequestID.hashCode());
+ result = prime * result + ((TimeStamp == null) ? 0 : TimeStamp.hashCode());
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CommonHeader other = (CommonHeader) obj;
+ if (APIver == null) {
+ if (other.APIver != null)
+ return false;
+ } else if (!APIver.equals(other.APIver))
+ return false;
+ if (Flags == null) {
+ if (other.Flags != null)
+ return false;
+ } else if (!Flags.equals(other.Flags))
+ return false;
+ if (OriginatorID == null) {
+ if (other.OriginatorID != null)
+ return false;
+ } else if (!OriginatorID.equals(other.OriginatorID))
+ return false;
+ if (RequestID == null) {
+ if (other.RequestID != null)
+ return false;
+ } else if (!RequestID.equals(other.RequestID))
+ return false;
+ if (RequestTrack == null) {
+ if (other.RequestTrack != null)
+ return false;
+ } else if (!RequestTrack.equals(other.RequestTrack))
+ return false;
+ if (SubRequestID == null) {
+ if (other.SubRequestID != null)
+ return false;
+ } else if (!SubRequestID.equals(other.SubRequestID))
+ return false;
+ if (TimeStamp == null) {
+ if (other.TimeStamp != null)
+ return false;
+ } else if (!TimeStamp.equals(other.TimeStamp))
+ return false;
+ return true;
+ }
+
+}
diff --git a/appc/src/main/java/org/openecomp/policy/appc/Request.java b/appc/src/main/java/org/openecomp/policy/appc/Request.java
new file mode 100644
index 000000000..933692378
--- /dev/null
+++ b/appc/src/main/java/org/openecomp/policy/appc/Request.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.openecomp.policy.appc;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Request implements Serializable{
+
+ private static final long serialVersionUID = -3912323643990646431L;
+
+ public CommonHeader CommonHeader;
+ public String Action;
+ public String TargetID;
+ public String ObjectID;
+ public Map<String, Object> Payload = new HashMap<String, Object>();
+
+ public Request() {
+
+ }
+
+ public CommonHeader getCommonHeader() {
+ return CommonHeader;
+ }
+
+ public Map<String, Object> getPayload() {
+ return Payload;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((Action == null) ? 0 : Action.hashCode());
+ result = prime * result + ((CommonHeader == null) ? 0 : CommonHeader.hashCode());
+ result = prime * result + ((ObjectID == null) ? 0 : ObjectID.hashCode());
+ result = prime * result + ((Payload == null) ? 0 : Payload.hashCode());
+ result = prime * result + ((TargetID == null) ? 0 : TargetID.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Request other = (Request) obj;
+ if (Action == null) {
+ if (other.Action != null)
+ return false;
+ } else if (!Action.equals(other.Action))
+ return false;
+ if (CommonHeader == null) {
+ if (other.CommonHeader != null)
+ return false;
+ } else if (!CommonHeader.equals(other.CommonHeader))
+ return false;
+ if (ObjectID == null) {
+ if (other.ObjectID != null)
+ return false;
+ } else if (!ObjectID.equals(other.ObjectID))
+ return false;
+ if (Payload == null) {
+ if (other.Payload != null)
+ return false;
+ } else if (!Payload.equals(other.Payload))
+ return false;
+ if (TargetID == null) {
+ if (other.TargetID != null)
+ return false;
+ } else if (!TargetID.equals(other.TargetID))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Request [CommonHeader=" + CommonHeader + ", Action=" + Action + ", TargetID=" + TargetID + ", ObjectID="
+ + ObjectID + ", Payload=" + Payload + "]";
+ }
+
+}
diff --git a/appc/src/main/java/org/openecomp/policy/appc/Response.java b/appc/src/main/java/org/openecomp/policy/appc/Response.java
new file mode 100644
index 000000000..a093f35a1
--- /dev/null
+++ b/appc/src/main/java/org/openecomp/policy/appc/Response.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.openecomp.policy.appc;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Response implements Serializable {
+
+ private static final long serialVersionUID = 434953706339865151L;
+
+ public CommonHeader CommonHeader;
+ public ResponseStatus Status = new ResponseStatus();
+ public Map<String, Object> Payload = new HashMap<String, Object>();
+
+ public Response() {
+
+ }
+
+ public Response(Request request) {
+ this.CommonHeader = new CommonHeader(request.CommonHeader);
+ if (request.Payload != null) {
+ this.Payload.putAll(request.Payload);
+ }
+ }
+
+ public CommonHeader getCommonHeader() {
+ return CommonHeader;
+ }
+
+ public void setCommonHeader(CommonHeader commonHeader) {
+ CommonHeader = commonHeader;
+ }
+
+ public ResponseStatus getStatus() {
+ return Status;
+ }
+
+ public void setStatus(ResponseStatus status) {
+ Status = status;
+ }
+
+ public Map<String, Object> getPayload() {
+ return Payload;
+ }
+
+ public void setPayload(Map<String, Object> payload) {
+ Payload = payload;
+ }
+
+ @Override
+ public String toString() {
+ return "Response [CommonHeader=" + CommonHeader + ", Status=" + Status + ", Payload=" + Payload + "]";
+ }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((CommonHeader == null) ? 0 : CommonHeader.hashCode());
+ result = prime * result + ((Payload == null) ? 0 : Payload.hashCode());
+ result = prime * result + ((Status == null) ? 0 : Status.hashCode());
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Response other = (Response) obj;
+ if (CommonHeader == null) {
+ if (other.CommonHeader != null)
+ return false;
+ } else if (!CommonHeader.equals(other.CommonHeader))
+ return false;
+ if (Payload == null) {
+ if (other.Payload != null)
+ return false;
+ } else if (!Payload.equals(other.Payload))
+ return false;
+ if (Status == null) {
+ if (other.Status != null)
+ return false;
+ } else if (!Status.equals(other.Status))
+ return false;
+ return true;
+ }
+
+
+
+}
diff --git a/appc/src/main/java/org/openecomp/policy/appc/ResponseCode.java b/appc/src/main/java/org/openecomp/policy/appc/ResponseCode.java
new file mode 100644
index 000000000..11c5539b1
--- /dev/null
+++ b/appc/src/main/java/org/openecomp/policy/appc/ResponseCode.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.openecomp.policy.appc;
+
+public enum ResponseCode {
+ ACCEPT(100),
+ ERROR(200),
+ REJECT(300),
+ SUCCESS(400),
+ FAILURE(500)
+ ;
+
+ private Integer code;
+
+ private ResponseCode(int code) {
+ this.code = code;
+ }
+
+ public int getValue() {
+ return this.code;
+ }
+
+ public String toString() {
+ return Integer.toString(this.code);
+ }
+
+ public static ResponseCode toResponseCode(int code) {
+ if (code == ACCEPT.code) {
+ return ACCEPT;
+ }
+ if (code == ERROR.code) {
+ return ERROR;
+ }
+ if (code == REJECT.code) {
+ return REJECT;
+ }
+ if (code == SUCCESS.code) {
+ return SUCCESS;
+ }
+ if (code == FAILURE.code) {
+ return FAILURE;
+ }
+ return null;
+ }
+}
diff --git a/appc/src/main/java/org/openecomp/policy/appc/ResponseStatus.java b/appc/src/main/java/org/openecomp/policy/appc/ResponseStatus.java
new file mode 100644
index 000000000..f8adb21da
--- /dev/null
+++ b/appc/src/main/java/org/openecomp/policy/appc/ResponseStatus.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.openecomp.policy.appc;
+
+import java.io.Serializable;
+
+public class ResponseStatus implements Serializable {
+
+ private static final long serialVersionUID = 2421770469587860452L;
+
+ public int Code;
+ public String Value;
+ public String Description;
+
+ @Override
+ public String toString() {
+ return "ResponseStatus [Code=" + Code + ", Value=" + Value + ", Description=" + Description + "]";
+ }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + Code;
+ result = prime * result + ((Description == null) ? 0 : Description.hashCode());
+ result = prime * result + ((Value == null) ? 0 : Value.hashCode());
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ResponseStatus other = (ResponseStatus) obj;
+ if (Code != other.Code)
+ return false;
+ if (Description == null) {
+ if (other.Description != null)
+ return false;
+ } else if (!Description.equals(other.Description))
+ return false;
+ if (Value == null) {
+ if (other.Value != null)
+ return false;
+ } else if (!Value.equals(other.Value))
+ return false;
+ return true;
+ }
+
+}
diff --git a/appc/src/main/java/org/openecomp/policy/appc/ResponseValue.java b/appc/src/main/java/org/openecomp/policy/appc/ResponseValue.java
new file mode 100644
index 000000000..18a1c2953
--- /dev/null
+++ b/appc/src/main/java/org/openecomp/policy/appc/ResponseValue.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.openecomp.policy.appc;
+
+public enum ResponseValue {
+ ACCEPT("ACCEPT"),
+ ERROR("ERROR"),
+ REJECT("REJECT"),
+ SUCCESS("SUCCESS"),
+ FAILURE("FAILURE")
+ ;
+
+ private String value;
+
+ private ResponseValue(String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return this.value;
+ }
+
+ public static ResponseValue toResponseValue(String value) {
+ if (value.toString().equals(ACCEPT.toString())) {
+ return ACCEPT;
+ }
+ if (value.toString().equals(ERROR.toString())) {
+ return ERROR;
+ }
+ if (value.toString().equals(REJECT.toString())) {
+ return REJECT;
+ }
+ if (value.toString().equals(SUCCESS.toString())) {
+ return SUCCESS;
+ }
+ if (value.toString().equals(FAILURE.toString())) {
+ return FAILURE;
+ }
+
+ return null;
+ }
+
+}
diff --git a/appc/src/main/java/org/openecomp/policy/appc/util/Serialization.java b/appc/src/main/java/org/openecomp/policy/appc/util/Serialization.java
new file mode 100644
index 000000000..b1b3ad8aa
--- /dev/null
+++ b/appc/src/main/java/org/openecomp/policy/appc/util/Serialization.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.openecomp.policy.appc.util;
+
+import java.lang.reflect.Type;
+import java.time.Instant;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+public final class Serialization {
+
+ public static DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+
+ public static class gsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+
+ public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
+ throws JsonParseException {
+ try {
+ return ZonedDateTime.parse(element.getAsString(), format);
+ } catch (Exception e) {
+ System.err.println(e);
+ }
+ return null;
+ }
+
+ public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) {
+ return new JsonPrimitive(datetime.format(format));
+ }
+ }
+ public static class gsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ return Instant.ofEpochMilli(json.getAsLong());
+ }
+
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toEpochMilli());
+ }
+
+ }
+
+ public static final Gson gsonPretty = new GsonBuilder()
+ .disableHtmlEscaping()
+ .setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
+ .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
+// .registerTypeAdapter(CommonHeader1607.class, new gsonCommonHeaderInstance())
+// .registerTypeAdapter(ResponseStatus1607.class, new gsonResponseStatus())
+ .create();
+
+}
diff --git a/appc/src/main/resources/definitions.yaml b/appc/src/main/resources/definitions.yaml
new file mode 100644
index 000000000..680a9929c
--- /dev/null
+++ b/appc/src/main/resources/definitions.yaml
@@ -0,0 +1,118 @@
+###
+# ============LICENSE_START=======================================================
+# appc
+# ================================================================================
+# 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=========================================================
+###
+
+Request:
+ type: object
+ properties:
+ CommonHeader:
+ type: object
+ properties:
+ TimeStamp:
+ type: string
+ APIver:
+ type: string
+ value: '1.01'
+ OriginatorID:
+ type: string
+ RequestID:
+ type: string
+ pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
+ SubRequestID:
+ type: string
+ Flags:
+ type: object
+ required:
+ - TimeStamp
+ - APIver
+ - OriginatorID
+ - RequestID
+ Action:
+ type: string
+ enum:
+ - Audit
+ - ActionStatus
+ - BlockAudits
+ - Configure
+ - HealthCheck
+ - Install
+ - LiveUpgrade
+ - Migrate
+ - ModifyConfig
+ - Query
+ - Rebuild
+ - Reconfigure
+ - Restart
+ - Rollback
+ - Scale
+ - Start
+ - Stop
+ - Sync
+ - Terminate
+ - Test
+ - Upgrade
+ TargetID:
+ type: string
+ ObjectID:
+ type: string
+ Payload:
+ type: object
+ required:
+ - CommonHeader
+ - Action
+ - TargetID
+Response:
+ type: object
+ properties:
+ CommonHeader:
+ type: object
+ properties:
+ TimeStamp:
+ type: string
+ APIver:
+ type: string
+ OriginatorID:
+ type: string
+ RequestID:
+ type: string
+ SubRequestID:
+ type: string
+ Flags:
+ type: object
+ required:
+ - TimeStamp
+ - APIver
+ - OriginatorID
+ - RequestID
+ Status:
+ type: object
+ properties:
+ Code:
+ type: integer
+ Value:
+ type: string
+ required:
+ - Code
+ - Value
+ Payload:
+ type: object
+ required:
+ - CommonHeader
+ - Status
+
diff --git a/archetype-closedloop-demo-rules/pom.xml b/archetype-closedloop-demo-rules/pom.xml
new file mode 100644
index 000000000..9d9f404e1
--- /dev/null
+++ b/archetype-closedloop-demo-rules/pom.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Drools PDP Application Models
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>archetype-closedloop-demo-rules</artifactId>
+ <packaging>maven-archetype</packaging>
+
+ <name>archetype-closed-loop-demo-rules</name>
+ <description>archetype to generate a closed loop demo rules jar</description>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.4</version>
+ </extension>
+ </extensions>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
diff --git a/archetype-closedloop-demo-rules/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetype-closedloop-demo-rules/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 000000000..a0b5506fc
--- /dev/null
+++ b/archetype-closedloop-demo-rules/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ archetype-closed-loop-demo-rules
+ ================================================================================
+ 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=========================================================
+ -->
+
+<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
+ name="closed-loop-rules"
+ xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <requiredProperties>
+ <requiredProperty key="closedLoopControlName"></requiredProperty>
+ <requiredProperty key="policyScope"></requiredProperty>
+ <requiredProperty key="policyName"></requiredProperty>
+ <requiredProperty key="policyVersion"></requiredProperty>
+ <requiredProperty key="actor"></requiredProperty>
+ <requiredProperty key="aaiURL"></requiredProperty>
+ <requiredProperty key="aaiUsername"></requiredProperty>
+ <requiredProperty key="aaiPassword"></requiredProperty>
+ <requiredProperty key="aaiNamedQueryUUID"></requiredProperty>
+ <requiredProperty key="aaiPatternMatch"></requiredProperty>
+ <requiredProperty key="msoURL"></requiredProperty>
+ <requiredProperty key="msoUsername"></requiredProperty>
+ <requiredProperty key="msoPassword"></requiredProperty>
+ <requiredProperty key="appcTopic"></requiredProperty>
+ <requiredProperty key="appcServers"></requiredProperty>
+ <requiredProperty key="appcApiKey"></requiredProperty>
+ <requiredProperty key="appcApiSecret"></requiredProperty>
+ <requiredProperty key="notificationTopic"></requiredProperty>
+ <requiredProperty key="notificationServers"></requiredProperty>
+ <requiredProperty key="notificationApiKey"></requiredProperty>
+ <requiredProperty key="notificationApiSecret"></requiredProperty>
+ <requiredProperty key="dcaeTopic"></requiredProperty>
+ <requiredProperty key="dcaeServers"></requiredProperty>
+ <requiredProperty key="dcaeApiKey"></requiredProperty>
+ <requiredProperty key="dcaeApiSecret"></requiredProperty>
+ <requiredProperty key="dependenciesVersion"></requiredProperty>
+ </requiredProperties>
+
+ <fileSets>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.drl</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/config</directory>
+ <includes>
+ <include>**/*.properties</include>
+ <include>**/*.json</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor>
diff --git a/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/pom.xml b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 000000000..c3973a7d9
--- /dev/null
+++ b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ archetype-closed-loop-demo-rules
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <version>${version}</version>
+
+ <name>${artifactId}</name>
+ <description>Closed Loop Demo Rules</description>
+
+ <properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>demo</artifactId>
+ <version>${dependenciesVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>controlloop</artifactId>
+ <version>${dependenciesVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>rest</artifactId>
+ <version>${dependenciesVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>appc</artifactId>
+ <version>${dependenciesVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>aai</artifactId>
+ <version>${dependenciesVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>mso</artifactId>
+ <version>${dependenciesVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>trafficgenerator</artifactId>
+ <version>${dependenciesVersion}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties
new file mode 100644
index 000000000..9c3885947
--- /dev/null
+++ b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties
@@ -0,0 +1,55 @@
+###
+# ============LICENSE_START=======================================================
+# archetype-closed-loop-demo-rules
+# ================================================================================
+# 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=========================================================
+###
+
+controller.name=${artifactId}
+
+ueb.source.topics=${dcaeTopic},${appcTopic}
+
+ueb.source.topics.${dcaeTopic}.servers=${dcaeServers}
+ueb.source.topics.${dcaeTopic}.apiKey=${dcaeApiKey}
+ueb.source.topics.${dcaeTopic}.apiSecret=${dcaeApiSecret}
+ueb.source.topics.${dcaeTopic}.events=org.openecomp.policy.controlloop.VirtualControlLoopEvent
+ueb.source.topics.${dcaeTopic}.events.org.openecomp.policy.controlloop.VirtualControlLoopEvent.filter=closedLoopEventStatus=.*
+ueb.source.topics.${dcaeTopic}.events.custom.gson=org.openecomp.policy.controlloop.util.Serialization,gsonPretty
+
+ueb.source.topics.${appcTopic}.servers=${appcServers}
+ueb.source.topics.${appcTopic}.apiKey=${appcApiKey}
+ueb.source.topics.${appcTopic}.apiSecret=${appcApiSecret}
+ueb.source.topics.${appcTopic}.events=org.openecomp.policy.appc.Response
+ueb.source.topics.${appcTopic}.events.org.openecomp.policy.appc.Response.filter=CommonHeader=.*,Status=.*
+ueb.source.topics.${appcTopic}.events.custom.gson=org.openecomp.policy.appc.util.Serialization,gsonPretty
+
+ueb.sink.topics=${appcTopic},${notificationTopic}
+
+ueb.sink.topics.${appcTopic}.servers=${appcServers}
+ueb.sink.topics.${appcTopic}.apiKey=${appcApiKey}
+ueb.sink.topics.${appcTopic}.apiSecret=${appcApiSecret}
+ueb.sink.topics.${appcTopic}.events=org.openecomp.policy.appc.Request
+ueb.sink.topics.${appcTopic}.events.custom.gson=org.openecomp.policy.appc.util.Serialization,gsonPretty
+
+ueb.sink.topics.${notificationTopic}.servers=${notificationServers}
+ueb.sink.topics.${notificationTopic}.apiKey=${notificationApiKey}
+ueb.sink.topics.${notificationTopic}.apiSecret=${notificationApiSecret}
+ueb.sink.topics.${notificationTopic}.events=org.openecomp.policy.controlloop.VirtualControlLoopNotification
+ueb.sink.topics.${notificationTopic}.events.custom.gson=org.openecomp.policy.controlloop.util.Serialization,gsonPretty
+
+rules.groupId=${groupId}
+rules.artifactId=${artifactId}
+rules.version=${version}
diff --git a/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json
new file mode 100644
index 000000000..de5db52df
--- /dev/null
+++ b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json
@@ -0,0 +1,37 @@
+{
+ "controller.name": "${artifactId}",
+
+ "ueb.source.topics": "${dcaeTopic},${appcTopic}",
+
+ "ueb.source.topics.${dcaeTopic}.servers": "${dcaeServers}",
+ "ueb.source.topics.${dcaeTopic}.apiKey": "${dcaeApiKey}",
+ "ueb.source.topics.${dcaeTopic}.apiSecret": "${dcaeApiSecret}",
+ "ueb.source.topics.${dcaeTopic}.events": "org.openecomp.policy.controlloop.VirtualControlLoopEvent",
+ "ueb.source.topics.${dcaeTopic}.events.org.openecomp.policy.controlloop.VirtualControlLoopEvent.filter": "closedLoopEventStatus=.*",
+ "ueb.source.topics.${dcaeTopic}.events.custom.gson": "org.openecomp.policy.controlloop.util.Serialization,gsonPretty",
+
+ "ueb.source.topics.${appcTopic}.servers": "${appcServers}",
+ "ueb.source.topics.${appcTopic}.apiKey": "${appcApiKey}",
+ "ueb.source.topics.${appcTopic}.apiSecret": "${appcApiSecret}",
+ "ueb.source.topics.${appcTopic}.events": "org.openecomp.policy.appc.Response",
+ "ueb.source.topics.${appcTopic}.events.org.openecomp.policy.appc.Response.filter": "CommonHeader=.*,Status=.*",
+ "ueb.source.topics.${appcTopic}.events.custom.gson": "org.openecomp.policy.appc.util.Serialization,gsonPretty",
+
+ "ueb.sink.topics": "${appcTopic},${notificationTopic}",
+
+ "ueb.sink.topics.${appcTopic}.servers": "${appcServers}",
+ "ueb.sink.topics.${appcTopic}.apiKey": "${appcApiKey}",
+ "ueb.sink.topics.${appcTopic}.apiSecret": "${appcApiSecret}",
+ "ueb.sink.topics.${appcTopic}.events": "org.openecomp.policy.appc.Request",
+ "ueb.sink.topics.${appcTopic}.events.custom.gson": "org.openecomp.policy.appc.util.Serialization,gsonPretty",
+
+ "ueb.sink.topics.${notificationTopic}.servers": "${notificationServers}",
+ "ueb.sink.topics.${notificationTopic}.apiKey": "${notificationApiKey}",
+ "ueb.sink.topics.${notificationTopic}.apiSecret": "${notificationApiSecret}",
+ "ueb.sink.topics.${notificationTopic}.events": "org.openecomp.policy.controlloop.VirtualControlLoopNotification",
+ "ueb.sink.topics.${notificationTopic}.events.custom.gson": "org.openecomp.policy.controlloop.util.Serialization,gsonPretty",
+
+ "rules.groupId": "${groupId}",
+ "rules.artifactId": "${artifactId}",
+ "rules.version": "${version}"
+}
diff --git a/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/dcae.onset.json b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/dcae.onset.json
new file mode 100644
index 000000000..5c787ed5d
--- /dev/null
+++ b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/dcae.onset.json
@@ -0,0 +1,14 @@
+{
+ "closedLoopControlName": "${closedLoopControlName}",
+ "closedLoopAlarmStart": 1463679805324,
+ "closedLoopEventClient": "microservice.stringmatcher",
+ "closedLoopEventStatus": "ONSET",
+ "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200",
+ "target_type": "VF",
+ "target": "generic-vnf.vnf-id",
+ "AAI": {
+ "generic-vnf.vnf-id": "fw0001vm001fw001",
+ },
+ "from": "DCAE",
+ "version": "1.0.2"
+}
diff --git a/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/vFWsim-controller.properties b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/vFWsim-controller.properties
new file mode 100644
index 000000000..4bbcca8ae
--- /dev/null
+++ b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/vFWsim-controller.properties
@@ -0,0 +1,49 @@
+###
+# ============LICENSE_START=======================================================
+# archetype-closed-loop-demo-rules
+# ================================================================================
+# 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=========================================================
+###
+
+controller.name=vFWsim
+
+ueb.source.topics=${appcTopic}
+
+ueb.source.topics.${appcTopic}.servers=${appcServers}
+ueb.source.topics.${appcTopic}.apiKey=${appcApiKey}
+ueb.source.topics.${appcTopic}.apiSecret=${appcApiSecret}
+ueb.source.topics.${appcTopic}.events=org.openecomp.policy.appc.Request,org.openecomp.policy.sim.vfw.OnsetEvent
+ueb.source.topics.${appcTopic}.events.org.openecomp.policy.appc.Request.filter=CommonHeader=.*,Action=.*
+ueb.source.topics.${appcTopic}.events.org.openecomp.policy.sim.vfw.OnsetEvent.filter=appcResponseCode=.*
+ueb.source.topics.${appcTopic}.events.custom.gson=org.openecomp.policy.appc.util.Serialization,gsonPretty
+
+ueb.sink.topics=${dcaeTopic},${appcTopic}
+
+ueb.sink.topics.${dcaeTopic}.servers=${dcaeServers}
+ueb.sink.topics.${dcaeTopic}.apiKey=${dcaeApiKey}
+ueb.sink.topics.${dcaeTopic}.apiSecret=${dcaeApiSecret}
+ueb.sink.topics.${dcaeTopic}.events=org.openecomp.policy.controlloop.VirtualControlLoopEvent
+ueb.sink.topics.${dcaeTopic}.events.custom.gson=org.openecomp.policy.controlloop.util.Serialization,gsonPretty
+
+ueb.sink.topics.${appcTopic}.servers=${appcServers}
+ueb.sink.topics.${appcTopic}.apiKey=${appcApiKey}
+ueb.sink.topics.${appcTopic}.apiSecret=${appcApiSecret}
+ueb.sink.topics.${appcTopic}.events=org.openecomp.policy.appc.Response
+ueb.sink.topics.${appcTopic}.events.custom.gson=org.openecomp.policy.appc.util.Serialization,gsonPretty
+
+rules.groupId=org.openecomp.policy.apps
+rules.artifactId=vfwsim
+rules.version=${dependenciesVersion}
diff --git a/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/vFWsim-controller.rest.json b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/vFWsim-controller.rest.json
new file mode 100644
index 000000000..3a475dab2
--- /dev/null
+++ b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/vFWsim-controller.rest.json
@@ -0,0 +1,31 @@
+{
+ "controller.name": "vFWsim",
+
+ "ueb.source.topics": "${appcTopic}",
+
+ "ueb.source.topics.${appcTopic}.servers": "${appcServers}",
+ "ueb.source.topics.${appcTopic}.apiKey": "${appcApiKey}",
+ "ueb.source.topics.${appcTopic}.apiSecret": "${appcApiSecret}",
+ "ueb.source.topics.${appcTopic}.events": "org.openecomp.policy.appc.Request,org.openecomp.policy.sim.vfw.OnsetEvent",
+ "ueb.source.topics.${appcTopic}.events.org.openecomp.policy.appc.Request.filter": "CommonHeader=.*,Action=.*",
+ "ueb.source.topics.${appcTopic}.events.org.openecomp.policy.sim.vfw.OnsetEvent.filter": "appcResponseCode=.*",
+ "ueb.source.topics.${appcTopic}.events.custom.gson": "org.openecomp.policy.appc.util.Serialization,gsonPretty",
+
+ "ueb.sink.topics": "${dcaeTopic},${appcTopic}",
+
+ "ueb.sink.topics.${dcaeTopic}.servers": "${dcaeServers}",
+ "ueb.sink.topics.${dcaeTopic}.apiKey": "${dcaeApiKey}",
+ "ueb.sink.topics.${dcaeTopic}.apiSecret": "${dcaeApiSecret}",
+ "ueb.sink.topics.${dcaeTopic}.events": "org.openecomp.policy.controlloop.VirtualControlLoopEvent",
+ "ueb.sink.topics.${dcaeTopic}.events.custom.gson": "org.openecomp.policy.controlloop.util.Serialization,gsonPretty",
+
+ "ueb.sink.topics.${appcTopic}.servers": "${appcServers}",
+ "ueb.sink.topics.${appcTopic}.apiKey": "${appcApiKey}",
+ "ueb.sink.topics.${appcTopic}.apiSecret": "${appcApiSecret}",
+ "ueb.sink.topics.${appcTopic}.events": "org.openecomp.policy.appc.Response",
+ "ueb.sink.topics.${appcTopic}.events.custom.gson": "org.openecomp.policy.appc.util.Serialization,gsonPretty",
+
+ "rules.groupId": "org.openecomp.policy.apps",
+ "rules.artifactId": "vfwsim",
+ "rules.version": "${dependenciesVersion}"
+}
diff --git a/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/vfwsim-onset.json b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/vfwsim-onset.json
new file mode 100644
index 000000000..dd559c039
--- /dev/null
+++ b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/config/vfwsim-onset.json
@@ -0,0 +1,5 @@
+{
+ "dcaeTopic": "${dcaeTopic}",
+ "appcTopic": "${appcTopic}",
+ "appcResponseCode": 400
+}
diff --git a/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/resources/ControlLoopDemo__closedLoopControlName__.drl b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/resources/ControlLoopDemo__closedLoopControlName__.drl
new file mode 100644
index 000000000..710fecf1e
--- /dev/null
+++ b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/resources/ControlLoopDemo__closedLoopControlName__.drl
@@ -0,0 +1,1092 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * archetype-closed-loop-demo-rules
+ * ================================================================================
+ * 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.openecomp.policy.controlloop;
+
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.UUID;
+
+import org.openecomp.policy.controlloop.VirtualControlLoopEvent;
+import org.openecomp.policy.controlloop.ControlLoopEventStatus;
+import org.openecomp.policy.controlloop.VirtualControlLoopNotification;
+import org.openecomp.policy.controlloop.ControlLoopNotificationType;
+import org.openecomp.policy.controlloop.ControlLoopOperation;
+import org.openecomp.policy.controlloop.ControlLoopOperationWrapper;
+import org.openecomp.policy.template.demo.ControlLoopException;
+
+import org.openecomp.policy.aai.AAINQF199.AAINQF199CloudRegion;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperties;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperty;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199GenericVNF;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InstanceFilters;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Manager;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199NamedQuery;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199QueryParameters;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Request;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199RequestWrapper;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Response;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ResponseWrapper;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ServiceInstance;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Tenant;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199VfModule;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199VServer;
+import org.openecomp.policy.aai.util.Serialization;
+
+import org.openecomp.policy.appc.CommonHeader;
+import org.openecomp.policy.appc.Request;
+import org.openecomp.policy.appc.Response;
+import org.openecomp.policy.appc.ResponseCode;
+import org.openecomp.policy.appc.ResponseStatus;
+import org.openecomp.policy.appc.ResponseValue;
+
+import org.openecomp.policy.template.demo.EventManager;
+import org.openecomp.policy.vnf.trafficgenerator.PGRequest;
+import org.openecomp.policy.vnf.trafficgenerator.PGStream;
+import org.openecomp.policy.vnf.trafficgenerator.PGStreams;
+
+import org.openecomp.policy.mso.MSOManager;
+import org.openecomp.policy.mso.MSORequest;
+import org.openecomp.policy.mso.MSORequestStatus;
+import org.openecomp.policy.mso.MSORequestDetails;
+import org.openecomp.policy.mso.MSOModelInfo;
+import org.openecomp.policy.mso.MSOCloudConfiguration;
+import org.openecomp.policy.mso.MSORequestInfo;
+import org.openecomp.policy.mso.MSORequestParameters;
+import org.openecomp.policy.mso.MSORelatedInstanceListElement;
+import org.openecomp.policy.mso.MSORelatedInstance;
+import org.openecomp.policy.mso.MSOResponse;
+
+import org.openecomp.policy.drools.system.PolicyEngine;
+
+//
+// These parameters are required to build the runtime policy
+//
+declare Params
+ closedLoopControlName : String
+ actor : String
+ aaiURL : String
+ aaiUsername : String
+ aaiPassword : String
+ msoURL : String
+ msoUsername : String
+ msoPassword : String
+ aaiNamedQueryUUID : String
+ aaiPatternMatch : int
+ notificationTopic : String
+ appcTopic : String
+end
+
+/*
+*
+* Called once and only once to insert the parameters into working memory for this Closed Loop policy.
+* (Comment SETUP rule out for the first ECOMP opensource release since policy BRMS_GW already puts a Params fact in there)
+*
+*
+*rule "${policyName}.SETUP"
+* when
+* then
+* System.out.println("rule SETUP is triggered.");
+* Params params = new Params();
+* params.setClosedLoopControlName("${closedLoopControlName}");
+* params.setActor("${actor}");
+* params.setAaiURL("${aaiURL}");
+* params.setAaiUsername("${aaiUsername}");
+* params.setAaiPassword("${aaiPassword}");
+* params.setMsoURL("${msoURL}");
+* params.setMsoUsername("${msoUsername}");
+* params.setMsoPassword("${msoPassword}");
+* params.setAaiNamedQueryUUID("${aaiNamedQueryUUID}");
+* params.setAaiPatternMatch(${aaiPatternMatch});
+* params.setNotificationTopic("${notificationTopic}");
+* params.setAppcTopic("${appcTopic}");
+* //
+* // This stays in memory as long as the rule is alive and running
+* //
+* insert(params);
+*end
+*/
+/*
+*
+* This rule responds to DCAE Events
+*
+*/
+rule "${policyName}.EVENT"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ not ( EventManager( closedLoopControlName == $event.closedLoopControlName ))
+ then
+ System.out.println("rule EVENT is triggered.");
+ try {
+ //
+ // Check the requestID in the event to make sure it is not null before we create the EventManager.
+ // The EventManager will do extra syntax checking as well check if the closed loop is disabled/
+ //
+ if ($event.requestID == null) {
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.REJECTED;
+ notification.from = "policy";
+ notification.message = "Missing requestID from DCAE event";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver notification: " + notification);
+ }
+ //
+ // Retract it from memory
+ //
+ retract($event);
+ System.out.println("Event with requestID=null has been retracted.");
+ } else {
+ //
+ // Create an EventManager
+ //
+ EventManager manager = new EventManager($params.getClosedLoopControlName(), $event.requestID, $event.target);
+ //
+ // Determine if EventManager can actively process the event (i.e. syntax)
+ //
+ VirtualControlLoopNotification notification = manager.activate($event);
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ //
+ // Are we actively pursuing this event?
+ //
+ if (notification.notification == ControlLoopNotificationType.ACTIVE) {
+ //
+ // Insert Event Manager into memory, this will now kick off processing.
+ //
+ insert(manager);
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver notification: " + notification);
+ }
+ } else {
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver notification: " + notification);
+ }
+ //
+ // Retract it from memory
+ //
+ retract($event);
+ }
+ //
+ // Now that the manager is inserted into Drools working memory, we'll wait for
+ // another rule to fire in order to continue processing. This way we can also
+ // then screen for additional ONSET and ABATED events for this same RequestIDs
+ // and for different RequestIDs but with the same closedLoopControlName and target.
+ //
+ }
+ //
+ } catch (Exception e) {
+ e.printStackTrace();
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.REJECTED;
+ notification.message = "Exception occurred " + e.getMessage();
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ //
+ //
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e1) {
+ System.out.println("Can't deliver notification: " + notification);
+ e1.printStackTrace();
+ }
+ //
+ // Retract the event
+ //
+ retract($event);
+ }
+end
+
+/*
+*
+* This rule happens when we got a valid ONSET, closed loop is enabled and an Event Manager
+* is created. We can start the operations for this closed loop.
+*
+*/
+rule "${policyName}.EVENT.MANAGER"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName, controlLoopResult == null)
+ then
+ System.out.println("rule EVENT.MANAGER is triggered.");
+ //
+ // Check which event this is.
+ //
+ EventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);
+ //
+ // We only want the initial ONSET event in memory,
+ // all the other events need to be retracted to support
+ // cleanup and avoid the other rules being fired for this event.
+ //
+ if (eventStatus != EventManager.NEW_EVENT_STATUS.FIRST_ONSET) {
+ System.out.println("Retracting "+eventStatus+" Event.");
+ retract($event);
+ return;
+ }
+ //
+ // Now the event in memory is first onset event
+ //
+ try {
+ //
+ // Pull the known AAI field from the Event
+ //
+ // generic-vnf is needed for vFirewall case
+ // vserver-name is needed for vLoadBalancer case
+ //
+ String genericVNF = $event.AAI.get("generic-vnf.vnf-id");
+ String vserver = $event.AAI.get("vserver.vserver-name");
+ //
+ // Check if we are implementing a simple pattern match.
+ //
+ if ($params.getAaiPatternMatch() == 1) {
+ //
+ // Yes
+ //
+ //Basic naming characteristics:
+ //VF Name (9 char)+VM name (13 char total)+VFC (19 char total)
+ //Example:
+ //VF Name (9 characters): cscf0001v
+ //VM Name(13 characters): cscf0001vm001
+ //VFC name(19 characters): cscf0001vm001cfg001
+ //
+ // zdfw1fwl01fwl02 or zdfw1fwl01fwl01
+ // replaced with
+ // zdfw1fwl01pgn02 or zdfw1fwl01pgn01
+ //
+ int index = genericVNF.lastIndexOf("fwl");
+ if (index == -1) {
+ System.err.println("The generic-vnf.vnf-id from DCAE Event is not valid.");
+ } else {
+ genericVNF = genericVNF.substring(0, index) + "pgn" + genericVNF.substring(index+"fwl".length());
+ }
+ //
+ // Construct an APPC request
+ //
+ ControlLoopOperation operation = new ControlLoopOperation();
+ operation.actor = $params.getActor();
+ operation.operation = "ModifyConfig";
+ operation.target = $event.target;
+ //
+ // Create operationWrapper
+ //
+ ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+ //
+ // insert operationWrapper into memory
+ //
+ insert(operationWrapper);
+ //
+ Request request = new Request();
+ request.CommonHeader = new CommonHeader();
+ request.CommonHeader.RequestID = $event.requestID;
+ request.Action = operation.operation;
+ request.Payload = new HashMap<String, Object>();
+ //
+ // Fill in the payload
+ //
+ request.Payload.put("generic-vnf.vnf-id", genericVNF);
+ //
+ PGRequest pgRequest = new PGRequest();
+ pgRequest.pgStreams = new PGStreams();
+
+ PGStream pgStream;
+ for(int i = 0; i < 5; i++){
+ pgStream = new PGStream();
+ pgStream.streamId = "fw_udp"+(i+1);
+ pgStream.isEnabled = "true";
+ pgRequest.pgStreams.pgStream.add(pgStream);
+ }
+ request.Payload.put("pg-streams", pgRequest.pgStreams);
+
+ if (request != null) {
+ //
+ // Insert request into memory
+ //
+ insert(request);
+ //
+ // Tell interested parties we are performing this Operation
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.OPERATION;
+ // message and history ??
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // Now send the operation request
+ //
+ if (request instanceof Request) {
+ try {
+ System.out.println("APPC request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(request));
+ PolicyEngine.manager.deliver($params.getAppcTopic(), request);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver request: " + request);
+ }
+ }
+ } else {
+ //
+ // what happens if it is null
+ //
+ }
+ //
+ } else {
+ //
+ // create AAI named-query request with UUID started with "F199"
+ //
+ AAINQF199Request aainqf199request = new AAINQF199Request();
+ AAINQF199QueryParameters aainqf199queryparam = new AAINQF199QueryParameters();
+ AAINQF199NamedQuery aainqf199namedquery = new AAINQF199NamedQuery();
+ AAINQF199InstanceFilters aainqf199instancefilter = new AAINQF199InstanceFilters();
+ //
+ // queryParameters
+ //
+ aainqf199namedquery.namedQueryUUID = UUID.fromString($params.getAaiNamedQueryUUID());
+ aainqf199queryparam.namedQuery = aainqf199namedquery;
+ aainqf199request.queryParameters = aainqf199queryparam;
+ //
+ // instanceFilters
+ //
+ Map aainqf199instancefiltermap = new HashMap();
+ Map aainqf199instancefiltermapitem = new HashMap();
+ aainqf199instancefiltermapitem.put("vserver-name", vserver);
+ aainqf199instancefiltermap.put("vserver", aainqf199instancefiltermapitem);
+ aainqf199instancefilter.instanceFilter.add(aainqf199instancefiltermap);
+ aainqf199request.instanceFilters = aainqf199instancefilter;
+ //
+ // print aainqf199request for debug
+ //
+ System.out.println("AAI Request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(aainqf199request));
+ //
+ // Create AAINQF199RequestWrapper
+ //
+ AAINQF199RequestWrapper aainqf199RequestWrapper = new AAINQF199RequestWrapper($event.requestID, aainqf199request);
+ //
+ // insert aainqf199request into memory
+ //
+ insert(aainqf199RequestWrapper);
+ }
+ //
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+end
+
+/*
+*
+* This rule happens when we got a valid ONSET, closed loop is enabled, an Event Manager
+* is created, AAI Manager and AAI Request are ready in memory. We can start sending query to AAI and then wait for response.
+*
+*/
+rule "${policyName}.EVENT.MANAGER.AAINQF199REQUEST"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+ $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)
+ then
+ System.out.println("rule EVENT.MANAGER.AAINQF199REQUEST is triggered.");
+ //
+ // send the request
+ //
+ AAINQF199Response aainqf199response = AAINQF199Manager.postQuery($params.getAaiURL(), $params.getAaiUsername(), $params.getAaiPassword(),
+ $aainqf199RequestWrapper.aainqf199request, $event.requestID);
+ //
+ // Check AAI response
+ //
+ if (aainqf199response == null) {
+ System.err.println("Failed to get AAI response");
+ //
+ // Fail and retract everything
+ //
+ retract($event);
+ retract($manager);
+ retract($aainqf199RequestWrapper);
+ } else {
+ //
+ // Create AAINQF199ResponseWrapper
+ //
+ AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper($event.requestID, aainqf199response);
+ //
+ // insert aainqf199ResponseWrapper to memeory
+ //
+ insert(aainqf199ResponseWrapper);
+ }
+end
+
+/*
+*
+* This rule happens when we got a valid AAI response. We can start sending request to APPC or MSO now.
+*
+*/
+rule "${policyName}.EVENT.MANAGER.AAINQF199RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+ $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)
+ $aainqf199ResponseWrapper : AAINQF199ResponseWrapper(requestID == $event.requestID)
+ then
+ System.out.println("rule EVENT.MANAGER.AAINQF199RESPONSE is triggered.");
+ //
+ // Extract related fields out of AAINQF199RESPONSE
+ //
+ String vnfItemVnfId, vnfItemVnfType, vnfItemPersonaModelId, vnfItemPersonaModelVersion, vnfItemModelName,
+ vnfItemModelVersion, vnfItemModelNameVersionId, serviceItemServiceInstanceId, serviceItemPersonaModelId,
+ serviceItemModelName, serviceItemModelType, serviceItemModelVersion, serviceItemModelNameVersionId,
+ vfModuleItemVfModuleName, vfModuleItemPersonaModelId, vfModuleItemPersonaModelVersion, vfModuleItemModelName,
+ vfModuleItemModelNameVersionId, tenantItemTenantId, cloudRegionItemCloudRegionId;
+ try {
+ //
+ // vnfItem
+ //
+ vnfItemVnfId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;
+ vnfItemVnfType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;
+ vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf("/")+1);
+ vnfItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;
+ vnfItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;
+ vnfItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
+ vnfItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(2).propertyValue;
+ vnfItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
+ //
+ // serviceItem
+ //
+ serviceItemServiceInstanceId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;
+ serviceItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;
+ serviceItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
+ serviceItemModelType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue;
+ serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;
+ serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
+ //
+ // This comes from the base module
+ //
+ vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).vfModule.vfModuleName;
+ vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace("Vfmodule", "vDNS");
+ //
+ // vfModuleItem - NOT the base module
+ //
+ vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelId;
+ vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelVersion;
+ vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(0).propertyValue;
+ vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(4).propertyValue;
+ //
+ // tenantItem
+ //
+ tenantItemTenantId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;
+ //
+ // cloudRegionItem
+ //
+ cloudRegionItemCloudRegionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;
+ //
+ } catch (Exception e) {
+ e.printStackTrace();
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.REJECTED;
+ notification.message = "Exception occurred " + e.getMessage();
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e1) {
+ System.out.println("Can't deliver notification: " + notification);
+ e1.printStackTrace();
+ }
+ //
+ notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+ notification.message = "Invalid named-query response from AAI";
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e1) {
+ System.out.println("Can't deliver notification: " + notification);
+ e1.printStackTrace();
+ }
+ //
+ // Retract everything
+ //
+ retract($aainqf199RequestWrapper);
+ retract($aainqf199ResponseWrapper);
+ retract($manager);
+ retract($event);
+ return;
+ }
+ //
+ // Extracted fields should not be null
+ //
+ if ((vnfItemVnfId == null) || (vnfItemVnfType == null) ||
+ (vnfItemPersonaModelId == null) || (vnfItemModelName == null) ||
+ (vnfItemModelVersion == null) || (vnfItemModelNameVersionId == null) ||
+ (serviceItemServiceInstanceId == null) || (serviceItemModelName == null) ||
+ (serviceItemModelType == null) || (serviceItemModelVersion == null) ||
+ (serviceItemModelNameVersionId == null) || (vfModuleItemVfModuleName == null) ||
+ (vfModuleItemPersonaModelId == null) || (vfModuleItemPersonaModelVersion == null) ||
+ (vfModuleItemModelName == null) || (vfModuleItemModelNameVersionId == null) ||
+ (tenantItemTenantId == null) || (cloudRegionItemCloudRegionId == null)) {
+ //
+ System.err.println("some fields are missing from AAI response.");
+ //
+ // Fail and retract everything
+ //
+ retract($aainqf199RequestWrapper);
+ retract($aainqf199ResponseWrapper);
+ retract($manager);
+ retract($event);
+ return;
+ }
+ //
+ // We don't need them any more
+ //
+ retract($aainqf199ResponseWrapper);
+ retract($aainqf199RequestWrapper);
+ //
+ // check the actor of this closed loop
+ //
+ switch ($params.getActor()) {
+ case "APPC":
+ {
+ //
+ // Construct an APPC request
+ //
+ ControlLoopOperation operation = new ControlLoopOperation();
+ operation.actor = $params.getActor();
+ operation.operation = "ModifyConfig";
+ operation.target = $event.target;
+ //
+ // Create operationWrapper
+ //
+ ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+ //
+ // insert operationWrapper into memory
+ //
+ insert(operationWrapper);
+ //
+ Request request = new Request();
+ request.CommonHeader = new CommonHeader();
+ request.CommonHeader.RequestID = $event.requestID;
+ request.Action = operation.operation;
+ request.Payload = new HashMap<String, Object>();
+ //
+ // Fill in the payload
+ // Hardcode genericVNF for now since AAI has not been ready for vFirewall demo case
+ //
+ String genericVNF = "zdfw1fwl01pgn02";
+ request.Payload.put("generic-vnf.vnf-id", genericVNF);
+ //
+ PGRequest pgRequest = new PGRequest();
+ pgRequest.pgStreams = new PGStreams();
+
+ PGStream pgStream;
+ for(int i = 0; i < 5; i++){
+ pgStream = new PGStream();
+ pgStream.streamId = "fw_udp"+(i+1);
+ pgStream.isEnabled = "true";
+ pgRequest.pgStreams.pgStream.add(pgStream);
+ }
+ request.Payload.put("pg-streams", pgRequest.pgStreams);
+
+ if (request != null) {
+ //
+ // Insert request into memory
+ //
+ insert(request);
+ //
+ // Tell interested parties we are performing this Operation
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.OPERATION;
+ // message and history ??
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // Now send the operation request
+ //
+ if (request instanceof Request) {
+ try {
+ System.out.println("APPC request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(request));
+ PolicyEngine.manager.deliver($params.getAppcTopic(), request);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver request: " + request);
+ }
+ }
+ } else {
+ //
+ // what happens if it is null
+ //
+ }
+ }
+ break;
+ case "MSO":
+ {
+ //
+ // Construct an operation
+ //
+ ControlLoopOperation operation = new ControlLoopOperation();
+ operation.actor = $params.getActor();
+ operation.operation = "createModuleInstance";
+ operation.target = $event.target;
+ //
+ // Create operationWrapper
+ //
+ ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+ //
+ // Construct an MSO request
+ //
+ MSORequest request = new MSORequest();
+ request.requestDetails = new MSORequestDetails();
+ request.requestDetails.modelInfo = new MSOModelInfo();
+ request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();
+ request.requestDetails.requestInfo = new MSORequestInfo();
+ request.requestDetails.requestParameters = new MSORequestParameters();
+ request.requestDetails.requestParameters.userParams = null;
+ //
+ // cloudConfiguration
+ //
+ request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;
+ request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;
+ //
+ // modelInfo
+ //
+ request.requestDetails.modelInfo.modelType = "vfModule";
+ request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;
+ request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;
+ request.requestDetails.modelInfo.modelName = vfModuleItemModelName;
+ request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;
+ //
+ // requestInfo
+ //
+ request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;
+ request.requestDetails.requestInfo.source = "POLICY";
+ request.requestDetails.requestInfo.suppressRollback = false;
+ //
+ // relatedInstanceList
+ //
+ MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();
+ MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();
+ relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();
+ relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();
+ //
+ relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;
+ relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;
+ //
+ relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;
+ relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemModelVersion;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;
+ //
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
+ //
+ // print MSO request for debug
+ //
+ System.out.println("MSO request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(request));
+ //
+ //
+ //
+ if (request != null) {
+ //
+ // Tell interested parties we are performing this Operation
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.OPERATION;
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // Concatenate serviceItemServiceInstanceId and vnfItemVnfId to msoURL
+ //
+ String MSOUrl = $params.getMsoURL() + "/serviceInstances/v2/" + serviceItemServiceInstanceId + "/vnfs/" + vnfItemVnfId + "/vfModules";
+ //
+ // Call MSO
+ //
+ MSOResponse response = MSOManager.createModuleInstance(MSOUrl, $params.getMsoURL(), $params.getMsoUsername(), $params.getMsoPassword(), request);
+ //
+ if (response != null) {
+ //
+ // Assign requestId
+ //
+ request.requestId = $event.requestID.toString();
+ response.request.requestId = $event.requestID.toString();
+ //
+ // Insert facts
+ //
+ insert(operationWrapper);
+ insert(request);
+ insert(response);
+ } else {
+ //
+ // MSO request not even accepted
+ //
+ notification.message = operationWrapper.operation.toMessage();
+ operationWrapper.operation.message = operationWrapper.operation.toMessage();
+ operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+ $manager.setControlLoopResult("FAILURE_EXCEPTION");
+ notification.history.add(operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // Retract everything
+ //
+ retract($event);
+ retract($manager);
+ }
+ } else {
+ System.err.println("constructed MSO request is invalid.");
+ }
+ }
+ break;
+ }
+end
+
+/*
+*
+* This rule responds to APPC Response Events
+*
+*/
+rule "${policyName}.APPC.RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+ $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )
+ $request : Request( getCommonHeader().RequestID == $event.requestID )
+ $response : Response( getCommonHeader().RequestID == $event.requestID )
+ then
+ System.out.println("rule APPC.RESPONSE is triggered.");
+ if ($response.Status == null) {
+ $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+ $manager.setControlLoopResult("FAILURE_EXCEPTION");
+ }
+ //
+ // Get the Response Code
+ //
+ ResponseCode code = ResponseCode.toResponseCode($response.Status.Code);
+ if (code == null) {
+ $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+ $manager.setControlLoopResult("FAILURE_EXCEPTION");
+ }
+ //
+ // Construct notification
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ notification.message = $operationWrapper.operation.toMessage();
+ $operationWrapper.operation.message = $operationWrapper.operation.toMessage();
+ //
+ // Ok, let's figure out what APP-C's response is
+ //
+ switch (code) {
+ case ACCEPT:
+ $operationWrapper.operation.outcome = "PROCESSING";
+ break;
+ case ERROR:
+ case REJECT:
+ $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+ $manager.setControlLoopResult("FAILURE_EXCEPTION");
+ break;
+ case SUCCESS:
+ $operationWrapper.operation.outcome = "SUCCESS";
+ $manager.setControlLoopResult("SUCCESS");
+ break;
+ case FAILURE:
+ $operationWrapper.operation.outcome = "FAILURE";
+ $manager.setControlLoopResult("FAILURE");
+ break;
+ }
+ if ($operationWrapper.operation.outcome.equals("SUCCESS")) {
+ notification.history.add($operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+
+ //
+ // We are going to retract these objects from memory
+ //
+ System.out.println("Retracting everything");
+ retract($operationWrapper);
+ retract($request);
+ retract($response);
+ retract($event);
+ retract($manager);
+ } else if ($operationWrapper.operation.outcome.equals("PROCESSING")) {
+ retract($response);
+ } else {
+ notification.history.add($operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // We are going to retract these objects from memory
+ //
+ System.out.println("Retracting everything");
+ retract($operationWrapper);
+ retract($request);
+ retract($response);
+ retract($event);
+ retract($manager);
+ }
+
+end
+
+/*
+*
+* This rule is used to clean up APPC response
+*
+*/
+rule "${policyName}.APPC.RESPONSE.CLEANUP"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $response : Response($id : getCommonHeader().RequestID )
+ not ( VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) )
+ then
+ System.out.println("rule APPC.RESPONSE.CLEANUP is triggered.");
+ retract($response);
+end
+
+/*
+*
+* This rule responds to MSO Response Events
+*
+*/
+rule "${policyName}.MSO.RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+ $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )
+ $request : MSORequest( requestId == $event.requestID.toString() )
+ $response : MSOResponse( request.requestId == $event.requestID.toString() )
+ then
+ System.out.println("rule MSO.RESPONSE is triggered.");
+ //
+ // Construct notification
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ notification.message = $operationWrapper.operation.toMessage();
+ $operationWrapper.operation.message = $operationWrapper.operation.toMessage();
+ //
+ // The operation can either be succeeded or failed
+ //
+ if($response.request.requestStatus.requestState.equals("Completed")) {
+ $operationWrapper.operation.outcome = "SUCCESS";
+ $manager.setControlLoopResult("SUCCESS");
+ notification.history.add($operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // We are going to retract these objects from memory
+ //
+ System.out.println("Retracting everything");
+ retract($operationWrapper);
+ retract($request);
+ retract($response);
+ retract($event);
+ retract($manager);
+ } else {
+ $operationWrapper.operation.outcome = "FAILURE";
+ $manager.setControlLoopResult("FAILURE");
+ notification.history.add($operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // We are going to retract these objects from memory
+ //
+ System.out.println("Retracting everything");
+ retract($operationWrapper);
+ retract($request);
+ retract($response);
+ retract($event);
+ retract($manager);
+ }
+
+end
diff --git a/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/resources/META-INF/kmodule.xml b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/resources/META-INF/kmodule.xml
new file mode 100644
index 000000000..8116d880a
--- /dev/null
+++ b/archetype-closedloop-demo-rules/src/main/resources/archetype-resources/src/main/resources/META-INF/kmodule.xml
@@ -0,0 +1,29 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ archetype-closed-loop-demo-rules
+ ================================================================================
+ 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=========================================================
+ -->
+
+<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
+ <kbase name="rules">
+ <ksession name="closedloop-demo"/>
+ </kbase>
+</kmodule>
diff --git a/archetype-closedloop-demo-rules/src/test/resources/projects/basic/archetype.properties b/archetype-closedloop-demo-rules/src/test/resources/projects/basic/archetype.properties
new file mode 100644
index 000000000..6dce9747d
--- /dev/null
+++ b/archetype-closedloop-demo-rules/src/test/resources/projects/basic/archetype.properties
@@ -0,0 +1,50 @@
+###
+# ============LICENSE_START=======================================================
+# archetype-closed-loop-demo-rules
+# ================================================================================
+# 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=========================================================
+###
+
+groupId=org.openecomp.policy.demo.drools
+artifactId=closedloop-demo-rules
+version=1.0.0-SNAPSHOT
+package=org.openecomp.policy.demo.drools
+closedLoopControlName=CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8
+policyScope=service=test;resource=FRWL;type=configuration
+policyName=FirewallDemo
+policyVersion=v1.0
+actor=APPC
+appcTopic=APPC-CL
+appcApiKey=NO-API-KEY
+appcApiSecret=NO-API-SECRET
+appcServers=server1,server2,server3
+notificationTopic=POLICY-CL-MGT
+notificationApiKey=NO-API-KEY
+notificationApiSecret=NO-API-SECRET
+notificationServers=server1,server2,server3
+dcaeTopic=DCAE-CL-EVENT
+dcaeServers=server1,server2,server3
+dcaeApiKey=NO-API-KEY
+dcaeApiSecret=NO-API-SECRET
+dependenciesVersion=1.0.0-SNAPSHOT
+aaiURL=http://localhost:8080/TestREST/Test
+aaiUsername=policy
+aaiPassword=policy
+aaiNamedQueryUUID=d925ed73-8231-4d02-9545-db4e101fffff
+aaiPatternMatch=false
+msoURL=http://localhost:8080/TestREST/Test
+msoUsername=policy
+msoPassword=policy
diff --git a/archetype-closedloop-demo-rules/src/test/resources/projects/basic/goal.txt b/archetype-closedloop-demo-rules/src/test/resources/projects/basic/goal.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archetype-closedloop-demo-rules/src/test/resources/projects/basic/goal.txt
diff --git a/controlloop/pom.xml b/controlloop/pom.xml
new file mode 100644
index 000000000..47e18703f
--- /dev/null
+++ b/controlloop/pom.xml
@@ -0,0 +1,46 @@
+<!--
+ ============LICENSE_START=======================================================
+ Drools PDP Application Models
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>controlloop</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopEvent.java b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopEvent.java
new file mode 100644
index 000000000..d7fa04884
--- /dev/null
+++ b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopEvent.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * 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.openecomp.policy.controlloop;
+
+import java.io.Serializable;
+import java.util.UUID;
+
+public abstract class ControlLoopEvent implements Serializable {
+
+ private static final long serialVersionUID = 2391252138583119195L;
+
+ public String closedLoopControlName;
+ public String version = "1.0.2";
+ public UUID requestID;
+ public String closedLoopEventClient;
+ public ControlLoopTargetType target_type;
+ public String target;
+ public String from;
+ public String policyScope;
+ public String policyName;
+ public String policyVersion;
+ public ControlLoopEventStatus closedLoopEventStatus;
+
+ public ControlLoopEvent() {
+
+ }
+
+ public ControlLoopEvent(ControlLoopEvent event) {
+ if (event == null) {
+ return;
+ }
+ this.closedLoopControlName = event.closedLoopControlName;
+ this.requestID = event.requestID;
+ this.closedLoopEventClient = event.closedLoopEventClient;
+ this.target_type = event.target_type;
+ this.target = event.target;
+ this.from = event.from;
+ this.policyScope = event.policyScope;
+ this.policyName = event.policyName;
+ this.policyVersion = event.policyVersion;
+ this.closedLoopEventStatus = event.closedLoopEventStatus;
+ }
+
+ public boolean isEventStatusValid() {
+ if (this.closedLoopEventStatus == null) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopEventStatus.java b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopEventStatus.java
new file mode 100644
index 000000000..063a611b9
--- /dev/null
+++ b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopEventStatus.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * 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.openecomp.policy.controlloop;
+
+public enum ControlLoopEventStatus {
+ ONSET("ONSET"),
+ ABATED("ABATED")
+ ;
+
+ private String status;
+
+ private ControlLoopEventStatus(String status) {
+ this.status = status;
+ }
+
+ public String toString() {
+ return this.status;
+ }
+
+ public static ControlLoopEventStatus toStatus(String status) {
+ if (ONSET.status.equalsIgnoreCase(status)) {
+ return ONSET;
+ }
+ if (ABATED.status.equalsIgnoreCase(status)) {
+ return ABATED;
+ }
+ //
+ // In case DCAE uses the old abatement
+ //
+ if (status.equalsIgnoreCase("abatement")) {
+ return ABATED;
+ }
+ return null;
+ }
+
+}
diff --git a/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopNotification.java b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopNotification.java
new file mode 100644
index 000000000..15c61a80a
--- /dev/null
+++ b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopNotification.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * 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.openecomp.policy.controlloop;
+
+import java.io.Serializable;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
+
+public abstract class ControlLoopNotification implements Serializable {
+
+ private static final long serialVersionUID = 7538596984567127915L;
+
+ public String closedLoopControlName;
+ public String version = "1.0.2";
+ public UUID requestID;
+ public String closedLoopEventClient;
+ public ControlLoopTargetType target_type;
+ public String target;
+ public String from;
+ public String policyScope;
+ public String policyName;
+ public String policyVersion;
+ public ControlLoopNotificationType notification;
+ public String message;
+ public ZonedDateTime notificationTime = ZonedDateTime.now(ZoneOffset.UTC);;
+ public Integer OPS_CL_timer;
+ public List<ControlLoopOperation> history = new LinkedList<ControlLoopOperation>();
+
+ public ControlLoopNotification() {
+
+ }
+
+ public ControlLoopNotification(ControlLoopEvent event) {
+ this.closedLoopControlName = event.closedLoopControlName;
+ this.requestID = event.requestID;
+ this.closedLoopEventClient = event.closedLoopEventClient;
+ this.target_type = event.target_type;
+ this.target = event.target;
+ }
+
+}
diff --git a/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopNotificationType.java b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopNotificationType.java
new file mode 100644
index 000000000..a5618df02
--- /dev/null
+++ b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopNotificationType.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * 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.openecomp.policy.controlloop;
+
+public enum ControlLoopNotificationType {
+ ACTIVE("ACTIVE"),
+ REJECTED("REJECTED"),
+ OPERATION("OPERATION"),
+ OPERATION_SUCCESS("OPERATION: SUCCESS"),
+ OPERATION_FAILURE("OPERATION: FAILURE"),
+ FINAL_FAILURE("FINAL: FAILURE"),
+ FINAL_SUCCESS("FINAL: SUCCESS"),
+ FINAL_OPENLOOP("FINAL: OPENLOOP")
+ ;
+
+ private String type;
+
+ private ControlLoopNotificationType(String type) {
+ this.type = type;
+ }
+
+ public String toString() {
+ return this.type;
+ }
+
+ public static ControlLoopNotificationType toType(String type) {
+ if (ACTIVE.toString().equals(type)) {
+ return ACTIVE;
+ }
+ if (REJECTED.toString().equals(type)) {
+ return REJECTED;
+ }
+ if (OPERATION.toString().equals(type)) {
+ return OPERATION;
+ }
+ if (OPERATION_SUCCESS.toString().equals(type)) {
+ return OPERATION_SUCCESS;
+ }
+ if (OPERATION_FAILURE.toString().equals(type)) {
+ return OPERATION_FAILURE;
+ }
+ if (FINAL_FAILURE.toString().equals(type)) {
+ return FINAL_FAILURE;
+ }
+ if (FINAL_SUCCESS.toString().equals(type)) {
+ return FINAL_SUCCESS;
+ }
+ if (FINAL_OPENLOOP.toString().equals(type)) {
+ return FINAL_OPENLOOP;
+ }
+ return null;
+ }
+
+}
diff --git a/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopOperation.java b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopOperation.java
new file mode 100644
index 000000000..8925ee287
--- /dev/null
+++ b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopOperation.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * 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.openecomp.policy.controlloop;
+
+import java.io.Serializable;
+import java.time.Instant;
+
+public class ControlLoopOperation implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8662706581293017099L;
+
+ public String actor;
+ public String operation;
+ public String target;
+ public Instant start = Instant.now();
+ public Instant end;
+ public String subRequestId;
+ public String outcome;
+ public String message;
+
+ public ControlLoopOperation() {
+
+ }
+
+ public ControlLoopOperation(ControlLoopOperation op) {
+ this.actor = op.actor;
+ this.operation = op.operation;
+ this.target = op.target;
+ this.start = op.start;
+ this.end = op.end;
+ this.subRequestId = op.subRequestId;
+ this.outcome = op.outcome;
+ this.message = op.message;
+ }
+
+ public String toMessage() {
+ return "actor="+actor+",operation="+operation+",target="+target+",subRequestId="+subRequestId;
+ }
+
+ public String toHistory() {
+ return "actor="+actor+",operation="+operation+",target="+target+",start="+start+",end="+end+",subRequestId="+subRequestId+",outcome="+outcome+",message="+message;
+ }
+
+ @Override
+ public String toString() {
+ return "ControlLoopOperation [actor=" + actor + ", operation=" + operation + ", target=" + target + ", start="
+ + start + ", end=" + end + ", subRequestId=" + subRequestId + ", outcome=" + outcome + ", message="
+ + message + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((actor == null) ? 0 : actor.hashCode());
+ result = prime * result + ((end == null) ? 0 : end.hashCode());
+ result = prime * result + ((message == null) ? 0 : message.hashCode());
+ result = prime * result + ((operation == null) ? 0 : operation.hashCode());
+ result = prime * result + ((outcome == null) ? 0 : outcome.hashCode());
+ result = prime * result + ((start == null) ? 0 : start.hashCode());
+ result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
+ result = prime * result + ((target == null) ? 0 : target.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ControlLoopOperation other = (ControlLoopOperation) obj;
+ if (actor == null) {
+ if (other.actor != null)
+ return false;
+ } else if (!actor.equals(other.actor))
+ return false;
+ if (end == null) {
+ if (other.end != null)
+ return false;
+ } else if (!end.equals(other.end))
+ return false;
+ if (message == null) {
+ if (other.message != null)
+ return false;
+ } else if (!message.equals(other.message))
+ return false;
+ if (operation == null) {
+ if (other.operation != null)
+ return false;
+ } else if (!operation.equals(other.operation))
+ return false;
+ if (outcome == null) {
+ if (other.outcome != null)
+ return false;
+ } else if (!outcome.equals(other.outcome))
+ return false;
+ if (start == null) {
+ if (other.start != null)
+ return false;
+ } else if (!start.equals(other.start))
+ return false;
+ if (subRequestId == null) {
+ if (other.subRequestId != null)
+ return false;
+ } else if (!subRequestId.equals(other.subRequestId))
+ return false;
+ if (target == null) {
+ if (other.target != null)
+ return false;
+ } else if (!target.equals(other.target))
+ return false;
+ return true;
+ }
+
+}
diff --git a/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopOperationWrapper.java b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopOperationWrapper.java
new file mode 100644
index 000000000..417a59d8e
--- /dev/null
+++ b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopOperationWrapper.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * 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.openecomp.policy.controlloop;
+
+import java.util.UUID;
+
+public class ControlLoopOperationWrapper {
+
+ public UUID requestID;
+ public ControlLoopOperation operation;
+
+ public ControlLoopOperationWrapper() {
+
+ }
+
+ public ControlLoopOperationWrapper(UUID requestID, ControlLoopOperation operation) {
+ this.requestID = requestID;
+ this.operation = operation;
+ }
+}
diff --git a/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopTargetType.java b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopTargetType.java
new file mode 100644
index 000000000..c1ed0e1d8
--- /dev/null
+++ b/controlloop/src/main/java/org/openecomp/policy/controlloop/ControlLoopTargetType.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * 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.openecomp.policy.controlloop;
+
+public enum ControlLoopTargetType {
+ VM("VM"),
+ VF("VF"),
+ VFC("VFC"),
+ ENODEB("eNodeB")
+ ;
+
+ private String type;
+
+ private ControlLoopTargetType(String type) {
+ this.type = type;
+ }
+
+ public String toString() {
+ return this.type;
+ }
+
+ public static ControlLoopTargetType toType(String type) {
+ if (VM.toString().equals(type)) {
+ return VM;
+ }
+ if (VF.toString().equals(type)) {
+ return VF;
+ }
+ if (VFC.toString().equals(type)) {
+ return VFC;
+ }
+ if (ENODEB.toString().equals(type)) {
+ return ENODEB;
+ }
+ return null;
+ }
+}
diff --git a/controlloop/src/main/java/org/openecomp/policy/controlloop/PhysicalControlLoopEvent.java b/controlloop/src/main/java/org/openecomp/policy/controlloop/PhysicalControlLoopEvent.java
new file mode 100644
index 000000000..615ee48bc
--- /dev/null
+++ b/controlloop/src/main/java/org/openecomp/policy/controlloop/PhysicalControlLoopEvent.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * 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.openecomp.policy.controlloop;
+
+public class PhysicalControlLoopEvent extends ControlLoopEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7282930271094849487L;
+
+ public PhysicalControlLoopEvent() {
+ }
+
+ public PhysicalControlLoopEvent(PhysicalControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ }
+
+
+}
diff --git a/controlloop/src/main/java/org/openecomp/policy/controlloop/PhysicalControlLoopNotification.java b/controlloop/src/main/java/org/openecomp/policy/controlloop/PhysicalControlLoopNotification.java
new file mode 100644
index 000000000..ee093cb67
--- /dev/null
+++ b/controlloop/src/main/java/org/openecomp/policy/controlloop/PhysicalControlLoopNotification.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * 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.openecomp.policy.controlloop;
+
+public class PhysicalControlLoopNotification extends ControlLoopNotification {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8105197217140032892L;
+
+ public PhysicalControlLoopNotification() {
+ }
+
+ public PhysicalControlLoopNotification(PhysicalControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ }
+
+}
diff --git a/controlloop/src/main/java/org/openecomp/policy/controlloop/VirtualControlLoopEvent.java b/controlloop/src/main/java/org/openecomp/policy/controlloop/VirtualControlLoopEvent.java
new file mode 100644
index 000000000..6ca280e4a
--- /dev/null
+++ b/controlloop/src/main/java/org/openecomp/policy/controlloop/VirtualControlLoopEvent.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * 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.openecomp.policy.controlloop;
+
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.Map;
+
+public class VirtualControlLoopEvent extends ControlLoopEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5752405682246066226L;
+ public Instant closedLoopAlarmStart;
+ public Instant closedLoopAlarmEnd;
+ public Map<String, String> AAI = new HashMap<String, String>();
+
+ public VirtualControlLoopEvent() {
+ }
+
+ public VirtualControlLoopEvent(VirtualControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ if (event.AAI != null) {
+ this.AAI = new HashMap<String, String>(event.AAI);
+ }
+ this.closedLoopAlarmStart = event.closedLoopAlarmStart;
+ this.closedLoopAlarmEnd = event.closedLoopAlarmEnd;
+ }
+
+}
diff --git a/controlloop/src/main/java/org/openecomp/policy/controlloop/VirtualControlLoopNotification.java b/controlloop/src/main/java/org/openecomp/policy/controlloop/VirtualControlLoopNotification.java
new file mode 100644
index 000000000..239a3ef21
--- /dev/null
+++ b/controlloop/src/main/java/org/openecomp/policy/controlloop/VirtualControlLoopNotification.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * 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.openecomp.policy.controlloop;
+
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.Map;
+
+public class VirtualControlLoopNotification extends ControlLoopNotification {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5354756047932144017L;
+
+ public Map<String, String> AAI = new HashMap<String, String>();
+ public Instant closedLoopAlarmStart;
+ public Instant closedLoopAlarmEnd;
+
+ public VirtualControlLoopNotification() {
+ }
+
+ public VirtualControlLoopNotification(VirtualControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ if (event.AAI != null) {
+ this.AAI = new HashMap<String, String>(event.AAI);
+ }
+ this.closedLoopAlarmStart = event.closedLoopAlarmStart;
+ this.closedLoopAlarmEnd = event.closedLoopAlarmEnd;
+ }
+
+}
diff --git a/controlloop/src/main/java/org/openecomp/policy/controlloop/util/Serialization.java b/controlloop/src/main/java/org/openecomp/policy/controlloop/util/Serialization.java
new file mode 100644
index 000000000..2625da712
--- /dev/null
+++ b/controlloop/src/main/java/org/openecomp/policy/controlloop/util/Serialization.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * 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.openecomp.policy.controlloop.util;
+
+import java.lang.reflect.Type;
+import java.time.Instant;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import org.openecomp.policy.controlloop.ControlLoopNotificationType;
+import org.openecomp.policy.controlloop.ControlLoopTargetType;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+public final class Serialization {
+
+ public static class notificationTypeAdapter implements JsonSerializer<ControlLoopNotificationType>, JsonDeserializer<ControlLoopNotificationType> {
+
+ @Override
+ public JsonElement serialize(ControlLoopNotificationType src, Type typeOfSrc,
+ JsonSerializationContext context) {
+ return new JsonPrimitive(src.toString());
+ }
+
+ @Override
+ public ControlLoopNotificationType deserialize(JsonElement json, Type typeOfT,
+ JsonDeserializationContext context) throws JsonParseException {
+ return ControlLoopNotificationType.toType(json.getAsString());
+ }
+
+ }
+
+ public static class targetTypeAdapter implements JsonSerializer<ControlLoopTargetType>, JsonDeserializer<ControlLoopTargetType> {
+
+ @Override
+ public JsonElement serialize(ControlLoopTargetType src, Type typeOfSrc,
+ JsonSerializationContext context) {
+ return new JsonPrimitive(src.toString());
+ }
+
+ @Override
+ public ControlLoopTargetType deserialize(JsonElement json, Type typeOfT,
+ JsonDeserializationContext context) throws JsonParseException {
+ return ControlLoopTargetType.toType(json.getAsString());
+ }
+
+ }
+
+ public static class gsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+ public static DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+
+ public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
+ throws JsonParseException {
+ try {
+ return ZonedDateTime.parse(element.getAsString(), format);
+ } catch (Exception e) {
+ System.err.println(e);
+ }
+ return null;
+ }
+
+ public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) {
+ return new JsonPrimitive(datetime.format(format));
+ }
+ }
+
+ public static class gsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ return Instant.ofEpochMilli(json.getAsLong());
+ }
+
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toEpochMilli());
+ }
+
+ }
+
+ final static public Gson gson = new GsonBuilder().disableHtmlEscaping()
+ .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
+ .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new notificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter())
+ .create();
+
+
+ final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
+ .setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
+ .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new notificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter())
+ .create();
+
+}
diff --git a/controlloop/src/main/resources/definitions.yaml b/controlloop/src/main/resources/definitions.yaml
new file mode 100644
index 000000000..13016ef5a
--- /dev/null
+++ b/controlloop/src/main/resources/definitions.yaml
@@ -0,0 +1,96 @@
+###
+# ============LICENSE_START=======================================================
+# controlloop
+# ================================================================================
+# 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=========================================================
+###
+
+ControlLoop:
+ type: object
+ description: Common fields for control loop events and notifications
+ properties:
+ closedLoopControlName:
+ type: string
+ description: A UNIQUE string identifying the Closed Loop ID this event is for. There are no semantics behind this string.
+ requestID:
+ type: string
+ description: This is required via ECOMP Platform Logging Requirements.
+ pattern: /[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/
+ closedLoopAlarmStart:
+ type: string
+ description: firstEpoch. UTC Timestamp when this event was detected by DCAE. Conform to ECOMP Logging requirements.
+ closedLoopAlarmEnd:
+ type: string
+ description: lastEpoch. UTC Timestamp when this event was detected as cleared by DCAE. Conform to ECOMP Logging requirements.
+ closedLoopEventClient:
+ type: string
+ description: Open DCAE sub-system that detected the event and published this event message.
+ target:
+ type: string
+ description: The target entity that is being administered. This could be VM_NAME, VNF_NAME, etc. This should map to a field name in the AAI sub-tag shown below.
+ AAI:
+ type: object
+ description: Fields of node.attribute and their values that map to AAI topology.
+ from:
+ type: string
+ description: The ECOMP component generating this message.
+ policyScope:
+ type: string
+ description: The policy scope driving the generation of this message.
+ policyName:
+ type: string
+ description: The policy name driving the generation of this message.
+ policyVersion:
+ type: string
+ description: The policy version driving the generation of this message.
+ required:
+ - closedLoopControlName
+ - requestID
+ - closedLoopAlarmStart
+ - closedLoopEventClient
+ - target
+ - AAI
+ - from
+ - policyScope
+ - policyName
+ - policyVersion
+Event:
+ allOf:
+ - $ref: '#/ControlLoop'
+ - properties:
+ closedLoopEventStatus:
+ type: string
+ description: The status for the event within Open DCAE. A value of “ONSET� indicates the event has been encountered. “ABATED� indicates the event has been abated.
+ valid_values:
+ - ONSET
+ - ABATEMENT
+ - required:
+ - closedLoopEventStatus
+Notification:
+ - $ref: '#/ControlLoop'
+ - properties:
+ notification:
+ type: string
+ notificationTime:
+ type: string
+ message:
+ type: string
+ OPS_CL_timer:
+ type: int
+ - required:
+ - notification
+ - notificationTime
+ - OPS_CL_timer
diff --git a/mso/pom.xml b/mso/pom.xml
new file mode 100644
index 000000000..f89ea372a
--- /dev/null
+++ b/mso/pom.xml
@@ -0,0 +1,51 @@
+<!--
+ ============LICENSE_START=======================================================
+ Drools PDP Application Models
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>mso</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>rest</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSOAsyncRequestStatus.java b/mso/src/main/java/org/openecomp/policy/mso/MSOAsyncRequestStatus.java
new file mode 100644
index 000000000..d3c24b403
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSOAsyncRequestStatus.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSOAsyncRequestStatus implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("correlator")
+ public String correlator;
+
+ @SerializedName("requestId")
+ public String requestId;
+
+ @SerializedName("instanceReferences")
+ public MSOInstanceReferences instanceReferences;
+
+ @SerializedName("startTime")
+ public LocalDateTime startTime;
+
+ @SerializedName("finishTime")
+ public LocalDateTime finishTime;
+
+ @SerializedName("requestScope")
+ public String requestScope;
+
+ @SerializedName("requestType")
+ public String requestType;
+
+ @SerializedName("requestStatus")
+ public MSORequestStatus requestStatus;
+
+
+ public MSOAsyncRequestStatus() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSOCloudConfiguration.java b/mso/src/main/java/org/openecomp/policy/mso/MSOCloudConfiguration.java
new file mode 100644
index 000000000..847619eaa
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSOCloudConfiguration.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSOCloudConfiguration implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("lcpCloudRegionId")
+ public String lcpCloudRegionId;
+
+ @SerializedName("tenantId")
+ public String tenantId;
+
+ public MSOCloudConfiguration() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSOInstanceReferences.java b/mso/src/main/java/org/openecomp/policy/mso/MSOInstanceReferences.java
new file mode 100644
index 000000000..3c3c4961d
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSOInstanceReferences.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSOInstanceReferences implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("requestId")
+ public String requestId;
+
+ @SerializedName("instanceId")
+ public String instanceId;
+
+ public MSOInstanceReferences() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSOManager.java b/mso/src/main/java/org/openecomp/policy/mso/MSOManager.java
new file mode 100644
index 000000000..75369e6e4
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSOManager.java
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openecomp.policy.mso.util.Serialization;
+import org.openecomp.policy.rest.RESTManager;
+import org.openecomp.policy.rest.RESTManager.Pair;
+
+import com.google.gson.JsonSyntaxException;
+
+public final class MSOManager {
+
+ public static MSOResponse createModuleInstance(String url, String urlBase, String username, String password, MSORequest request) {
+
+ //
+ // Call REST
+ //
+ Map<String, String> headers = new HashMap<String, String>();
+ //headers.put("X-FromAppId", "POLICY");
+ //headers.put("X-TransactionId", requestID.toString());
+ headers.put("Accept", "application/json");
+
+ //
+ // 201 - CREATED - you are done just return
+ //
+
+ Pair<Integer, String> httpDetails = RESTManager.post(url, username, password, headers, "application/json", Serialization.gsonPretty.toJson(request));
+
+ if (httpDetails == null) {
+ return null;
+ }
+
+ if (httpDetails.a == 202) {
+ try {
+ MSOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, MSOResponse.class);
+
+ String body = Serialization.gsonPretty.toJson(response);
+ System.out.println("***** Response to post:");
+ System.out.println(body);
+
+ String requestId = response.requestReferences.requestId;
+ int attemptsLeft = 7;
+
+ //String getUrl = "/orchestrationRequests/v2/"+requestId;
+ String urlGet = urlBase + "/orchestrationRequests/v2/"+requestId;
+ MSOResponse responseGet = null;
+
+ while(attemptsLeft-- > 0){
+
+ Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
+ responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, MSOResponse.class);
+ body = Serialization.gsonPretty.toJson(responseGet);
+ System.out.println("***** Response to get:");
+ System.out.println(body);
+
+ if(httpDetailsGet.a == 200){
+ if(responseGet.request.requestStatus.requestState.equalsIgnoreCase("COMPLETE") ||
+ responseGet.request.requestStatus.requestState.equalsIgnoreCase("FAILED")){
+ System.out.println("***** ######## VF Module Creation "+responseGet.request.requestStatus.requestState);
+ return responseGet;
+ }
+ }
+ Thread.sleep(20000);
+ }
+
+ System.out.println("***** ######## VF Module Creation takes too long... can't wait longer. Status: ("+responseGet.request.requestStatus.requestState+")");
+ return responseGet;
+ } catch (JsonSyntaxException e) {
+ System.err.println("Failed to deserialize into MSOResponse" + e.getLocalizedMessage());
+ } catch (InterruptedException e) {
+ System.err.println("Interrupted exception: " + e.getLocalizedMessage());
+ }
+ }
+
+
+
+
+ return null;
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSOModelInfo.java b/mso/src/main/java/org/openecomp/policy/mso/MSOModelInfo.java
new file mode 100644
index 000000000..a908056da
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSOModelInfo.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSOModelInfo implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("modelType")
+ public String modelType;
+
+ @SerializedName("modelInvariantId")
+ public String modelInvariantId;
+
+ @SerializedName("modelNameVersionId")
+ public String modelNameVersionId;
+
+ @SerializedName("modelName")
+ public String modelName;
+
+ @SerializedName("modelVersion")
+ public String modelVersion;
+
+ @SerializedName("modelCustomizationName")
+ public String modelCustomizationName;
+
+ public MSOModelInfo() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSOPolicyException.java b/mso/src/main/java/org/openecomp/policy/mso/MSOPolicyException.java
new file mode 100644
index 000000000..4dc6ad8b2
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSOPolicyException.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSOPolicyException implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("messageId")
+ public String messageId;
+
+ @SerializedName("text")
+ public String text;
+
+ public MSOPolicyException() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSORelatedInstance.java b/mso/src/main/java/org/openecomp/policy/mso/MSORelatedInstance.java
new file mode 100644
index 000000000..09cbba65d
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSORelatedInstance.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+
+
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSORelatedInstance implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("instanceId")
+ public String instanceId;
+
+ @SerializedName("instanceName")
+ public String instanceName;
+
+ @SerializedName("modelInfo")
+ public MSOModelInfo modelInfo;
+
+
+ public MSORelatedInstance() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSORelatedInstanceListElement.java b/mso/src/main/java/org/openecomp/policy/mso/MSORelatedInstanceListElement.java
new file mode 100644
index 000000000..31a9158a5
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSORelatedInstanceListElement.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSORelatedInstanceListElement implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("relatedInstance")
+ public MSORelatedInstance relatedInstance;
+
+
+ public MSORelatedInstanceListElement() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSORequest.java b/mso/src/main/java/org/openecomp/policy/mso/MSORequest.java
new file mode 100644
index 000000000..331fcb5b3
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSORequest.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSORequest implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("requestId")
+ public String requestId;
+
+ @SerializedName("startTime")
+ //public LocalDateTime startTime;
+ public String startTime;
+
+ @SerializedName("finishTime")
+ public LocalDateTime finishTime;
+
+ @SerializedName("requestScope")
+ public String requestScope;
+
+ @SerializedName("requestType")
+ public String requestType;
+
+ @SerializedName("requestDetails")
+ public MSORequestDetails requestDetails;
+
+ @SerializedName("requestStatus")
+ public MSORequestStatus requestStatus;
+
+ public MSORequest() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSORequestDetails.java b/mso/src/main/java/org/openecomp/policy/mso/MSORequestDetails.java
new file mode 100644
index 000000000..182675f91
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSORequestDetails.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSORequestDetails implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("modelInfo")
+ public MSOModelInfo modelInfo;
+
+ @SerializedName("cloudConfiguration")
+ public MSOCloudConfiguration cloudConfiguration;
+
+ @SerializedName("requestInfo")
+ public MSORequestInfo requestInfo;
+
+ @SerializedName("subscriberInfo")
+ public MSOSubscriberInfo subscriberInfo;
+
+ @SerializedName("relatedInstanceList")
+ public List<MSORelatedInstanceListElement> relatedInstanceList= new LinkedList<MSORelatedInstanceListElement>();
+
+ @SerializedName("requestParameters")
+ public MSORequestParameters requestParameters;
+
+ public MSORequestDetails() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSORequestError.java b/mso/src/main/java/org/openecomp/policy/mso/MSORequestError.java
new file mode 100644
index 000000000..42c4182a0
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSORequestError.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSORequestError implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+
+ @SerializedName("policyException")
+ public MSOPolicyException policyException;
+
+
+ @SerializedName("serviceException")
+ public MSOServiceException serviceException;
+
+ /*
+ @SerializedName("messageId")
+ public String messageId;
+
+ @SerializedName("text")
+ public String text;
+
+ @SerializedName("url")
+ public String url;
+
+ @SerializedName("variables")
+ public String variables;
+ */
+
+ public MSORequestError() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSORequestInfo.java b/mso/src/main/java/org/openecomp/policy/mso/MSORequestInfo.java
new file mode 100644
index 000000000..4c033a465
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSORequestInfo.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSORequestInfo implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("instanceName")
+ public String instanceName;
+
+ @SerializedName("source")
+ public String source;
+
+ @SerializedName("productFamilyId")
+ public String productFamilyId;
+
+ @SerializedName("suppressRollback")
+ public boolean suppressRollback;
+
+ @SerializedName("billingAccountNumber")
+ public String billingAccountNumber;
+
+ @SerializedName("callbackUrl")
+ public String callbackUrl;
+
+ @SerializedName("correlator")
+ public String correlator;
+
+ @SerializedName("orderNumber")
+ public String orderNumber;
+
+ @SerializedName("orderVersion")
+ public Integer orderVersion;
+
+
+ public MSORequestInfo() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSORequestParameters.java b/mso/src/main/java/org/openecomp/policy/mso/MSORequestParameters.java
new file mode 100644
index 000000000..d40cdc9a4
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSORequestParameters.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSORequestParameters implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("subscriptionServiceType")
+ public String subscriptionServiceType;
+
+ @SerializedName("userParams")
+ public List<Map<String, String>> userParams = new LinkedList<Map<String, String>>();
+
+ public MSORequestParameters() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSORequestReferences.java b/mso/src/main/java/org/openecomp/policy/mso/MSORequestReferences.java
new file mode 100644
index 000000000..dea094567
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSORequestReferences.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSORequestReferences implements Serializable {
+
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("instanceId")
+ public String instanceId;
+
+ @SerializedName("requestId")
+ public String requestId;
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSORequestStatus.java b/mso/src/main/java/org/openecomp/policy/mso/MSORequestStatus.java
new file mode 100644
index 000000000..df2ce898d
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSORequestStatus.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSORequestStatus implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("percentProgress")
+ public int percentProgress;
+
+ @SerializedName("requestState")
+ public String requestState;
+
+ @SerializedName("timestamp")
+ //public LocalDateTime timestamp;
+ public String timestamp;
+
+ @SerializedName("wasRolledBack")
+ public boolean wasRolledBack;
+
+
+ public MSORequestStatus() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSOResponse.java b/mso/src/main/java/org/openecomp/policy/mso/MSOResponse.java
new file mode 100644
index 000000000..51a8c5d42
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSOResponse.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSOResponse implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("requestReferences")
+ public MSORequestReferences requestReferences;
+
+ @SerializedName("requestError")
+ public MSORequestError requestError;
+
+ @SerializedName("request")
+ public MSORequest request;
+
+
+
+ public MSOResponse() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSOServiceException.java b/mso/src/main/java/org/openecomp/policy/mso/MSOServiceException.java
new file mode 100644
index 000000000..b03da3f2b
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSOServiceException.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSOServiceException implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("messageId")
+ public String messageId;
+
+ @SerializedName("text")
+ public String text;
+
+ @SerializedName("variables")
+ public List<String> variables = new LinkedList<String>();
+
+ public MSOServiceException() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/MSOSubscriberInfo.java b/mso/src/main/java/org/openecomp/policy/mso/MSOSubscriberInfo.java
new file mode 100644
index 000000000..a14ffee33
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/MSOSubscriberInfo.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.io.Serializable;
+
+
+import com.google.gson.annotations.SerializedName;
+
+public class MSOSubscriberInfo implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("globalSubscriberId")
+ public String globalSubscriberId;
+
+ @SerializedName("subscriberCommonSiteId")
+ public String subscriberCommonSiteId;
+
+ @SerializedName("subscriberName")
+ public String subscriberName;
+
+ public MSOSubscriberInfo() {
+ }
+
+}
diff --git a/mso/src/main/java/org/openecomp/policy/mso/util/Serialization.java b/mso/src/main/java/org/openecomp/policy/mso/util/Serialization.java
new file mode 100644
index 000000000..fa82dde59
--- /dev/null
+++ b/mso/src/main/java/org/openecomp/policy/mso/util/Serialization.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso.util;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public final class Serialization {
+
+ final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
+ .setPrettyPrinting()
+ .create();
+
+}
diff --git a/mso/src/test/java/org/openecomp/policy/mso/TestDemo.java b/mso/src/test/java/org/openecomp/policy/mso/TestDemo.java
new file mode 100644
index 000000000..e9a7ec0d0
--- /dev/null
+++ b/mso/src/test/java/org/openecomp/policy/mso/TestDemo.java
@@ -0,0 +1,164 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * mso
+ * ================================================================================
+ * 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.openecomp.policy.mso;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.openecomp.policy.mso.util.Serialization;
+
+public class TestDemo {
+
+ @Test
+ public void test() {
+
+ MSORequest request = new MSORequest();
+ request.requestDetails = new MSORequestDetails();
+ request.requestDetails.modelInfo = new MSOModelInfo();
+ request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();
+ request.requestDetails.requestInfo = new MSORequestInfo();
+ request.requestDetails.requestParameters = new MSORequestParameters();
+
+ request.requestDetails.modelInfo.modelType = "vfModule";
+ request.requestDetails.modelInfo.modelInvariantId = "ff5256d2-5a33-55df-13ab-12abad84e7ff";
+ request.requestDetails.modelInfo.modelNameVersionId = "fe6478e5-ea33-3346-ac12-ab121484a3fe";
+ request.requestDetails.modelInfo.modelName = "vSAMP12..base..module-0";
+ request.requestDetails.modelInfo.modelVersion = "1";
+
+ request.requestDetails.cloudConfiguration.lcpCloudRegionId = "mdt1";
+ request.requestDetails.cloudConfiguration.tenantId = "88a6ca3ee0394ade9403f075db23167e";
+
+ request.requestDetails.requestInfo.instanceName = "MSOTEST103a-vSAMP12_base_module-0";
+ request.requestDetails.requestInfo.source = "VID";
+ request.requestDetails.requestInfo.suppressRollback = true;
+
+ MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();
+ MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();
+ MSORelatedInstanceListElement relatedInstanceListElement3 = new MSORelatedInstanceListElement();
+ relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();
+ relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();
+ relatedInstanceListElement3.relatedInstance = new MSORelatedInstance();
+
+ relatedInstanceListElement1.relatedInstance.instanceId = "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c";
+ relatedInstanceListElement1.relatedInstance.instanceName = "MSOTESTVOL103a-vSAMP12_base_module-0_vol";
+ relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "volumeGroup";
+
+ relatedInstanceListElement2.relatedInstance.instanceId = "serviceInstanceId";
+ relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "service";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = "ff3514e3-5a33-55df-13ab-12abad84e7ff";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = "fe6985cd-ea33-3346-ac12-ab121484a3fe";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "parent service model name";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "1.0";
+
+ relatedInstanceListElement3.relatedInstance.instanceId = "vnfInstanceId";
+ relatedInstanceListElement3.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement3.relatedInstance.modelInfo.modelType = "vnf";
+ relatedInstanceListElement3.relatedInstance.modelInfo.modelInvariantId = "ff5256d1-5a33-55df-13ab-12abad84e7ff";
+ relatedInstanceListElement3.relatedInstance.modelInfo.modelNameVersionId = "fe6478e4-ea33-3346-ac12-ab121484a3fe";
+ relatedInstanceListElement3.relatedInstance.modelInfo.modelName = "vSAMP12";
+ relatedInstanceListElement3.relatedInstance.modelInfo.modelVersion = "1.0";
+ relatedInstanceListElement3.relatedInstance.modelInfo.modelCustomizationName = "vSAMP12 1";
+
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement3);
+
+ Map<String, String> userParam1 = new HashMap<String, String>();
+ userParam1.put("name1", "value1");
+
+ Map<String, String> userParam2 = new HashMap<String, String>();
+ userParam2.put("name2", "value2");
+
+ request.requestDetails.requestParameters.userParams.add(userParam1);
+ request.requestDetails.requestParameters.userParams.add(userParam2);
+
+ String body = Serialization.gsonPretty.toJson(request);
+ System.out.println(body);
+
+ //MSOResponse response = MSOManager.createModuleInstance("http://localhost:7780/", "my_username", "my_passwd", request);
+
+ //body = Serialization.gsonPretty.toJson(response);
+ //System.out.println(body);
+
+ }
+
+ @Test
+ public void testHack() {
+
+ System.out.println("** HACK **");
+
+ MSORequest request = new MSORequest();
+ //
+ request.requestDetails = new MSORequestDetails();
+ request.requestDetails.modelInfo = new MSOModelInfo();
+ request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();
+ request.requestDetails.requestInfo = new MSORequestInfo();
+ request.requestDetails.requestParameters = new MSORequestParameters();
+ request.requestDetails.requestParameters.userParams = null;
+
+ request.requestDetails.modelInfo.modelType = "vfModule";
+ request.requestDetails.modelInfo.modelInvariantId = "a9c4a35a-de48-451a-9e4e-343f2ac52928";
+ request.requestDetails.modelInfo.modelNameVersionId = "e0d98ad1-238d-4555-b439-023d3f9079f6";
+ request.requestDetails.modelInfo.modelName = "0d9e0d9d352749f4B3cb..dnsscaling..module-0";
+ request.requestDetails.modelInfo.modelVersion = "2.0";
+
+ request.requestDetails.cloudConfiguration.lcpCloudRegionId = "DFW";
+ request.requestDetails.cloudConfiguration.tenantId = "1015548";
+
+ request.requestDetails.requestInfo.instanceName = "Vfmodule_Ete_Name1eScaling63928f-ccdc-4b34-bdef-9bf64109026e";
+ request.requestDetails.requestInfo.source = "POLICY";
+ request.requestDetails.requestInfo.suppressRollback = false;
+
+ MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();
+ MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();
+ relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();
+ relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();
+
+ String serviceInstanceId = "98af39ce-6408-466b-921f-c2c7a8f59ed6";
+ relatedInstanceListElement1.relatedInstance.instanceId = serviceInstanceId;
+ relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = "24329a0c-1d57-4210-b1af-a65df64e9d59";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = "ac642881-8e7e-4217-bd64-16ad41c42e30";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelName = "5116d67e-0b4f-46bf-a46f";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = "2.0";
+
+ String vnfInstanceId = "8eb411b8-a936-412f-b01f-9a9a435c0e93";
+ relatedInstanceListElement2.relatedInstance.instanceId = vnfInstanceId;
+ relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = "09fd971e-db5f-475d-997c-cf6704b6b8fe";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = "152ed917-6dcc-46ee-bf8a-a775c5aa5a74";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "9e4c31d2-4b25-4d9e-9fb4";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "2.0";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = "0d9e0d9d-3527-49f4-b3cb 2";
+
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
+
+ String body = Serialization.gsonPretty.toJson(request);
+ System.out.println(body);
+ }
+
+}
diff --git a/packages/apps/pom.xml b/packages/apps/pom.xml
new file mode 100644
index 000000000..ed5f04cd2
--- /dev/null
+++ b/packages/apps/pom.xml
@@ -0,0 +1,77 @@
+<!--
+ ============LICENSE_START=======================================================
+ PDP-D Application Installation Packages
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>packages</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>apps</artifactId>
+ <packaging>pom</packaging>
+
+ <name>PDP-D APPS Installation Package</name>
+ <description>PDP-D APPS Installation Package</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/zip.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- List any dependencies here that should be included in the installer zip -->
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>basex</artifactId>
+ <version>${project.version}</version>
+ <type>tar.gz</type>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>artifacts</artifactId>
+ <version>${project.version}</version>
+ <type>zip</type>
+ </dependency>
+ </dependencies>
+
+</project>
+
diff --git a/packages/apps/src/assembly/zip.xml b/packages/apps/src/assembly/zip.xml
new file mode 100644
index 000000000..f3392e130
--- /dev/null
+++ b/packages/apps/src/assembly/zip.xml
@@ -0,0 +1,40 @@
+<!--
+ ============LICENSE_START=======================================================
+ PDP-D APPS Installation Package
+ ================================================================================
+ 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=========================================================
+ -->
+
+<assembly>
+ <id>zipfile</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>src/files</directory>
+ <outputDirectory>.</outputDirectory>
+ <fileMode>755</fileMode>
+ </fileSet>
+ </fileSets>
+ <dependencySets>
+ <dependencySet>
+ <useTransitiveDependencies>false</useTransitiveDependencies>
+ </dependencySet>
+ </dependencySets>
+</assembly>
+
diff --git a/packages/apps/src/files/README.apps.txt b/packages/apps/src/files/README.apps.txt
new file mode 100644
index 000000000..aab021885
--- /dev/null
+++ b/packages/apps/src/files/README.apps.txt
@@ -0,0 +1,8 @@
+
+The PDP-D apps installation package contains:
+
+1. artifacts-<version>.zip contains models and other jars to support PDP-D applications.
+2. basex-<version>.tar.gz contains scripts and additional files to support the PDP-D models.
+
+The apps-<version>.zip must be placed in the same directory as the installation package
+before installation before installation is attempted.
diff --git a/packages/artifacts/pom.xml b/packages/artifacts/pom.xml
new file mode 100644
index 000000000..0cd8d39d2
--- /dev/null
+++ b/packages/artifacts/pom.xml
@@ -0,0 +1,124 @@
+<!--
+ ============LICENSE_START=======================================================
+ PDP-D Application Installation Packages
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>packages</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>artifacts</artifactId>
+ <packaging>pom</packaging>
+
+ <name>Artifacts for PDP-D Applications</name>
+ <description>PDP-D models, rules and tooling</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/zip.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- The following are placed in the local repository at installation -->
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>demo</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>controlloop</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>rest</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>appc</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>aai</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>mso</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>trafficgenerator</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>vfwsim</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>archetype-closedloop-demo-rules</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/packages/artifacts/src/assembly/zip.xml b/packages/artifacts/src/assembly/zip.xml
new file mode 100644
index 000000000..e3f018d26
--- /dev/null
+++ b/packages/artifacts/src/assembly/zip.xml
@@ -0,0 +1,33 @@
+<!--
+ ============LICENSE_START=======================================================
+ Artifacts for PDP-D Applications
+ ================================================================================
+ 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=========================================================
+ -->
+
+<assembly>
+ <id>zipfile</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>artifacts</outputDirectory>
+ <useTransitiveDependencies>false</useTransitiveDependencies>
+ </dependencySet>
+ </dependencySets>
+</assembly>
diff --git a/packages/basex/pom.xml b/packages/basex/pom.xml
new file mode 100644
index 000000000..32b6b78e2
--- /dev/null
+++ b/packages/basex/pom.xml
@@ -0,0 +1,61 @@
+<!--
+ ============LICENSE_START=======================================================
+ PDP-D Application Installation Packages
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>packages</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>basex</artifactId>
+ <packaging>pom</packaging>
+
+ <name>PDP-D APPS Base Package</name>
+ <description>PDP-D APPS Packaging</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/zip.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
diff --git a/packages/basex/src/assembly/zip.xml b/packages/basex/src/assembly/zip.xml
new file mode 100644
index 000000000..a33f1b7e5
--- /dev/null
+++ b/packages/basex/src/assembly/zip.xml
@@ -0,0 +1,36 @@
+<!--
+ ============LICENSE_START=======================================================
+ PDP-D APPS Base Package
+ ================================================================================
+ 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=========================================================
+ -->
+
+<assembly>
+ <id>basex</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>src/files</directory>
+ <outputDirectory>.</outputDirectory>
+ <fileMode>700</fileMode>
+ <directoryMode>700</directoryMode>
+ </fileSet>
+ </fileSets>
+</assembly>
+
diff --git a/packages/basex/src/files/bin/create-closed-loop-demo.sh b/packages/basex/src/files/bin/create-closed-loop-demo.sh
new file mode 100644
index 000000000..bb6c92e34
--- /dev/null
+++ b/packages/basex/src/files/bin/create-closed-loop-demo.sh
@@ -0,0 +1,315 @@
+#! /bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# PDP-D APPS Base Package
+# ================================================================================
+# 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=========================================================
+###
+
+# Interactive script to generate a closed loop demo rules artifact
+# for testing purposes of standalone PDP-D
+
+echo "Closed Loop Demo Creator for standalone PDP-D"
+echo "----------------------------------------------"
+echo
+
+GROUPID="org.openecomp.policy.demo.rules"
+ARTIFACTID="closed-loop-demo-rules"
+VERSION="1.0.0-SNAPSHOT"
+PACKAGE="org.openecomp.policy.demo.rules"
+CLOSEDLOOPCONTROLNAME="CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8"
+POLICYSCOPE="service=test;resource=FRWL;type=configuration"
+POLICYNAME="FirewallDemo"
+POLICYVERSION="v0.0.1"
+ACTOR="APPC"
+APPCTOPIC="APPC-CL"
+APPCSERVERS="vm1.mr.simpledemo.openecomp.org"
+APPCAPIKEY=
+APPCAPISECRET=
+NOTIFICATIONTOPIC="POLICY-CL-MGT"
+NOTIFICATIONSERVERS="vm1.mr.simpledemo.openecomp.org"
+NOTIFICATIONAPIKEY=
+NOTIFICATIONAPISECRET=
+DCAETOPIC="DCAE-CL-EVENT"
+DCAESERVERS="vm1.mr.simpledemo.openecomp.org"
+DCAEAPIKEY=
+DCAEAPISECRET=
+AAIURL="http://localhost:7676/aai/test"
+AAIUSERNAME="policy"
+AAIPASSWORD="policy"
+AAINAMEDQUERYUUID=d925ed73-8231-4d02-9545-db4e101fffff
+AAIPATTERNMATCH=true
+MSOURL="http://localhost:7677/mso/test"
+MSOUSERNAME="policy"
+MSOPASSWORD="policy"
+
+read -e -i "${GROUPID}" -p "Closed Loop Rules Maven Group Id> " GROUP_ID
+read -e -i "${ARTIFACTID}" -p "Closed Loop Rules Maven Coordinates Artifact Id> " ARTIFACTID
+read -e -i "${VERSION}" -p "Closed Loop Rules Maven Coordinates Version> " VERSION
+read -e -i "${PACKAGE}" -p "Closed Loop Rules Package> " PACKAGE
+read -e -i "${CLOSEDLOOPCONTROLNAME}" -p "Closed Loop Template Control Name> " CLOSEDLOOPCONTROLNAME
+read -e -i "${POLICYSCOPE}" -p "Closed Loop Policy Scope> " POLICYSCOPE
+read -e -i "${POLICYNAME}" -p "Closed Loop Policy Name> " POLICYNAME
+read -e -i "${POLICYVERSION}" -p "Closed Loop Policy Version> " POLICYVERSION
+read -e -i "${ACTOR}" -p "Closed Loop Actor ('APPC' or 'MSO')> " ACTOR
+read -e -i "${APPCTOPIC}" -p "Closed Loop APP-C Recipe Topic> " APPCTOPIC
+read -e -i "${APPCSERVERS}" -p "Closed Loop APP-C UEB Servers for ${APPCTOPIC} topic> " APPCSERVERS
+read -e -i "${APPCAPIKEY}" -p "Closed Loop APP-C UEB API Key for ${APPCTOPIC} topic> " APPCAPIKEY
+read -e -i "${APPCAPISECRET}" -p "Closed Loop APP-C UEB API Secret for ${APPCTOPIC} topic> " APPCAPISECRET
+read -e -i "${NOTIFICATIONTOPIC}" -p "Closed Loop Ruby Notification Topic> " NOTIFICATIONTOPIC
+read -e -i "${NOTIFICATIONSERVERS}" -p "Closed Loop Ruby UEB Servers for ${NOTIFICATIONTOPIC} topic> " NOTIFICATIONSERVERS
+read -e -i "${NOTIFICATIONAPIKEY}" -p "Closed Loop Ruby UEB API Key ${NOTIFICATIONTOPIC} topic> " NOTIFICATIONAPIKEY
+read -e -i "${NOTIFICATIONAPISECRET}" -p "Closed Loop Ruby UEB API Secret ${NOTIFICATIONTOPIC} topic> " NOTIFICATIONAPISECRET
+read -e -i "${DCAETOPIC}" -p "Closed Loop DCAE Topic> " DCAETOPIC
+read -e -i "${DCAESERVERS}" -p "Closed Loop DCAE UEB Servers> " DCAESERVERS
+read -e -i "${DCAEAPIKEY}" -p "Closed Loop DCAE UEB API Key for ${DCAETOPIC} topic> " DCAEAPIKEY
+read -e -i "${DCAEAPISECRET}" -p "Closed Loop DCAE UEB API Secret for ${DCAETOPIC} topic> " DCAEAPISECRET
+read -e -i "${AAIURL}" -p "Closed Loop AAI URL> " AAIURL
+read -e -i "${AAIUSERNAME}" -p "Closed Loop AAI Username> " AAIUSERNAME
+read -e -i "${AAIPASSWORD}" -p "Closed Loop AAI Password> " AAIPASSWORD
+read -e -i "${AAINAMEDQUERYUUID}" -p "Closed Loop AAI Named Query UUID> " AAINAMEDQUERYUUID
+read -e -i "${AAIPATTERNMATCH}" -p "Closed Loop AAI Pattern Match ('true' or 'false')> " AAINAMEDQUERYUUID
+read -e -i "${MSOURL}" -p "Closed Loop MSO URL> " MSOURL
+read -e -i "${MSOUSERNAME}" -p "Closed Loop MSO Username> " MSOUSERNAME
+read -e -i "${MSOPASSWORD}" -p "Closed Loop MSO Password> " MSOPASSWORD
+
+echo
+echo
+
+if [ -z "${GROUPID}" ]; then echo "Aborting: Closed Loop Rules Maven Group Id not provided"; exit 1; fi
+if [ -z "${ARTIFACTID}" ]; then echo "Aborting: Closed Loop Rules Maven Coordinates Artifact Id not provided"; exit 1; fi
+if [ -z "${VERSION}" ]; then echo "Aborting: Closed Loop Rules Maven Coordinates Version not provided"; exit 1; fi
+if [ -z "${PACKAGE}" ]; then echo "Aborting: Closed Loop Rules Package not provided"; exit 1; fi
+if [ -z "${CLOSEDLOOPCONTROLNAME}" ]; then echo "Aborting: Closed Loop Template Control Name not provided"; exit 1; fi
+if [ -z "${POLICYSCOPE}" ]; then echo "Aborting: Closed Loop Template Policy Scope not provided"; exit 1; fi
+if [ -z "${POLICYNAME}" ]; then echo "Aborting: Closed Loop Template Policy Name not provided"; exit 1; fi
+if [ -z "${POLICYVERSION}" ]; then echo "Aborting: Closed Loop Template Policy Version not provided"; exit 1; fi
+if [ -z "${ACTOR}" ]; then echo "Aborting: Closed Loop Template Actor not provided"; exit 1; fi
+if [ -z "${APPCTOPIC}" ]; then echo "Aborting: Closed Loop Template APP-C Recipe Topic not provided"; exit 1; fi
+if [ -z "${APPCSERVERS}" ]; then echo "Aborting: Closed Loop Template APP-C UEB Servers not provided"; exit 1; fi
+if [ -z "${NOTIFICATIONTOPIC}" ]; then echo "Aborting: Closed Loop Template Ruby Notification Topic not provided"; exit 1; fi
+if [ -z "${NOTIFICATIONSERVERS}" ]; then echo "Aborting: Closed Loop Template Ruby UEB Servers not provided"; exit 1; fi
+if [ -z "${DCAETOPIC}" ]; then echo "Aborting: Closed Loop Template DCAE DMAAP Topic not provided"; exit 1; fi
+if [ -z "${DCAESERVERS}" ]; then echo "Aborting: Closed Loop Template DCAE DMAAP Servers not provided"; exit 1; fi
+if [ -z "${AAIURL}" ]; then echo "Aborting: Closed Loop Template AAI URL not provided"; exit 1; fi
+if [ -z "${AAIUSERNAME}" ]; then echo "Aborting: Closed Loop Template AAI Username not provided"; exit 1; fi
+if [ -z "${AAIPASSWORD}" ]; then echo "Aborting: Closed Loop Template AAI Password not provided"; exit 1; fi
+if [ -z "${AAINAMEDQUERYUUID}" ]; then echo "Aborting: Closed Loop Template AAI Named Query UUID not provided"; exit 1; fi
+if [ -z "${AAIPATTERNMATCH}" ]; then echo "Aborting: Closed Loop Template AAPI Pattern Match not provided"; exit 1; fi
+if [ -z "${MSOURL}" ]; then echo "Aborting: Closed Loop Template MSO URL not provided"; exit 1; fi
+if [ -z "${MSOUSERNAME}" ]; then echo "Aborting: Closed Loop Template MSO Username not provided"; exit 1; fi
+if [ -z "${MSOPASSWORD}" ]; then echo "Aborting: Closed Loop Template MSO Password not provided"; exit 1; fi
+
+if [ -z "${DCAEAPIKEY}" ]; then DCAEAPIKEY="NULL"; fi
+if [ -z "${DCAEAPISECRET}" ]; then DCAEAPISECRET="NULL"; fi
+if [ -z "${APPCAPIKEY}" ]; then APPCAPIKEY="NULL"; fi
+if [ -z "${APPCAPISECRET}" ]; then APPCAPISECRET="NULL"; fi
+if [ -z "${NOTIFICATIONAPIKEY}" ]; then NOTIFICATIONAPIKEY="NULL"; fi
+if [ -z "${NOTIFICATIONAPISECRET}" ]; then NOTIFICATIONAPISECRET="NULL"; fi
+
+if [[ "$VERSION" == *-SNAPSHOT ]]; then
+ DEPENDENCIES_VERSION="1.0.0-SNAPSHOT"
+else
+ DEPENDENCIES_VERSION="${VERSION}"
+fi
+
+read -e -i "${DEPENDENCIES_VERSION}" -p "Closed Loop Model/PDP-D dependent version(s) (ie: 1.0.0-SNAPSHOT, 1607.31.1-1, or [1607.31.1,)) > " DEPENDENCIES_VERSION
+if [ -z "${DEPENDENCIES_VERSION}" ]; then echo "Aborting: Closed Loop Model/PDP-D dependencies not provided"; exit 1; fi
+
+echo "---------------------------------------------------------------------------------------"
+echo "Please review the entered Closed Loop Maven Coordinates and Policy Template Parameters:"
+echo
+echo "Installation in Local Maven Repository"
+echo
+echo "Closed Loop Rules Maven Artifact Generation: Group Id: ${GROUP_ID}"
+echo "Closed Loop Rules Maven Artifact Generation: Artifact Id: ${ARTIFACTID}"
+echo "Closed Loop Rules Maven Artifact Generation: Version: ${VERSION}"
+echo "Closed Loop Rules Maven Artifact Generation: Package: ${PACKAGE}"
+echo
+echo "Closed Loop Template Drools DRL Expansion: Closed Loop Control Name: ${CLOSEDLOOPCONTROLNAME}"
+echo "Closed Loop Template Drools DRL Expansion: Closed Loop Policy Scope: ${POLICYSCOPE}"
+echo "Closed Loop Template Drools DRL Expansion: Closed Loop Policy Name: ${POLICYNAME}"
+echo "Closed Loop Template Drools DRL Expansion: Closed Loop Policy Version: ${POLICYVERSION}"
+echo "Closed Loop Template Drools DRL Expansion: Closed Loop Actor: ${ACTOR}"
+echo "Closed Loop Template Drools DRL Expansion: Closed Loop Recipe: ${APPC}"
+echo "Closed Loop Template Drools DRL Expansion: Closed Loop Recipe Topic: ${APPCTOPIC}"
+echo "Closed Loop Template Drools DRL Expansion: Closed Loop Notification Topic: ${NOTIFICATIONTOPIC}"
+echo
+echo "Closed Loop Controller Configuration: Rules: Group Id: ${GROUP_ID}"
+echo "Closed Loop Controller Configuration: Rules: Artifact Id: ${ARTIFACTID}"
+echo "Closed Loop Controller Configuration: Rules: Version: ${VERSION}"
+echo
+echo "Closed Loop Controller Configuration: DCAE UEB Topic: ${DCAETOPIC}"
+echo "Closed Loop Controller Configuration: DCAE UEB Servers: ${DCAESERVERS}"
+echo "Closed Loop Controller Configuration: DCAE UEB API Key: ${DCAEAPIKEY}"
+echo "Closed Loop Controller Configuration: DCAE UEB API Secret: ${DCAEAPISECRET}"
+echo
+echo "Closed Loop Controller Configuration: APP-C UEB Topic: ${APPCTOPIC}"
+echo "Closed Loop Controller Configuration: APP-C UEB Servers: ${APPCSERVERS}"
+echo "Closed Loop Controller Configuration: APP-C UEB API Key: ${APPCAPIKEY}"
+echo "Closed Loop Controller Configuration: APP-C UEB API Secret: ${APPCAPISECRET}"
+echo
+echo "Closed Loop Controller Configuration: NOTIFICATION Topic: ${NOTIFICATIONTOPIC}"
+echo "Closed Loop Controller Configuration: NOTIFICATION UEB Servers: ${NOTIFICATIONSERVERS}"
+echo "Closed Loop Controller Configuration: NOTIFICATION UEB API Key: ${NOTIFICATIONAPIKEY}"
+echo "Closed Loop Controller Configuration: NOTIFICATION UEB API Secret: ${NOTIFICATIONAPISECRET}"
+echo
+echo "Closed Loop Controller Configuration: AAI URL: ${AAIURL}"
+echo "Closed Loop Controller Configuration: AAI Username: ${AAIUSERNAME}"
+echo "Closed Loop Controller Configuration: AAI Password: ${AAIPASSWORD}"
+echo "Closed Loop Controller Configuration: AAI Named Query UUID: ${AAINAMEDQUERYUUID}"
+echo "Closed Loop Controller Configuration: AAI Pattern Match: ${AAIPATTERNMATCH}"
+echo
+echo "Closed Loop Controller Configuration: MSO URL: ${MSOURL}"
+echo "Closed Loop Controller Configuration: MSO Username: ${MSOUSERNAME}"
+echo "Closed Loop Controller Configuration: MSO Password: ${MSOPASSWORD}"
+echo
+echo "Closed Loop Model/PDP-D dependent version(s): ${DEPENDENCIES_VERSION}"
+echo "---------------------------------------------------------------------------------------"
+echo
+
+HAPPY="Y"
+read -e -i "${HAPPY}" -p "Are the previous parameters correct (Y/N)? " HAPPY
+if [[ ${HAPPY} != "Y" ]]; then
+ exit 1
+fi
+
+echo
+DIR_TMP="/tmp"
+echo "The Closed Loop Source Rules will be installed at ${DIR_TMP}"
+read -e -i "${DIR_TMP}" -p "Do you want to change the Source Rules install directory? " DIR_TMP
+
+if [ ! -w "${DIR_TMP}" ]; then
+ echo "Aborting. ${DIR_TMP} is not writable"
+ exit 1
+fi
+
+ARCHETYPE_GROUP_ID="org.openecomp.policy.drools-applications"
+ARCHETYPE_ARTIFACT_ID="archetype-closedloop-demo-rules"
+
+if [ -d "${DIR_TMP}/${ARTIFACTID}/" ]; then
+ if [ "$(ls -A "${DIR_TMP}/${ARTIFACTID}"/)" ]; then
+ echo "${DIR_TMP} already contains a ${ARTIFACTID}/ directory, saving it to ${DIR_TMP}/${ARTIFACTID}.arch.bak/"
+ if [ -d "${DIR_TMP}/${ARTIFACTID}.arch.bak"/ ]; then
+ (
+ echo "${DIR_TMP}/${ARTIFACTID}.arch.bak/ also exists, deleting it .."
+ cd "${DIR_TMP}"/
+ rm -fr "${ARTIFACTID}.arch.bak"
+ )
+ fi
+ /bin/mv --force "${DIR_TMP}/${ARTIFACTID}/" "${DIR_TMP}/${ARTIFACTID}.arch.bak"
+ if [ "${?}" -ne 0 ]; then
+ echo
+ echo
+ echo "Aborting: ${DIR_TMP}/${ARTIFACTID}/ cannot be moved"
+ exit 1
+ fi
+ else
+ ( cd "${DIR_TMP}/" ; rmdir "${DIR_TMP}/${ARTIFACTID}/" )
+ fi
+fi
+
+CREATEARTIFACT="Y"
+read -e -i "${CREATEARTIFACT}" -p "Create Maven Artifact (Y/N)? " CREATEARTIFACT
+if [[ ${CREATEARTIFACT} != "Y" ]]; then
+ exit 1
+fi
+
+(
+cd "${DIR_TMP}"
+
+"$M2_HOME"/bin/mvn archetype:generate \
+ -B \
+ -DarchetypeCatalog=local \
+ -DarchetypeGroupId="${ARCHETYPE_GROUP_ID}" \
+ -DarchetypeArtifactId="${ARCHETYPE_ARTIFACT_ID}" \
+ -DarchetypeVersion="${VERSION}" \
+ -DgroupId="${GROUP_ID}" \
+ -DartifactId="${ARTIFACTID}" \
+ -Dversion="${VERSION}" \
+ -Dpackage="${PACKAGE}" \
+ -DclosedLoopControlName="${CLOSEDLOOPCONTROLNAME}" \
+ -DpolicyScope="${POLICYSCOPE}" \
+ -DpolicyName="${POLICYNAME}" \
+ -DpolicyVersion="${POLICYVERSION}" \
+ -Dactor="${ACTOR}" \
+ -DappcTopic="${APPCTOPIC}" \
+ -DappcServers="${APPCSERVERS}" \
+ -DappcApiKey="${APPCAPIKEY}" \
+ -DappcApiSecret="${APPCAPISECRET}" \
+ -DnotificationTopic="${NOTIFICATIONTOPIC}" \
+ -DnotificationServers="${NOTIFICATIONSERVERS}" \
+ -DnotificationApiKey="${NOTIFICATIONAPIKEY}" \
+ -DnotificationApiSecret="${NOTIFICATIONAPISECRET}" \
+ -DdcaeTopic="${DCAETOPIC}" \
+ -DdcaeServers="${DCAESERVERS}" \
+ -DdcaeApiKey="${DCAEAPIKEY}" \
+ -DdcaeApiSecret="${DCAEAPISECRET}" \
+ -DaaiURL="${AAIURL}" \
+ -DaaiUsername="${AAIUSERNAME}" \
+ -DaaiPassword="${AAIPASSWORD}" \
+ -DaaiNamedQueryUUID="${AAINAMEDQUERYUUID}" \
+ -DaaiPatternMatch="${AAIPATTERNMATCH}" \
+ -DmsoURL="${MSOURL}" \
+ -DmsoUsername="${MSOUSERNAME}" \
+ -DmsoPassword="${MSOPASSWORD}" \
+ -DdependenciesVersion="${DEPENDENCIES_VERSION}"
+
+if [ "${?}" -ne 0 ]; then
+ echo
+ echo
+ echo "Aborting: ${ARTIFACTID} has not been successfully generated"
+ exit 1
+fi
+
+echo
+
+cd "${DIR_TMP}/${ARTIFACTID}"/
+
+/bin/mv src/main/config/* .
+
+/bin/sed -i -e "/apiKey=NULL$/d" *-controller.properties
+/bin/sed -i -e "/apiSecret=NULL$/d" *-controller.properties
+
+/bin/sed -i -e "/apiKey.*:.*\"NULL\",/d" *-controller.rest.json
+/bin/sed -i -e "/apiSecret.*:.*\"NULL\",/d" *-controller.rest.json
+
+echo "Closed Loop Rules from templates have been successfully created under ${DIR_TMP}/${ARTIFACTID}/"
+
+INSTALLREPO="Y"
+read -e -i "${INSTALLREPO}" -p "Do you want to deploy ${ARTIFACTID} rules into maven repository (Y/N)? " INSTALLREPO
+if [[ ${INSTALLREPO} != "Y" ]]; then
+ exit 1
+fi
+
+echo
+echo "generating deployable ${ARTIFACTID} maven artifact .."
+
+"$M2_HOME"/bin/mvn install
+
+if [ "${?}" -ne 0 ]; then
+ echo
+ echo
+ echo "Aborting: ${ARTIFACTID} deployable jar cannot be generated"
+ exit 1
+fi
+
+
+echo
+echo "${ARTIFACTID} has been successfully installed in user's (${USER}) local repository"
+echo "Find configuration files at ${DIR_TMP}/${ARTIFACTID}/"
+)
diff --git a/packages/basex/src/files/config/vDNS-controller.properties b/packages/basex/src/files/config/vDNS-controller.properties
new file mode 100644
index 000000000..951a0f9c4
--- /dev/null
+++ b/packages/basex/src/files/config/vDNS-controller.properties
@@ -0,0 +1,55 @@
+###
+# ============LICENSE_START=======================================================
+# PDP-D APPS Base Package
+# ================================================================================
+# 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=========================================================
+###
+
+controller.name=vDNS
+
+ueb.source.topics=DCAE-CL-EVENT,APPC-CL
+
+ueb.source.topics.DCAE-CL-EVENT.servers=vm1.mr.simpledemo.openecomp.org
+ueb.source.topics.DCAE-CL-EVENT.apiKey=
+ueb.source.topics.DCAE-CL-EVENT.apiSecret=
+ueb.source.topics.DCAE-CL-EVENT.events=org.openecomp.policy.controlloop.VirtualControlLoopEvent
+ueb.source.topics.DCAE-CL-EVENT.events.org.openecomp.policy.controlloop.VirtualControlLoopEvent.filter=closedLoopEventStatus\=.*,closedLoopControlName\=.*DNS.*
+ueb.source.topics.DCAE-CL-EVENT.events.custom.gson=org.openecomp.policy.controlloop.util.Serialization,gsonPretty
+
+ueb.source.topics.APPC-CL.servers=vm1.mr.simpledemo.openecomp.org
+ueb.source.topics.APPC-CL.apiKey=
+ueb.source.topics.APPC-CL.apiSecret=
+ueb.source.topics.APPC-CL.events=org.openecomp.policy.appc.Response
+ueb.source.topics.APPC-CL.events.org.openecomp.policy.appc.Response.filter=CommonHeader=.*,Status=.*
+ueb.source.topics.APPC-CL.events.custom.gson=org.openecomp.policy.appc.util.Serialization,gsonPretty
+
+ueb.sink.topics=APPC-CL,POLICY-CL-MGT
+
+ueb.sink.topics.APPC-CL.servers=vm1.mr.simpledemo.openecomp.org
+ueb.sink.topics.APPC-CL.apiKey=
+ueb.sink.topics.APPC-CL.apiSecret=
+ueb.sink.topics.APPC-CL.events=org.openecomp.policy.appc.Request
+ueb.sink.topics.APPC-CL.events.custom.gson=org.openecomp.policy.appc.util.Serialization,gsonPretty
+
+ueb.sink.topics.POLICY-CL-MGT.servers=vm1.mr.simpledemo.openecomp.org
+ueb.sink.topics.POLICY-CL-MGT.apiKey=
+ueb.sink.topics.POLICY-CL-MGT.apiSecret=
+ueb.sink.topics.POLICY-CL-MGT.events=org.openecomp.policy.controlloop.VirtualControlLoopNotification
+ueb.sink.topics.POLICY-CL-MGT.events.custom.gson=org.openecomp.policy.controlloop.util.Serialization,gsonPretty
+
+rules.groupId=
+rules.artifactId=
+rules.version=
diff --git a/packages/basex/src/files/config/vFW-controller.properties b/packages/basex/src/files/config/vFW-controller.properties
new file mode 100644
index 000000000..558ba42e8
--- /dev/null
+++ b/packages/basex/src/files/config/vFW-controller.properties
@@ -0,0 +1,55 @@
+###
+# ============LICENSE_START=======================================================
+# PDP-D APPS Base Package
+# ================================================================================
+# 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=========================================================
+###
+
+controller.name=vFW
+
+ueb.source.topics=DCAE-CL-EVENT,APPC-CL
+
+ueb.source.topics.DCAE-CL-EVENT.servers=vm1.mr.simpledemo.openecomp.org
+ueb.source.topics.DCAE-CL-EVENT.apiKey=
+ueb.source.topics.DCAE-CL-EVENT.apiSecret=
+ueb.source.topics.DCAE-CL-EVENT.events=org.openecomp.policy.controlloop.VirtualControlLoopEvent
+ueb.source.topics.DCAE-CL-EVENT.events.org.openecomp.policy.controlloop.VirtualControlLoopEvent.filter=closedLoopEventStatus\=.*,closedLoopControlName\=.*FRWL.*
+ueb.source.topics.DCAE-CL-EVENT.events.custom.gson=org.openecomp.policy.controlloop.util.Serialization,gsonPretty
+
+ueb.source.topics.APPC-CL.servers=vm1.mr.simpledemo.openecomp.org
+ueb.source.topics.APPC-CL.apiKey=
+ueb.source.topics.APPC-CL.apiSecret=
+ueb.source.topics.APPC-CL.events=org.openecomp.policy.appc.Response
+ueb.source.topics.APPC-CL.events.org.openecomp.policy.appc.Response.filter=CommonHeader=.*,Status=.*
+ueb.source.topics.APPC-CL.events.custom.gson=org.openecomp.policy.appc.util.Serialization,gsonPretty
+
+ueb.sink.topics=APPC-CL,POLICY-CL-MGT
+
+ueb.sink.topics.APPC-CL.servers=vm1.mr.simpledemo.openecomp.org
+ueb.sink.topics.APPC-CL.apiKey=
+ueb.sink.topics.APPC-CL.apiSecret=
+ueb.sink.topics.APPC-CL.events=org.openecomp.policy.appc.Request
+ueb.sink.topics.APPC-CL.events.custom.gson=org.openecomp.policy.appc.util.Serialization,gsonPretty
+
+ueb.sink.topics.POLICY-CL-MGT.servers=vm1.mr.simpledemo.openecomp.org
+ueb.sink.topics.POLICY-CL-MGT.apiKey=
+ueb.sink.topics.POLICY-CL-MGT.apiSecret=
+ueb.sink.topics.POLICY-CL-MGT.events=org.openecomp.policy.controlloop.VirtualControlLoopNotification
+ueb.sink.topics.POLICY-CL-MGT.events.custom.gson=org.openecomp.policy.controlloop.util.Serialization,gsonPretty
+
+rules.groupId=
+rules.artifactId=
+rules.version=
diff --git a/packages/pom.xml b/packages/pom.xml
new file mode 100644
index 000000000..650743ce2
--- /dev/null
+++ b/packages/pom.xml
@@ -0,0 +1,43 @@
+<!--
+ ============LICENSE_START=======================================================
+ Drools PDP Application Models
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>packages</artifactId>
+ <packaging>pom</packaging>
+
+ <name>PDP-D Application Installation Packages</name>
+ <description>PDP-D Installation</description>
+
+ <modules>
+ <module>basex</module>
+ <module>artifacts</module>
+ <module>apps</module>
+ </modules>
+</project>
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 000000000..06daacde8
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,167 @@
+<!--
+ ============LICENSE_START=======================================================
+ drools-pdp-apps
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <name>Drools PDP Application Models</name>
+ <packaging>pom</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <!--
+
+ license plugin
+
+ Run
+
+ mvn clean
+
+ before running from the command line
+
+ mvn license:update-file-header
+
+ -->
+
+ <plugin>
+
+ <groupId>org.codehaus.mojo</groupId>
+
+ <artifactId>license-maven-plugin</artifactId>
+
+ <version>1.9</version>
+
+ <configuration>
+
+ <extraExtensions>
+
+ <!-- Used to add or change the header style <fileTypeYouAreMapping>
+
+ fileTypeMappedInto </fileTypeYouAreMapping> -->
+
+ <!-- Since it appears that comments in .json files are, at best,
+ iffy, you should remove the license headers from those files or
+ you can list each individual file to be ignored in the ignore
+ section below -->
+
+ <drl>java</drl>
+
+ <ccf>properties</ccf>
+
+
+
+ <!-- Because the typical sql comment type confuses the update algorithm -->
+
+ <sql>java</sql>
+
+ <!-- yaml files are generated, but some are included -->
+
+ <yaml>properties</yaml>
+
+ </extraExtensions>
+
+ <licenseName>apache_v2</licenseName>
+
+
+
+ <inceptionYear>2017</inceptionYear>
+
+ <organizationName>AT&amp;T Intellectual Property. All rights reserved.</organizationName>
+
+
+
+ <!-- Once you have established the tags and delimiter, they cannot be
+
+ changed -->
+
+ <processStartTag>============LICENSE_START=======================================================</processStartTag>
+
+ <processEndTag>============LICENSE_END=========================================================</processEndTag>
+
+ <sectionDelimiter>================================================================================</sectionDelimiter>
+
+ <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
+
+ <canUpdateCopyright>true</canUpdateCopyright>
+
+ <canUpdateDescription>true</canUpdateDescription>
+
+ <canUpdateLicense>true</canUpdateLicense>
+
+ <emptyLineAfterHeader>true</emptyLineAfterHeader>
+
+ <roots>
+
+ <!-- Default is src, target/generated-sources, target/processed-sources -->
+
+
+
+ <!-- Everything except the files in the excludes section -->
+
+ <root>/</root>
+
+ </roots>
+
+ <excludes>
+
+ <!-- Files which are to be excluded. The pom.xml is excluded because
+
+ the start/end tags and the delimiters are in the body of the file. This confuses
+
+ the algorithm. So, this file must be manually updated with a license header. -->
+
+ <exclude>pom.xml</exclude>
+
+ </excludes>
+
+ </configuration>
+
+ </plugin>
+ </plugins>
+ </build>
+
+ <modules>
+ <module>rest</module>
+ <module>aai</module>
+ <module>appc</module>
+ <module>controlloop</module>
+ <module>mso</module>
+ <module>sdnc</module>
+ <module>trafficgenerator</module>
+ <module>template.demo</module>
+ <module>vfwsim</module>
+ <module>archetype-closedloop-demo-rules</module>
+ <module>packages</module>
+ </modules>
+</project>
diff --git a/rest/pom.xml b/rest/pom.xml
new file mode 100644
index 000000000..4098ce9a0
--- /dev/null
+++ b/rest/pom.xml
@@ -0,0 +1,52 @@
+<!--
+ ============LICENSE_START=======================================================
+ Drools PDP Application Models
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>rest</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.2</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/rest/src/main/java/org/openecomp/policy/rest/RESTManager.java b/rest/src/main/java/org/openecomp/policy/rest/RESTManager.java
new file mode 100644
index 000000000..1044749cc
--- /dev/null
+++ b/rest/src/main/java/org/openecomp/policy/rest/RESTManager.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * rest
+ * ================================================================================
+ * 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.openecomp.policy.rest;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
+
+public final class RESTManager {
+
+ public static class Pair<A, B> {
+ public final A a;
+ public final B b;
+
+ public Pair(A a, B b) {
+ this.a = a;
+ this.b = b;
+ }
+ }
+
+ public static Pair<Integer, String> post(String url, String username, String password, Map<String, String> headers, String contentType, String body) {
+ CredentialsProvider credentials = new BasicCredentialsProvider();
+ credentials.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
+
+ System.out.println("HTTP REQUEST: " + url + " -> " + username + ((password!=null)?password.length():"-") + " -> " + contentType);
+ if (headers != null) {
+ System.out.println("Headers: ");
+ headers.forEach((name, value) -> {
+ System.out.println(name + " -> " + value);
+ });
+ }
+ System.out.println(body);
+
+ try (CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) {
+
+ HttpPost post = new HttpPost(url);
+ for (String key : headers.keySet()) {
+ post.addHeader(key, headers.get(key));
+ }
+ post.addHeader("Content-Type", contentType);
+
+ StringEntity input = new StringEntity(body);
+ input.setContentType(contentType);
+ post.setEntity(input);
+
+ HttpResponse response = client.execute(post);
+
+ String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
+ System.out.println("HTTP POST Response Status Code: " + response.getStatusLine().getStatusCode());
+ System.out.println("HTTP POST Response Body:");
+ System.out.println(returnBody);
+
+ return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
+ } catch (IOException e) {
+ System.err.println("Failed to POST to " + url + e.getLocalizedMessage());
+ return null;
+ }
+
+ }
+
+ public static Pair<Integer, String> get(String url, String username, String password, Map<String, String> headers) {
+
+ CredentialsProvider credentials = new BasicCredentialsProvider();
+ credentials.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
+
+ try (CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) {
+
+ HttpGet get = new HttpGet(url);
+ for (String key : headers.keySet()) {
+ get.addHeader(key, headers.get(key));
+ }
+
+ HttpResponse response = client.execute(get);
+
+ String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
+ System.out.println("HTTP GET Response Status Code: " + response.getStatusLine().getStatusCode());
+ System.out.println("HTTP GET Response Body:");
+ System.out.println(returnBody);
+
+ return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
+ } catch (IOException e) {
+ System.err.println("Failed to GET to " + url + e.getLocalizedMessage());
+ return null;
+ }
+ }
+}
diff --git a/sdnc/pom.xml b/sdnc/pom.xml
new file mode 100644
index 000000000..63ad320f6
--- /dev/null
+++ b/sdnc/pom.xml
@@ -0,0 +1,51 @@
+<!--
+ ============LICENSE_START=======================================================
+ Drools PDP Application Models
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>sdnc</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>rest</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequest.java b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequest.java
new file mode 100644
index 000000000..fe1588a5b
--- /dev/null
+++ b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdnc
+ * ================================================================================
+ * 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.openecomp.policy.sdnc;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class SDNCRequest implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("input")
+ public SDNCRequestInput input;
+
+
+
+ public SDNCRequest() {
+ }
+
+}
diff --git a/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequestHeader.java b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequestHeader.java
new file mode 100644
index 000000000..84c3f3cdc
--- /dev/null
+++ b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequestHeader.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdnc
+ * ================================================================================
+ * 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.openecomp.policy.sdnc;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class SDNCRequestHeader implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("svc-request-id")
+ public String svcRequestId;
+
+ @SerializedName("svc-notification-url")
+ public String svcNotificationUrl;
+
+ @SerializedName("svc-action")
+ public String svcAction;
+
+
+ public SDNCRequestHeader() {
+ }
+
+}
diff --git a/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequestInformation.java b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequestInformation.java
new file mode 100644
index 000000000..b895b4afe
--- /dev/null
+++ b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequestInformation.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdnc
+ * ================================================================================
+ * 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.openecomp.policy.sdnc;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class SDNCRequestInformation implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("request-id")
+ public String requestId;
+
+ @SerializedName("order-version")
+ public String orderVersion;
+
+ @SerializedName("notification-url")
+ public String notificationUrl;
+
+ @SerializedName("order-number")
+ public String orderNumber;
+
+ @SerializedName("request-action")
+ public String requestAction;
+
+ public SDNCRequestInformation() {
+ }
+
+}
diff --git a/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequestInput.java b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequestInput.java
new file mode 100644
index 000000000..cecd0a268
--- /dev/null
+++ b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCRequestInput.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdnc
+ * ================================================================================
+ * 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.openecomp.policy.sdnc;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class SDNCRequestInput implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("vnf-topology-information")
+ public SDNCVnfTopologyInformation vnfTopolgyInformation;
+
+ @SerializedName("request-information")
+ public SDNCRequestInformation requestInformation;
+
+ @SerializedName("sdnc-request-header")
+ public SDNCRequestHeader requestHeader;
+
+ public SDNCRequestInput() {
+ }
+
+}
diff --git a/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCVnfAssignments.java b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCVnfAssignments.java
new file mode 100644
index 000000000..8a32c2121
--- /dev/null
+++ b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCVnfAssignments.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdnc
+ * ================================================================================
+ * 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.openecomp.policy.sdnc;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.google.gson.annotations.SerializedName;
+
+public class SDNCVnfAssignments implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+
+ @SerializedName("availability-zones")
+ public List<String> availabilityZones = new LinkedList<String>();
+
+
+ @SerializedName("vnf-networks")
+ public List<String> vnfNetworks = new LinkedList<String>();
+
+ @SerializedName("vnf-vms")
+ public List<String> vnfVms = new LinkedList<String>();
+
+ public SDNCVnfAssignments() {
+ }
+
+}
diff --git a/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCVnfTopologyIdentifier.java b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCVnfTopologyIdentifier.java
new file mode 100644
index 000000000..5b31bd1b2
--- /dev/null
+++ b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCVnfTopologyIdentifier.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdnc
+ * ================================================================================
+ * 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.openecomp.policy.sdnc;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class SDNCVnfTopologyIdentifier implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("service-type")
+ public String serviceType;
+
+ @SerializedName("vnf-name")
+ public String vnfName;
+
+ @SerializedName("vnf-type")
+ public String vnfType;
+
+ @SerializedName("generic-vnf-name")
+ public String genericVnfName;
+
+ @SerializedName("generic-vnf-type")
+ public String genericVnfType;
+
+
+ public SDNCVnfTopologyIdentifier() {
+ }
+
+}
diff --git a/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCVnfTopologyInformation.java b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCVnfTopologyInformation.java
new file mode 100644
index 000000000..5b3ae2685
--- /dev/null
+++ b/sdnc/src/main/java/org/openecomp/policy/sdnc/SDNCVnfTopologyInformation.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdnc
+ * ================================================================================
+ * 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.openecomp.policy.sdnc;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import com.google.gson.annotations.SerializedName;
+
+public class SDNCVnfTopologyInformation implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("vnf-topology-identifier")
+ public SDNCVnfTopologyIdentifier vnfTopologyIdentifier;
+
+ @SerializedName("vnf-assignments")
+ public SDNCVnfAssignments vnfAssignments;
+
+ @SerializedName("vnf-parameters")
+ public List<Map<String,String>> vnfParameters = new LinkedList<Map<String,String>>();
+
+ public SDNCVnfTopologyInformation() {
+ }
+
+}
diff --git a/sdnc/src/main/java/org/openecomp/policy/sdnc/util/Serialization.java b/sdnc/src/main/java/org/openecomp/policy/sdnc/util/Serialization.java
new file mode 100644
index 000000000..4cc2fb586
--- /dev/null
+++ b/sdnc/src/main/java/org/openecomp/policy/sdnc/util/Serialization.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdnc
+ * ================================================================================
+ * 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.openecomp.policy.sdnc.util;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public final class Serialization {
+
+ final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
+ .setPrettyPrinting()
+ .create();
+
+}
diff --git a/sdnc/src/test/java/org/openecomp/policy/sdnc/TestDemo.java b/sdnc/src/test/java/org/openecomp/policy/sdnc/TestDemo.java
new file mode 100644
index 000000000..4a616fbfb
--- /dev/null
+++ b/sdnc/src/test/java/org/openecomp/policy/sdnc/TestDemo.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdnc
+ * ================================================================================
+ * 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.openecomp.policy.sdnc;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.openecomp.policy.sdnc.SDNCRequest;
+import org.openecomp.policy.sdnc.util.Serialization;
+
+public class TestDemo {
+
+ @Test
+ public void test() {
+
+ SDNCRequest request = new SDNCRequest();
+ request.input = new SDNCRequestInput();
+ request.input.requestHeader = new SDNCRequestHeader();
+ request.input.vnfTopolgyInformation = new SDNCVnfTopologyInformation();
+ request.input.vnfTopolgyInformation.vnfTopologyIdentifier = new SDNCVnfTopologyIdentifier();
+ request.input.vnfTopolgyInformation.vnfAssignments = new SDNCVnfAssignments();
+ request.input.requestInformation = new SDNCRequestInformation();
+
+ request.input.vnfTopolgyInformation.vnfTopologyIdentifier.serviceType = "my_serviceType";
+ request.input.vnfTopolgyInformation.vnfTopologyIdentifier.vnfName = "my_vnfName";
+ request.input.vnfTopolgyInformation.vnfTopologyIdentifier.vnfType = "my_vnfType";
+ request.input.vnfTopolgyInformation.vnfTopologyIdentifier.genericVnfName = "my_genericVnfName";
+ request.input.vnfTopolgyInformation.vnfTopologyIdentifier.genericVnfType = "my_genericVnfType";
+
+ request.input.vnfTopolgyInformation.vnfAssignments.availabilityZones.add("zone1");
+ request.input.vnfTopolgyInformation.vnfAssignments.availabilityZones.add("zone2");
+ request.input.vnfTopolgyInformation.vnfAssignments.vnfNetworks.add("network1");
+ request.input.vnfTopolgyInformation.vnfAssignments.vnfNetworks.add("network2");
+ request.input.vnfTopolgyInformation.vnfAssignments.vnfVms.add("vnfVm1");
+ request.input.vnfTopolgyInformation.vnfAssignments.vnfVms.add("vnfVm2");
+
+ Map<String, String> vnfParams1 = new HashMap<String, String>();
+ vnfParams1.put("name1", "value1");
+ request.input.vnfTopolgyInformation.vnfParameters.add(vnfParams1);
+
+ Map<String, String> vnfParams2 = new HashMap<String, String>();
+ vnfParams2.put("name2", "value2");
+ request.input.vnfTopolgyInformation.vnfParameters.add(vnfParams2);
+
+
+ request.input.requestInformation.requestId = "ff5256d1-5a33-55df-13ab-12abad84e7ff";
+ request.input.requestInformation.orderNumber = "1";
+ request.input.requestInformation.orderVersion = "1";
+ request.input.requestInformation.notificationUrl = "sdnc.myDomain.com";
+ request.input.requestInformation.requestAction = "PreloadVNFRequest";
+
+ request.input.requestHeader.svcRequestId = "ff5256d1-5a33-55df-13ab-12abad84e7ff";
+ request.input.requestHeader.svcNotificationUrl = "some_url.myDomain.com:8080";
+ request.input.requestHeader.svcAction = "reserve";
+
+ String body = Serialization.gsonPretty.toJson(request);
+ System.out.println(body);
+
+
+
+ }
+
+}
diff --git a/template.demo/pom.xml b/template.demo/pom.xml
new file mode 100644
index 000000000..9bd5f338f
--- /dev/null
+++ b/template.demo/pom.xml
@@ -0,0 +1,94 @@
+<!--
+ ============LICENSE_START=======================================================
+ Drools PDP Application Models
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>demo</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ <version>6.3.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
+ <version>6.3.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>controlloop</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>appc</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>aai</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>mso</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>trafficgenerator</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/template.demo/src/main/java/org/openecomp/policy/template/demo/ControlLoopException.java b/template.demo/src/main/java/org/openecomp/policy/template/demo/ControlLoopException.java
new file mode 100644
index 000000000..5956d6017
--- /dev/null
+++ b/template.demo/src/main/java/org/openecomp/policy/template/demo/ControlLoopException.java
@@ -0,0 +1,51 @@
+/*-
+ * ============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.openecomp.policy.template.demo;
+
+public class ControlLoopException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6400725747325923701L;
+
+ public ControlLoopException() {
+ super();
+ }
+
+ public ControlLoopException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+
+ public ControlLoopException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ControlLoopException(String message) {
+ super(message);
+ }
+
+ public ControlLoopException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/template.demo/src/main/java/org/openecomp/policy/template/demo/EventManager.java b/template.demo/src/main/java/org/openecomp/policy/template/demo/EventManager.java
new file mode 100644
index 000000000..c54ea607a
--- /dev/null
+++ b/template.demo/src/main/java/org/openecomp/policy/template/demo/EventManager.java
@@ -0,0 +1,210 @@
+/*-
+ * ============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.openecomp.policy.template.demo;
+
+import java.util.UUID;
+
+import org.openecomp.policy.controlloop.VirtualControlLoopEvent;
+import org.openecomp.policy.controlloop.VirtualControlLoopNotification;
+import org.openecomp.policy.template.demo.ControlLoopException;
+import org.openecomp.policy.controlloop.ControlLoopNotificationType;
+import org.openecomp.policy.controlloop.ControlLoopEventStatus;
+
+public class EventManager {
+ /*
+ *
+ */
+ public final String closedLoopControlName;
+ public final UUID requestID;
+ public final String target;
+ public String controlLoopResult;
+
+ private boolean isActivated = false;
+ private VirtualControlLoopEvent onset;
+ private VirtualControlLoopEvent abatement;
+ private Integer numOnsets = 0;
+ private Integer numAbatements = 0;
+
+
+
+ public EventManager(String closedLoopControlName, UUID requestID, String target) {
+ this.closedLoopControlName = closedLoopControlName;
+ this.requestID = requestID;
+ this.target = target;
+ }
+
+ public Integer getNumOnsets() {
+ return numOnsets;
+ }
+
+ public void setNumOnsets(Integer numOnsets) {
+ this.numOnsets = numOnsets;
+ }
+
+ public Integer getNumAbatements() {
+ return numAbatements;
+ }
+
+ public void setNumAbatements(Integer numAbatements) {
+ this.numAbatements = numAbatements;
+ }
+
+ public boolean isActivated() {
+ return isActivated;
+ }
+
+ public void setActivated(boolean isActivated) {
+ this.isActivated = isActivated;
+ }
+
+ public VirtualControlLoopEvent getOnsetEvent() {
+ return this.onset;
+ }
+
+ public VirtualControlLoopEvent getAbatementEvent() {
+ return this.abatement;
+ }
+
+ public void setControlLoopResult(String result) {
+ this.controlLoopResult = result;
+ }
+
+ public VirtualControlLoopNotification activate(VirtualControlLoopEvent event) {
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification(event);
+ try {
+ //
+ // This method should ONLY be called ONCE
+ //
+ if (this.isActivated) {
+ throw new ControlLoopException("ControlLoopEventManager has already been activated.");
+ }
+ //
+ // Syntax check the event
+ //
+ checkEventSyntax(event);
+ //
+ // At this point we are good to go with this event
+ //
+ this.onset = event;
+ this.numOnsets = 1;
+ //
+ notification.notification = ControlLoopNotificationType.ACTIVE;
+ //
+ // Set ourselves as active
+ //
+ this.isActivated = true;
+ } catch (ControlLoopException e) {
+ notification.notification = ControlLoopNotificationType.REJECTED;
+ notification.message = e.getMessage();
+ }
+ return notification;
+
+ }
+
+ public static void checkEventSyntax(VirtualControlLoopEvent event) throws ControlLoopException {
+ if (event.closedLoopEventStatus == null ||
+ (event.closedLoopEventStatus != ControlLoopEventStatus.ONSET &&
+ event.closedLoopEventStatus != ControlLoopEventStatus.ABATED)) {
+ throw new ControlLoopException("Invalid value in closedLoopEventStatus");
+ }
+ if (event.closedLoopControlName == null || event.closedLoopControlName.length() < 1) {
+ throw new ControlLoopException("No control loop name");
+ }
+ if (event.requestID == null) {
+ throw new ControlLoopException("No request ID");
+ }
+ if (event.AAI == null) {
+ throw new ControlLoopException("AAI is null");
+ }
+ if (event.target == null || event.target.length() < 1) {
+ throw new ControlLoopException("No target field");
+ } else {
+ if (! event.target.equalsIgnoreCase("VM_NAME") &&
+ ! event.target.equalsIgnoreCase("VNF_NAME") &&
+ ! event.target.equalsIgnoreCase("vserver.vserver-name") &&
+ ! event.target.equalsIgnoreCase("generic-vnf.vnf-id") ) {
+ throw new ControlLoopException("target field invalid");
+ }
+ }
+ }
+
+ public enum NEW_EVENT_STATUS {
+ FIRST_ONSET,
+ SUBSEQUENT_ONSET,
+ FIRST_ABATEMENT,
+ SUBSEQUENT_ABATEMENT,
+ SYNTAX_ERROR
+ ;
+ }
+
+ public NEW_EVENT_STATUS onNewEvent(VirtualControlLoopEvent event) {
+ try {
+ EventManager.checkEventSyntax(event);
+ if (event.closedLoopEventStatus == ControlLoopEventStatus.ONSET) {
+ //
+ // Check if this is our original ONSET
+ //
+ if (event.equals(this.onset)) {
+ //
+ // DO NOT retract it
+ //
+ return NEW_EVENT_STATUS.FIRST_ONSET;
+ }
+ //
+ // Log that we got an onset
+ //
+ this.numOnsets++;
+ return NEW_EVENT_STATUS.SUBSEQUENT_ONSET;
+ } else if (event.closedLoopEventStatus == ControlLoopEventStatus.ABATED) {
+ //
+ // Have we already got an abatement?
+ //
+ if (this.abatement == null) {
+ //
+ // Save this
+ //
+ this.abatement = event;
+ //
+ // Keep track that we received another
+ //
+ this.numAbatements++;
+ //
+ //
+ //
+ return NEW_EVENT_STATUS.FIRST_ABATEMENT;
+ } else {
+ //
+ // Keep track that we received another
+ //
+ this.numAbatements++;
+ //
+ //
+ //
+ return NEW_EVENT_STATUS.SUBSEQUENT_ABATEMENT;
+ }
+ } else {
+ return NEW_EVENT_STATUS.SYNTAX_ERROR;
+ }
+ } catch (ControlLoopException e) {
+ return NEW_EVENT_STATUS.SYNTAX_ERROR;
+ }
+ }
+}
diff --git a/template.demo/src/main/java/org/openecomp/policy/template/demo/PolicyEngine.java b/template.demo/src/main/java/org/openecomp/policy/template/demo/PolicyEngine.java
new file mode 100644
index 000000000..4daf89750
--- /dev/null
+++ b/template.demo/src/main/java/org/openecomp/policy/template/demo/PolicyEngine.java
@@ -0,0 +1,81 @@
+/*-
+ * ============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.openecomp.policy.template.demo;
+
+ import java.util.HashMap;
+ import java.util.LinkedList;
+ import java.util.Map;
+ import java.util.Queue;
+
+ import org.openecomp.policy.controlloop.VirtualControlLoopNotification;
+ import org.openecomp.policy.appc.Request;
+ import org.openecomp.policy.controlloop.util.Serialization;
+
+
+ public class PolicyEngine {
+
+ private static Map<String, Map<String, Queue<Object>>> busMap = new HashMap<String, Map<String, Queue<Object>>>();
+
+ public PolicyEngine() {}
+
+ public boolean deliver(String busType, String topic, Object obj) {
+ if (obj instanceof VirtualControlLoopNotification) {
+ VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj;
+ System.out.println("Notification to be sent:");
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ }
+ if (obj instanceof Request) {
+ Request request = (Request) obj;
+ System.out.println("APPC request to be sent:");
+ System.out.println("Request: " + request.Action + " RequestID: " + request.CommonHeader.RequestID + " Payload: " + request.Payload);
+ }
+ //
+ // Does the bus exist?
+ //
+ if (busMap.containsKey(busType) == false) {
+ System.out.println("creating new bus type " + busType);
+ //
+ // Create the bus
+ //
+ busMap.put(busType, new HashMap<String, Queue<Object>>());
+ }
+ //
+ // Get the bus
+ //
+ Map<String, Queue<Object>> topicMap = busMap.get(busType);
+ //
+ // Does the topic exist?
+ //
+ if (topicMap.containsKey(topic) == false) {
+ System.out.println("creating new topic " + topic);
+ //
+ // Create the topic
+ //
+ topicMap.put(topic, new LinkedList<Object>());
+ }
+ //
+ // Get the topic queue
+ //
+ System.out.println("queueing");
+ return topicMap.get(topic).add(obj);
+
+ }
+ }
diff --git a/template.demo/src/main/resources/archetype-resources/src/main/resources/ControlLoopDemo__closedLoopControlName__.drl b/template.demo/src/main/resources/archetype-resources/src/main/resources/ControlLoopDemo__closedLoopControlName__.drl
new file mode 100644
index 000000000..ae02a2c51
--- /dev/null
+++ b/template.demo/src/main/resources/archetype-resources/src/main/resources/ControlLoopDemo__closedLoopControlName__.drl
@@ -0,0 +1,1270 @@
+/*-
+ * ============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.openecomp.policy.controlloop;
+
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.UUID;
+
+import org.openecomp.policy.controlloop.VirtualControlLoopEvent;
+import org.openecomp.policy.controlloop.ControlLoopEventStatus;
+import org.openecomp.policy.controlloop.VirtualControlLoopNotification;
+import org.openecomp.policy.controlloop.ControlLoopNotificationType;
+import org.openecomp.policy.controlloop.ControlLoopOperation;
+import org.openecomp.policy.controlloop.ControlLoopOperationWrapper;
+import org.openecomp.policy.template.demo.ControlLoopException;
+
+import org.openecomp.policy.aai.AAINQF199.AAINQF199CloudRegion;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperties;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperty;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199GenericVNF;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InstanceFilters;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Manager;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199NamedQuery;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199QueryParameters;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Request;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199RequestWrapper;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Response;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ResponseWrapper;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ServiceInstance;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Tenant;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199VfModule;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199VServer;
+import org.openecomp.policy.aai.util.Serialization;
+
+import org.openecomp.policy.appc.CommonHeader;
+import org.openecomp.policy.appc.Request;
+import org.openecomp.policy.appc.Response;
+import org.openecomp.policy.appc.ResponseCode;
+import org.openecomp.policy.appc.ResponseStatus;
+import org.openecomp.policy.appc.ResponseValue;
+
+import org.openecomp.policy.template.demo.EventManager;
+import org.openecomp.policy.vnf.trafficgenerator.PGRequest;
+import org.openecomp.policy.vnf.trafficgenerator.PGStream;
+import org.openecomp.policy.vnf.trafficgenerator.PGStreams;
+
+import org.openecomp.policy.mso.MSOManager;
+import org.openecomp.policy.mso.MSORequest;
+import org.openecomp.policy.mso.MSORequestStatus;
+import org.openecomp.policy.mso.MSORequestDetails;
+import org.openecomp.policy.mso.MSOModelInfo;
+import org.openecomp.policy.mso.MSOCloudConfiguration;
+import org.openecomp.policy.mso.MSORequestInfo;
+import org.openecomp.policy.mso.MSORequestParameters;
+import org.openecomp.policy.mso.MSORelatedInstanceListElement;
+import org.openecomp.policy.mso.MSORelatedInstance;
+import org.openecomp.policy.mso.MSOResponse;
+
+//import org.openecomp.policy.drools.system.PolicyEngine;
+
+//
+// These parameters are required to build the runtime policy
+//
+declare Params
+ closedLoopControlName : String
+ actor : String
+ aaiURL : String
+ aaiUsername : String
+ aaiPassword : String
+ msoURL : String
+ msoUsername : String
+ msoPassword : String
+ aaiNamedQueryUUID : String
+ aaiPatternMatch : int
+ notificationTopic : String
+ appcTopic : String
+end
+
+/*
+*
+* Called once and only once to insert the parameters into working memory for this Closed Loop policy.
+* (Comment SETUP rule out for the first ECOMP opensource release since policy BRMS_GW already puts a Params fact in there)
+*
+*/
+rule "${policyName}.SETUP"
+ when
+ then
+ System.out.println("rule SETUP is triggered.");
+ Params params = new Params();
+ params.setClosedLoopControlName("${closedLoopControlName}");
+ params.setActor("${actor}");
+ params.setAaiURL("${aaiURL}");
+ params.setAaiUsername("${aaiUsername}");
+ params.setAaiPassword("${aaiPassword}");
+ params.setMsoURL("${msoURL}");
+ params.setMsoUsername("${msoUsername}");
+ params.setMsoPassword("${msoPassword}");
+ params.setAaiNamedQueryUUID("${aaiNamedQueryUUID}");
+ params.setAaiPatternMatch(${aaiPatternMatch});
+ params.setNotificationTopic("${notificationTopic}");
+ params.setAppcTopic("${appcTopic}");
+ //
+ // This stays in memory as long as the rule is alive and running
+ //
+ insert(params);
+end
+
+/*
+*
+* This rule responds to DCAE Events
+*
+*/
+rule "${policyName}.EVENT"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ not ( EventManager( closedLoopControlName == $event.closedLoopControlName ))
+ then
+ System.out.println("rule EVENT is triggered.");
+ try {
+ //
+ // Check the requestID in the event to make sure it is not null before we create the EventManager.
+ // The EventManager will do extra syntax checking as well check if the closed loop is disabled/
+ //
+ if ($event.requestID == null) {
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.REJECTED;
+ notification.from = "policy";
+ notification.message = "Missing requestID from DCAE event";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver notification: " + notification);
+ }
+ //
+ // Retract it from memory
+ //
+ retract($event);
+ System.out.println("Event with requestID=null has been retracted.");
+ } else {
+ //
+ // Create an EventManager
+ //
+ EventManager manager = new EventManager($params.getClosedLoopControlName(), $event.requestID, $event.target);
+ //
+ // Determine if EventManager can actively process the event (i.e. syntax)
+ //
+ VirtualControlLoopNotification notification = manager.activate($event);
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ //
+ // Are we actively pursuing this event?
+ //
+ if (notification.notification == ControlLoopNotificationType.ACTIVE) {
+ //
+ // Insert Event Manager into memory, this will now kick off processing.
+ //
+ insert(manager);
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver notification: " + notification);
+ }
+ } else {
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver notification: " + notification);
+ }
+ //
+ // Retract it from memory
+ //
+ retract($event);
+ }
+ //
+ // Now that the manager is inserted into Drools working memory, we'll wait for
+ // another rule to fire in order to continue processing. This way we can also
+ // then screen for additional ONSET and ABATED events for this same RequestIDs
+ // and for different RequestIDs but with the same closedLoopControlName and target.
+ //
+ }
+ //
+ } catch (Exception e) {
+ e.printStackTrace();
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.REJECTED;
+ notification.message = "Exception occurred " + e.getMessage();
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ //
+ //
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e1) {
+ System.out.println("Can't deliver notification: " + notification);
+ e1.printStackTrace();
+ }
+ //
+ // Retract the event
+ //
+ retract($event);
+ }
+end
+
+/*
+*
+* This rule happens when we got a valid ONSET, closed loop is enabled and an Event Manager
+* is created. We can start the operations for this closed loop.
+*
+*/
+rule "${policyName}.EVENT.MANAGER"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName, controlLoopResult == null)
+ then
+ System.out.println("rule EVENT.MANAGER is triggered.");
+ //
+ // Check which event this is.
+ //
+ EventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);
+ //
+ // We only want the initial ONSET event in memory,
+ // all the other events need to be retracted to support
+ // cleanup and avoid the other rules being fired for this event.
+ //
+ if (eventStatus != EventManager.NEW_EVENT_STATUS.FIRST_ONSET) {
+ System.out.println("Retracting "+eventStatus+" Event.");
+ retract($event);
+ return;
+ }
+ //
+ // Now the event in memory is first onset event
+ //
+ try {
+ //
+ // Pull the known AAI field from the Event
+ //
+ // generic-vnf is needed for vFirewall case
+ // vserver-name is needed for vLoadBalancer case
+ //
+ String genericVNF = $event.AAI.get("generic-vnf.vnf-id");
+ String vserver = $event.AAI.get("vserver.vserver-name");
+ //
+ // Check if we are implementing a simple pattern match.
+ //
+ if ($params.getAaiPatternMatch() == 1) {
+ //
+ // Yes
+ //
+ //Basic naming characteristics:
+ //VF Name (9 char)+VM name (13 char total)+VFC (19 char total)
+ //Example:
+ //VF Name (9 characters): cscf0001v
+ //VM Name(13 characters): cscf0001vm001
+ //VFC name(19 characters): cscf0001vm001cfg001
+ //
+ // zdfw1fwl01fwl02 or zdfw1fwl01fwl01
+ // replaced with
+ // zdfw1fwl01pgn02 or zdfw1fwl01pgn01
+ //
+ int index = genericVNF.lastIndexOf("fwl");
+ if (index == -1) {
+ System.err.println("The generic-vnf.vnf-id from DCAE Event is not valid.");
+ } else {
+ genericVNF = genericVNF.substring(0, index) + "pgn" + genericVNF.substring(index+"fwl".length());
+ }
+ //
+ // Construct an APPC request
+ //
+ ControlLoopOperation operation = new ControlLoopOperation();
+ operation.actor = $params.getActor();
+ operation.operation = "ModifyConfig";
+ operation.target = $event.target;
+ //
+ // Create operationWrapper
+ //
+ ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+ //
+ // insert operationWrapper into memory
+ //
+ insert(operationWrapper);
+ //
+ Request request = new Request();
+ request.CommonHeader = new CommonHeader();
+ request.CommonHeader.RequestID = $event.requestID;
+ request.Action = operation.operation;
+ request.Payload = new HashMap<String, Object>();
+ //
+ // Fill in the payload
+ //
+ request.Payload.put("generic-vnf.vnf-id", genericVNF);
+ //
+ PGRequest pgRequest = new PGRequest();
+ pgRequest.pgStreams = new PGStreams();
+
+ PGStream pgStream;
+ for(int i = 0; i < 5; i++){
+ pgStream = new PGStream();
+ pgStream.streamId = "fw_udp"+(i+1);
+ pgStream.isEnabled = "true";
+ pgRequest.pgStreams.pgStream.add(pgStream);
+ }
+ request.Payload.put("pg-streams", pgRequest.pgStreams);
+
+ if (request != null) {
+ //
+ // Insert request into memory
+ //
+ insert(request);
+ //
+ // Tell interested parties we are performing this Operation
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.OPERATION;
+ // message and history ??
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // Now send the operation request
+ //
+ if (request instanceof Request) {
+ try {
+ System.out.println("APPC request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(request));
+ //PolicyEngine.manager.deliver($params.getAppcTopic(), request);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver request: " + request);
+ }
+ }
+ } else {
+ //
+ // what happens if it is null
+ //
+ }
+ //
+ } else {
+ //
+ // create AAI named-query request with UUID started with "F199"
+ //
+ AAINQF199Request aainqf199request = new AAINQF199Request();
+ AAINQF199QueryParameters aainqf199queryparam = new AAINQF199QueryParameters();
+ AAINQF199NamedQuery aainqf199namedquery = new AAINQF199NamedQuery();
+ AAINQF199InstanceFilters aainqf199instancefilter = new AAINQF199InstanceFilters();
+ //
+ // queryParameters
+ //
+ aainqf199namedquery.namedQueryUUID = UUID.fromString($params.getAaiNamedQueryUUID());
+ aainqf199queryparam.namedQuery = aainqf199namedquery;
+ aainqf199request.queryParameters = aainqf199queryparam;
+ //
+ // instanceFilters
+ //
+ Map aainqf199instancefiltermap = new HashMap();
+ Map aainqf199instancefiltermapitem = new HashMap();
+ aainqf199instancefiltermapitem.put("vserver-name", vserver);
+ aainqf199instancefiltermap.put("vserver", aainqf199instancefiltermapitem);
+ aainqf199instancefilter.instanceFilter.add(aainqf199instancefiltermap);
+ aainqf199request.instanceFilters = aainqf199instancefilter;
+ //
+ // print aainqf199request for debug
+ //
+ System.out.println("AAI Request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(aainqf199request));
+ //
+ // Create AAINQF199RequestWrapper
+ //
+ AAINQF199RequestWrapper aainqf199RequestWrapper = new AAINQF199RequestWrapper($event.requestID, aainqf199request);
+ //
+ // insert aainqf199request into memory
+ //
+ insert(aainqf199RequestWrapper);
+ }
+ //
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+end
+
+/*
+*
+* This rule happens when we got a valid ONSET, closed loop is enabled, an Event Manager
+* is created, AAI Manager and AAI Request are ready in memory. We can start sending query to AAI and then wait for response.
+*
+*/
+rule "${policyName}.EVENT.MANAGER.AAINQF199REQUEST"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+ $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)
+ then
+ System.out.println("rule EVENT.MANAGER.AAINQF199REQUEST is triggered.");
+ //
+ // send the request
+ //
+ AAINQF199Response aainqf199response = AAINQF199Manager.postQuery($params.getAaiURL(), $params.getAaiUsername(), $params.getAaiPassword(),
+ $aainqf199RequestWrapper.aainqf199request, $event.requestID);
+
+
+
+ //////////////////////////////////////////////////////////
+ // Simulate a valid aainqf199response for junit test
+ // Remove this for real deployment
+ //
+
+ AAINQF199InventoryResponseItem serviceItem = new AAINQF199InventoryResponseItem();
+ serviceItem.modelName = "service-instance";
+ serviceItem.serviceInstance = new AAINQF199ServiceInstance();
+ serviceItem.serviceInstance.serviceInstanceID = "cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5";
+ serviceItem.serviceInstance.serviceInstanceName = "Service_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8";
+ serviceItem.serviceInstance.personaModelId = "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b";
+ serviceItem.serviceInstance.personaModelVersion = "1.0";
+ serviceItem.serviceInstance.resourceVersion = "1485542400";
+ serviceItem.extraProperties = new AAINQF199ExtraProperties();
+ serviceItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name", "8330e932-2a23-4943-8606"));
+ serviceItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-type", "service"));
+ serviceItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-version", "1"));
+ serviceItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-id", "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b"));
+ serviceItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name-version-id", "5c996219-b2e2-4c76-9b43-7e8672a33c1d"));
+
+ AAINQF199InventoryResponseItem vfModuleItem = new AAINQF199InventoryResponseItem();
+ vfModuleItem.modelName = "C15ce9e1E9144c8fB8bb..base_vlb..module-0";
+ vfModuleItem.vfModule = new AAINQF199VfModule();
+ vfModuleItem.vfModule.vfModuleId = "b0eff878-e2e1-4947-9597-39afdd0f51dd";
+ vfModuleItem.vfModule.vfModuleName = "Vfmodule_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8";
+ vfModuleItem.vfModule.heatStackId = "Vfmodule_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8/5845f37b-6cda-4e91-8ca3-f5572d226488";
+ vfModuleItem.vfModule.orchestrationStatus = "active";
+ vfModuleItem.vfModule.isBaseVfModule = true;
+ vfModuleItem.vfModule.resourceVersion = "1485542667";
+ vfModuleItem.vfModule.personaModelId = "79ee24cd-fc9a-4f14-afae-5e1dd2ab2941";
+ vfModuleItem.vfModule.personaModelVersion = "1";
+
+ vfModuleItem.extraProperties = new AAINQF199ExtraProperties();
+ vfModuleItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name", "C15ce9e1E9144c8fB8bb..base_vlb..module-0"));
+ vfModuleItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-type", "resource"));
+ vfModuleItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-version", "1"));
+ vfModuleItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-id", "79ee24cd-fc9a-4f14-afae-5e1dd2ab2941"));
+ vfModuleItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name-version-id", "5484cabb-1a0d-4f29-a616-094a3f643d73"));
+
+
+ AAINQF199InventoryResponseItem vfModuleItem1 = new AAINQF199InventoryResponseItem();
+ //vfModuleItem1.modelName = "vf-module";
+ vfModuleItem1.vfModule = new AAINQF199VfModule();
+ vfModuleItem1.vfModule.vfModuleId = "dummy";
+ vfModuleItem1.vfModule.vfModuleName = "dummy";
+ vfModuleItem1.vfModule.isBaseVfModule = false;
+ vfModuleItem1.vfModule.resourceVersion = "1485561752";
+ vfModuleItem1.vfModule.personaModelId = "f32568ec-2f1c-458a-864b-0593d53d141a";
+ vfModuleItem1.vfModule.personaModelVersion = "1.0";
+
+ vfModuleItem1.extraProperties = new AAINQF199ExtraProperties();
+ vfModuleItem1.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name", "C15ce9e1E9144c8fB8bb..dnsscaling..module-1"));
+ vfModuleItem1.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-type", "resource"));
+ vfModuleItem1.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-version", "1"));
+ vfModuleItem1.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-id", "f32568ec-2f1c-458a-864b-0593d53d141a"));
+ vfModuleItem1.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name-version-id", "69615025-879d-4f0d-afe3-b7d1a7eeed1f"));
+
+
+
+ AAINQF199InventoryResponseItem vfModuleItem2 = new AAINQF199InventoryResponseItem();
+ //vfModuleItem2.modelName = "vf-module";
+ vfModuleItem2.vfModule = new AAINQF199VfModule();
+ vfModuleItem2.vfModule.vfModuleId = "8cd79e44-1fae-48c1-a160-609f90b46749";
+ vfModuleItem2.vfModule.vfModuleName = "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8";
+ vfModuleItem2.vfModule.heatStackId = "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8/f447ce51-14dd-4dcd-9957-68a047c79673";
+ vfModuleItem2.vfModule.orchestrationStatus = "active";
+ vfModuleItem2.vfModule.isBaseVfModule = false;
+ vfModuleItem2.vfModule.resourceVersion = "1485562712";
+ vfModuleItem2.vfModule.personaModelId = "f32568ec-2f1c-458a-864b-0593d53d141a";
+ vfModuleItem2.vfModule.personaModelVersion = "1.0";
+
+ vfModuleItem2.extraProperties = new AAINQF199ExtraProperties();
+ vfModuleItem2.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name", "C15ce9e1E9144c8fB8bb..dnsscaling..module-1"));
+ vfModuleItem2.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-type", "resource"));
+ vfModuleItem2.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-version", "1"));
+ vfModuleItem2.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-id", "f32568ec-2f1c-458a-864b-0593d53d141a"));
+ vfModuleItem2.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name-version-id", "69615025-879d-4f0d-afe3-b7d1a7eeed1f"));
+
+
+
+
+
+ AAINQF199InventoryResponseItem genericVNFItem = new AAINQF199InventoryResponseItem();
+ genericVNFItem.modelName = "generic-vnf";
+ genericVNFItem.genericVNF = new AAINQF199GenericVNF();
+ genericVNFItem.genericVNF.vnfID = "594e2fe0-48b8-41ff-82e2-3d4bab69b192";
+ genericVNFItem.genericVNF.vnfName = "Vnf_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8";
+ genericVNFItem.genericVNF.vnfType = "8330e932-2a23-4943-8606/c15ce9e1-e914-4c8f-b8bb 1";
+ genericVNFItem.genericVNF.serviceId = "b3f70641-bdb9-4030-825e-6abb73a1f929";
+// genericVNFItem.genericVNF.provStatus = "PREPROV";
+// genericVNFItem.genericVNF.operationalState = "dhv-test-operational-state";
+// genericVNFItem.genericVNF.ipv4OamAddress = "dhv-test-gvnf-ipv4-oam-address";
+// genericVNFItem.genericVNF.ipv4Loopback0Address = "dhv-test-gvnfipv4-loopback0-address";
+ genericVNFItem.genericVNF.inMaint = false;
+ genericVNFItem.genericVNF.isClosedLoopDisabled = false;
+ genericVNFItem.genericVNF.resourceVersion = "1485542422";
+// genericVNFItem.genericVNF.encrypedAccessFlag = true;
+ genericVNFItem.genericVNF.personaModelId = "033a32ed-aa65-4764-a736-36f2942f1aa0";
+ genericVNFItem.genericVNF.personaModelVersion = "1.0";
+ genericVNFItem.extraProperties = new AAINQF199ExtraProperties();
+ genericVNFItem.extraProperties.extraProperty = new LinkedList<AAINQF199ExtraProperty>();
+ genericVNFItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name", "c15ce9e1-e914-4c8f-b8bb"));
+ genericVNFItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-type", "resource"));
+ genericVNFItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-version", "1"));
+ genericVNFItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-id", "033a32ed-aa65-4764-a736-36f2942f1aa0"));
+ genericVNFItem.extraProperties.extraProperty.add(new AAINQF199ExtraProperty("model.model-name-version-id", "d4d072dc-4e21-4a03-9524-628985819a8e"));
+ genericVNFItem.items = new AAINQF199InventoryResponseItems();
+ genericVNFItem.items.inventoryResponseItems = new LinkedList<AAINQF199InventoryResponseItem>();
+ genericVNFItem.items.inventoryResponseItems.add(serviceItem);
+ genericVNFItem.items.inventoryResponseItems.add(vfModuleItem);
+ genericVNFItem.items.inventoryResponseItems.add(vfModuleItem1);
+ genericVNFItem.items.inventoryResponseItems.add(vfModuleItem2);
+
+ AAINQF199InventoryResponseItem cloudItem = new AAINQF199InventoryResponseItem();
+ cloudItem.cloudRegion = new AAINQF199CloudRegion();
+ cloudItem.cloudRegion.cloudOwner = "OWNER";
+ cloudItem.cloudRegion.cloudRegionId = "REGIONID";
+ cloudItem.cloudRegion.cloudRegionVersion = "2.5";
+ cloudItem.cloudRegion.complexName = "COMPLEXNAME";
+ cloudItem.cloudRegion.resourceVersion = "1485465545";
+
+ AAINQF199InventoryResponseItem tenantItem = new AAINQF199InventoryResponseItem();
+ tenantItem.tenant = new AAINQF199Tenant();
+ tenantItem.tenant.tenantId = "1015548";
+ tenantItem.tenant.tenantName = "1015548";
+ tenantItem.tenant.resourceVersion = "1485465545";
+ tenantItem.items = new AAINQF199InventoryResponseItems();
+ tenantItem.items.inventoryResponseItems = new LinkedList<AAINQF199InventoryResponseItem>();
+ tenantItem.items.inventoryResponseItems.add(cloudItem);
+
+ AAINQF199InventoryResponseItem vserverItem = new AAINQF199InventoryResponseItem();
+ vserverItem.vserver = new AAINQF199VServer();
+ vserverItem.vserver.vserverId = "70f081eb-2a87-4c81-9296-4b93d7d145c6";
+ vserverItem.vserver.vserverName = "vlb-lb-32c8";
+ vserverItem.vserver.vserverName2 = "vlb-lb-32c8";
+ vserverItem.vserver.provStatus = "ACTIVE";
+ vserverItem.vserver.vserverSelflink = "https://dfw.servers.api.rackspacecloud.com/v2/1015548/servers/70f081eb-2a87-4c81-9296-4b93d7d145c6";
+ vserverItem.vserver.inMaint = false;
+ vserverItem.vserver.isClosedLoopDisabled = false;
+ vserverItem.vserver.resourceVersion = "1485546436";
+ vserverItem.items = new AAINQF199InventoryResponseItems();
+ vserverItem.items.inventoryResponseItems = new LinkedList<AAINQF199InventoryResponseItem>();
+ vserverItem.items.inventoryResponseItems.add(genericVNFItem);
+ vserverItem.items.inventoryResponseItems.add(tenantItem);
+
+ aainqf199response = new AAINQF199Response();
+ aainqf199response.inventoryResponseItems.add(vserverItem);
+
+ System.out.println("PAM");
+ System.out.println(Serialization.gsonPretty.toJson(aainqf199response));
+
+ //////////////////////////////////////////////////////////
+
+
+
+
+
+ //
+ // Check AAI response
+ //
+ if (aainqf199response == null) {
+ System.err.println("Failed to get AAI response");
+ //
+ // Fail and retract everything
+ //
+ retract($event);
+ retract($manager);
+ retract($aainqf199RequestWrapper);
+ } else {
+ //
+ // Create AAINQF199ResponseWrapper
+ //
+ AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper($event.requestID, aainqf199response);
+ //
+ // insert aainqf199ResponseWrapper to memeory
+ //
+ insert(aainqf199ResponseWrapper);
+ }
+end
+
+/*
+*
+* This rule happens when we got a valid AAI response. We can start sending request to APPC or MSO now.
+*
+*/
+rule "${policyName}.EVENT.MANAGER.AAINQF199RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+ $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)
+ $aainqf199ResponseWrapper : AAINQF199ResponseWrapper(requestID == $event.requestID)
+ then
+ System.out.println("rule EVENT.MANAGER.AAINQF199RESPONSE is triggered.");
+ //
+ // Extract related fields out of AAINQF199RESPONSE
+ //
+ //
+ String vnfItemVnfId, vnfItemVnfType, vnfItemPersonaModelId, vnfItemPersonaModelVersion, vnfItemModelName,
+ vnfItemModelVersion, vnfItemModelNameVersionId, serviceItemServiceInstanceId, serviceItemPersonaModelId,
+ serviceItemModelName, serviceItemModelType, serviceItemModelVersion, serviceItemModelNameVersionId,
+ vfModuleItemVfModuleName, vfModuleItemPersonaModelId, vfModuleItemPersonaModelVersion, vfModuleItemModelName,
+ vfModuleItemModelNameVersionId, tenantItemTenantId, cloudRegionItemCloudRegionId;
+ try {
+ //
+ // vnfItem
+ //
+ vnfItemVnfId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;
+ vnfItemVnfType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;
+ vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf("/")+1);
+ vnfItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;
+ vnfItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;
+ vnfItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
+ vnfItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(2).propertyValue;
+ vnfItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
+ //
+ // serviceItem
+ //
+ serviceItemServiceInstanceId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;
+ serviceItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;
+ serviceItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
+ serviceItemModelType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue;
+ serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;
+ serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
+ //
+ // This comes from the base module
+ //
+ vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).vfModule.vfModuleName;
+ vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace("Vfmodule", "vDNS");
+ //
+ // vfModuleItem - NOT the base module
+ //
+ vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelId;
+ vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelVersion;
+ vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(0).propertyValue;
+ vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(4).propertyValue;
+ //
+ // tenantItem
+ //
+ tenantItemTenantId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;
+ //
+ // cloudRegionItem
+ //
+ cloudRegionItemCloudRegionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;
+ //
+ } catch (Exception e) {
+ e.printStackTrace();
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.REJECTED;
+ notification.message = "Exception occurred " + e.getMessage();
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e1) {
+ System.out.println("Can't deliver notification: " + notification);
+ e1.printStackTrace();
+ }
+ //
+ notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+ notification.message = "Invalid named-query response from AAI";
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e1) {
+ System.out.println("Can't deliver notification: " + notification);
+ e1.printStackTrace();
+ }
+ //
+ // Retract everything
+ //
+ retract($aainqf199RequestWrapper);
+ retract($aainqf199ResponseWrapper);
+ retract($manager);
+ retract($event);
+ return;
+ }
+ //
+ // Extracted fields should not be null
+ //
+ if ((vnfItemVnfId == null) || (vnfItemVnfType == null) ||
+ (vnfItemPersonaModelId == null) || (vnfItemModelName == null) ||
+ (vnfItemModelVersion == null) || (vnfItemModelNameVersionId == null) ||
+ (serviceItemServiceInstanceId == null) || (serviceItemModelName == null) ||
+ (serviceItemModelType == null) || (serviceItemModelVersion == null) ||
+ (serviceItemModelNameVersionId == null) || (vfModuleItemVfModuleName == null) ||
+ (vfModuleItemPersonaModelId == null) || (vfModuleItemPersonaModelVersion == null) ||
+ (vfModuleItemModelName == null) || (vfModuleItemModelNameVersionId == null) ||
+ (tenantItemTenantId == null) || (cloudRegionItemCloudRegionId == null)) {
+ //
+ System.err.println("some fields are missing from AAI response.");
+ //
+ // Fail and retract everything
+ //
+ retract($aainqf199RequestWrapper);
+ retract($aainqf199ResponseWrapper);
+ retract($manager);
+ retract($event);
+ return;
+ }
+ //
+ // We don't need them any more
+ //
+ retract($aainqf199ResponseWrapper);
+ retract($aainqf199RequestWrapper);
+ //
+ // check the actor of this closed loop
+ //
+ switch ($params.getActor()) {
+ case "APPC":
+ {
+ //
+ // Construct an APPC request
+ //
+ ControlLoopOperation operation = new ControlLoopOperation();
+ operation.actor = $params.getActor();
+ operation.operation = "ModifyConfig";
+ operation.target = $event.target;
+ //
+ // Create operationWrapper
+ //
+ ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+ //
+ // insert operationWrapper into memory
+ //
+ insert(operationWrapper);
+ //
+ Request request = new Request();
+ request.CommonHeader = new CommonHeader();
+ request.CommonHeader.RequestID = $event.requestID;
+ request.Action = operation.operation;
+ request.Payload = new HashMap<String, Object>();
+ //
+ // Fill in the payload
+ // Hardcode genericVNF for now since AAI has not been ready for vFirewall demo case
+ //
+ String genericVNF = "zdfw1fwl01pgn02";
+ request.Payload.put("generic-vnf.vnf-id", genericVNF);
+ //
+ PGRequest pgRequest = new PGRequest();
+ pgRequest.pgStreams = new PGStreams();
+
+ PGStream pgStream;
+ for(int i = 0; i < 5; i++){
+ pgStream = new PGStream();
+ pgStream.streamId = "fw_udp"+(i+1);
+ pgStream.isEnabled = "true";
+ pgRequest.pgStreams.pgStream.add(pgStream);
+ }
+ request.Payload.put("pg-streams", pgRequest.pgStreams);
+
+ if (request != null) {
+ //
+ // Insert request into memory
+ //
+ insert(request);
+ //
+ // Tell interested parties we are performing this Operation
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.OPERATION;
+ // message and history ??
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // Now send the operation request
+ //
+ if (request instanceof Request) {
+ try {
+ System.out.println("APPC request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(request));
+ //PolicyEngine.manager.deliver($params.getAppcTopic(), request);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver request: " + request);
+ }
+ }
+ } else {
+ //
+ // what happens if it is null
+ //
+ }
+ }
+ break;
+ case "MSO":
+ {
+ //
+ // Construct an operation
+ //
+ ControlLoopOperation operation = new ControlLoopOperation();
+ operation.actor = $params.getActor();
+ operation.operation = "createModuleInstance";
+ operation.target = $event.target;
+ //
+ // Create operationWrapper
+ //
+ ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+ //
+ // Construct an MSO request
+ //
+ MSORequest request = new MSORequest();
+ request.requestDetails = new MSORequestDetails();
+ request.requestDetails.modelInfo = new MSOModelInfo();
+ request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();
+ request.requestDetails.requestInfo = new MSORequestInfo();
+ request.requestDetails.requestParameters = new MSORequestParameters();
+ request.requestDetails.requestParameters.userParams = null;
+ //
+ // cloudConfiguration
+ //
+ request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;
+ request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;
+ //
+ // modelInfo
+ //
+ request.requestDetails.modelInfo.modelType = "vfModule";
+ request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;
+ request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;
+ request.requestDetails.modelInfo.modelName = vfModuleItemModelName;
+ request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;
+ //
+ // requestInfo
+ //
+ request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;
+ request.requestDetails.requestInfo.source = "POLICY";
+ request.requestDetails.requestInfo.suppressRollback = false;
+ //
+ // relatedInstanceList
+ //
+ MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();
+ MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();
+ relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();
+ relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();
+ //
+ relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;
+ relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;
+ //
+ relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;
+ relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemPersonaModelVersion;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;
+ //
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
+ //
+ // print MSO request for debug
+ //
+ System.out.println("MSO request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(request));
+ //
+ //
+ //
+ if (request != null) {
+ //
+ // Tell interested parties we are performing this Operation
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.OPERATION;
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // Concatenate serviceItemServiceInstanceId and vnfItemVnfId to msoURL
+ //
+ String MSOUrl = $params.getMsoURL() + "/serviceInstances/v2/" + serviceItemServiceInstanceId + "/vnfs/" + vnfItemVnfId + "/vfModules";
+ //
+ // Call MSO
+ //
+ MSOResponse response = MSOManager.createModuleInstance(MSOUrl, $params.getMsoURL(), $params.getMsoUsername(), $params.getMsoPassword(), request);
+
+
+
+ //////////////////////////////////////////////////////////
+ // Simulate a valid MSOResponse for junit test
+ // Remove this for real deployment
+ //
+ response = new MSOResponse();
+ response.request = new MSORequest();
+ response.request.requestStatus = new MSORequestStatus();
+ response.request.requestStatus.requestState = "COMPLETE";
+ //////////////////////////////////////////////////////////
+
+
+
+
+
+ if (response != null) {
+ //
+ // Assign requestId
+ //
+ request.requestId = $event.requestID.toString();
+ response.request.requestId = $event.requestID.toString();
+ //
+ // Insert facts
+ //
+ insert(operationWrapper);
+ insert(request);
+ insert(response);
+ } else {
+ //
+ // MSO request not even accepted
+ //
+ notification.message = operationWrapper.operation.toMessage();
+ operationWrapper.operation.message = operationWrapper.operation.toMessage();
+ operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+ $manager.setControlLoopResult("FAILURE_EXCEPTION");
+ notification.history.add(operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // Retract everything
+ //
+ retract($event);
+ retract($manager);
+ }
+ } else {
+ System.err.println("constructed MSO request is invalid.");
+ }
+ }
+ break;
+ }
+end
+
+/*
+*
+* This rule responds to APPC Response Events
+*
+*/
+rule "${policyName}.APPC.RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+ $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )
+ $request : Request( getCommonHeader().RequestID == $event.requestID )
+ $response : Response( getCommonHeader().RequestID == $event.requestID )
+ then
+ System.out.println("rule APPC.RESPONSE is triggered.");
+ if ($response.Status == null) {
+ $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+ $manager.setControlLoopResult("FAILURE_EXCEPTION");
+ }
+ //
+ // Get the Response Code
+ //
+ ResponseCode code = ResponseCode.toResponseCode($response.Status.Code);
+ if (code == null) {
+ $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+ $manager.setControlLoopResult("FAILURE_EXCEPTION");
+ }
+ //
+ // Construct notification
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ notification.message = $operationWrapper.operation.toMessage();
+ $operationWrapper.operation.message = $operationWrapper.operation.toMessage();
+ //
+ // Ok, let's figure out what APP-C's response is
+ //
+ switch (code) {
+ case ACCEPT:
+ $operationWrapper.operation.outcome = "PROCESSING";
+ break;
+ case ERROR:
+ case REJECT:
+ $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+ $manager.setControlLoopResult("FAILURE_EXCEPTION");
+ break;
+ case SUCCESS:
+ $operationWrapper.operation.outcome = "SUCCESS";
+ $manager.setControlLoopResult("SUCCESS");
+ break;
+ case FAILURE:
+ $operationWrapper.operation.outcome = "FAILURE";
+ $manager.setControlLoopResult("FAILURE");
+ break;
+ }
+ if ($operationWrapper.operation.outcome.equals("SUCCESS")) {
+ notification.history.add($operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+
+ //
+ // We are going to retract these objects from memory
+ //
+ System.out.println("Retracting everything");
+ retract($operationWrapper);
+ retract($request);
+ retract($response);
+ retract($event);
+ retract($manager);
+ } else if ($operationWrapper.operation.outcome.equals("PROCESSING")) {
+ retract($response);
+ } else {
+ notification.history.add($operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // We are going to retract these objects from memory
+ //
+ System.out.println("Retracting everything");
+ retract($operationWrapper);
+ retract($request);
+ retract($response);
+ retract($event);
+ retract($manager);
+ }
+
+end
+
+/*
+*
+* This rule is used to clean up APPC response
+*
+*/
+rule "${policyName}.APPC.RESPONSE.CLEANUP"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $response : Response($id : getCommonHeader().RequestID )
+ not ( VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) )
+ then
+ System.out.println("rule APPC.RESPONSE.CLEANUP is triggered.");
+ retract($response);
+end
+
+/*
+*
+* This rule responds to MSO Response Events
+*
+*/
+rule "${policyName}.MSO.RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+ $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )
+ $request : MSORequest( requestId == $event.requestID.toString() )
+ $response : MSOResponse( request.requestId == $event.requestID.toString() )
+ then
+ System.out.println("rule MSO.RESPONSE is triggered.");
+ //
+ // Construct notification
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ notification.message = $operationWrapper.operation.toMessage();
+ $operationWrapper.operation.message = $operationWrapper.operation.toMessage();
+ //
+ // The operation can either be succeeded or failed
+ //
+ if($response.request.requestStatus.requestState.equals("Completed")) {
+ $operationWrapper.operation.outcome = "SUCCESS";
+ $manager.setControlLoopResult("SUCCESS");
+ notification.history.add($operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // We are going to retract these objects from memory
+ //
+ System.out.println("Retracting everything");
+ retract($operationWrapper);
+ retract($request);
+ retract($response);
+ retract($event);
+ retract($manager);
+ } else {
+ $operationWrapper.operation.outcome = "FAILURE";
+ $manager.setControlLoopResult("FAILURE");
+ notification.history.add($operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ //PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // We are going to retract these objects from memory
+ //
+ System.out.println("Retracting everything");
+ retract($operationWrapper);
+ retract($request);
+ retract($response);
+ retract($event);
+ retract($manager);
+ }
+
+end
diff --git a/template.demo/src/test/java/org/openecomp/policy/template/demo/TestAPPCPayload.java b/template.demo/src/test/java/org/openecomp/policy/template/demo/TestAPPCPayload.java
new file mode 100644
index 000000000..114ae932a
--- /dev/null
+++ b/template.demo/src/test/java/org/openecomp/policy/template/demo/TestAPPCPayload.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.openecomp.policy.template.demo;
+
+import java.util.HashMap;
+import java.util.UUID;
+
+import org.junit.Test;
+import org.openecomp.policy.appc.CommonHeader;
+import org.openecomp.policy.appc.Request;
+import org.openecomp.policy.appc.util.Serialization;
+import org.openecomp.policy.vnf.trafficgenerator.PGRequest;
+import org.openecomp.policy.vnf.trafficgenerator.PGStream;
+import org.openecomp.policy.vnf.trafficgenerator.PGStreams;
+
+public class TestAPPCPayload {
+
+ @Test
+ public void test() {
+ PGRequest request = new PGRequest();
+ request.pgStreams = new PGStreams();
+
+ PGStream pgStream;
+ for(int i = 0; i < 5; i++){
+ pgStream = new PGStream();
+ pgStream.streamId = "fw_udp"+(i+1);
+ pgStream.isEnabled = "true";
+ request.pgStreams.pgStream.add(pgStream);
+ }
+
+ Request appc = new Request();
+ appc.CommonHeader = new CommonHeader();
+ appc.CommonHeader.RequestID = UUID.randomUUID();
+ appc.Action = "ModifyConfig";
+ appc.Payload = new HashMap<String, Object>();
+ appc.Payload.put("pg-streams", request);
+ System.out.println(Serialization.gsonPretty.toJson(appc));
+ }
+
+}
diff --git a/template.demo/src/test/java/org/openecomp/policy/template/demo/TestFirewallDemo.java b/template.demo/src/test/java/org/openecomp/policy/template/demo/TestFirewallDemo.java
new file mode 100644
index 000000000..799fe4363
--- /dev/null
+++ b/template.demo/src/test/java/org/openecomp/policy/template/demo/TestFirewallDemo.java
@@ -0,0 +1,595 @@
+/*-
+ * ============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.openecomp.policy.template.demo;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+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.openecomp.policy.appc.CommonHeader;
+import org.openecomp.policy.appc.Response;
+import org.openecomp.policy.appc.ResponseStatus;
+import org.openecomp.policy.controlloop.ControlLoopEventStatus;
+import org.openecomp.policy.controlloop.ControlLoopTargetType;
+import org.openecomp.policy.controlloop.VirtualControlLoopEvent;
+import org.openecomp.policy.controlloop.util.Serialization;
+
+
+
+public class TestFirewallDemo {
+
+
+ @Test
+ public void testvDNS() throws IOException {
+ //
+ // Build a container
+ //
+ final String closedLoopControlName = "CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8";
+ final KieSession kieSession = buildContainer("src/main/resources/archetype-resources/src/main/resources/ControlLoopDemo__closedLoopControlName__.drl",
+ closedLoopControlName,
+ "type=operational",
+ "myFirewallDemoPolicy",
+ "v1.0",
+ "MSO",
+ "http://localhost:8080/TestREST/Test",
+ "POLICY",
+ "POLICY",
+ "http://localhost:8080/TestREST/Test",
+ "POLICY",
+ "POLICY",
+ "4ff56a54-9e3f-46b7-a337-07a1d3c6b469",
+ 0,
+ "POLICY-CL-MGT",
+ "APPC-CL"
+ );
+ //
+ // Initial fire of rules
+ //
+ kieSession.fireAllRules();
+ //
+ // Kick a thread that starts testing
+ //
+ new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ //
+ // 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.VF;
+ 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;
+
+ System.out.println("----- Invalid ONSET -----");
+ System.out.println(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.VF;
+ onsetEvent.target = "generic-vnf.vnf-id";
+ 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.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+
+ System.out.println("----- ONSET -----");
+ System.out.println(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);
+ //
+ // 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.openecomp.policy.controlloop.Params", fact.getClass().getName());
+ }
+ }
+
+ @Ignore
+ @Test
+ public void testvFirewall() throws IOException {
+ //
+ // Build a container
+ //
+ final String closedLoopControlName = "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8";
+ final KieSession kieSession = buildContainer("src/main/resources/archetype-resources/src/main/resources/ControlLoopDemo__closedLoopControlName__.drl",
+ closedLoopControlName,
+ "type=operational",
+ "myFirewallDemoPolicy",
+ "v1.0",
+ "APPC",
+ "http://localhost:8080/TestREST/Test",
+ "POLICY",
+ "POLICY",
+ null,
+ null,
+ null,
+ null,
+ 1,
+ "POLICY-CL-MGT",
+ "APPC-CL"
+ );
+ //
+ // Initial fire of rules
+ //
+ kieSession.fireAllRules();
+ //
+ // Kick a thread that starts testing
+ //
+ new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ //
+ // 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.VF;
+ invalidEvent.target = "generic-vnf.vnf-id";
+ invalidEvent.from = "DCAE";
+ invalidEvent.closedLoopAlarmStart = Instant.now();
+ invalidEvent.AAI = new HashMap<String, String>();
+ invalidEvent.AAI.put("generic-vnf.vnf-id", "foo");
+ invalidEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+
+ System.out.println("----- Invalid ONSET -----");
+ System.out.println(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.VF;
+ onsetEvent.target = "generic-vnf.vnf-id";
+ onsetEvent.from = "DCAE";
+ onsetEvent.closedLoopAlarmStart = Instant.now();
+ onsetEvent.AAI = new HashMap<String, String>();
+ onsetEvent.AAI.put("generic-vnf.vnf-id", "fw0001vm001fw001");
+ //onsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
+ onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+
+ System.out.println("----- ONSET -----");
+ System.out.println(Serialization.gsonPretty.toJson(onsetEvent));
+
+ //
+ // Insert first DCAE ONSET Event into memory
+ //
+ kieSession.insert(onsetEvent);
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ }
+
+
+ Thread thread = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ while (true) {
+ //
+ // Generate subsequent DCAE ONSET Event
+ //
+ VirtualControlLoopEvent subOnsetEvent = new VirtualControlLoopEvent();
+ subOnsetEvent.closedLoopControlName = closedLoopControlName;
+ subOnsetEvent.requestID = UUID.randomUUID();
+ subOnsetEvent.closedLoopEventClient = "tca.instance00001";
+ subOnsetEvent.target_type = ControlLoopTargetType.VF;
+ subOnsetEvent.target = "generic-vnf.vnf-id";
+ subOnsetEvent.from = "DCAE";
+ subOnsetEvent.closedLoopAlarmStart = Instant.now();
+ subOnsetEvent.AAI = new HashMap<String, String>();
+ subOnsetEvent.AAI.put("generic-vnf.vnf-id", "fw0001vm001fw001");
+ //subOnsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
+ subOnsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+
+ System.out.println("----- Subsequent ONSET -----");
+ System.out.println(Serialization.gsonPretty.toJson(subOnsetEvent));
+
+ //
+ // Insert subsequent DCAE ONSET Event into memory
+ //
+ kieSession.insert(subOnsetEvent);
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ break;
+ }
+ }
+ }
+
+ });
+ thread.start();
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ }
+ //
+ // Stop the thread
+ //
+ thread.interrupt();
+ //
+ // Generate APPC ACCEPT Response
+ //
+ Response response1 = new Response();
+ // CommonHeader
+ CommonHeader commonHeader1 = new CommonHeader();
+ commonHeader1.RequestID = onsetEvent.requestID;
+ response1.CommonHeader = commonHeader1;
+ // ResponseStatus
+ ResponseStatus responseStatus1 = new ResponseStatus();
+ responseStatus1.Code = 100;
+ response1.Status = responseStatus1;
+ //
+ System.out.println("----- APP-C RESPONSE 100 -----");
+ System.out.println(Serialization.gsonPretty.toJson(response1));
+ //
+ // Insert APPC Response into memory
+ //
+ kieSession.insert(response1);
+ //
+ // Simulating APPC takes some time for processing the recipe
+ // and then gives response
+ //
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ //
+ // Generate APPC SUCCESS Response
+ //
+ Response response2 = new Response();
+ // CommonHeader
+ CommonHeader commonHeader2 = new CommonHeader();
+ commonHeader2.RequestID = onsetEvent.requestID;
+ response2.CommonHeader = commonHeader2;
+ // ResponseStatus
+ ResponseStatus responseStatus2 = new ResponseStatus();
+ responseStatus2.Code = 400;
+ response2.Status = responseStatus2;
+ //
+ System.out.println("----- APP-C RESPONSE 400 -----");
+ System.out.println(Serialization.gsonPretty.toJson(response2));
+ //
+ // Insert APPC Response into memory
+ //
+ kieSession.insert(response2);
+ //
+ 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);
+ //
+ // 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.openecomp.policy.controlloop.Params", fact.getClass().getName());
+ }
+ }
+
+ public static void dumpFacts(KieSession kieSession) {
+ System.out.println("Fact Count: " + kieSession.getFactCount());
+ for (FactHandle handle : kieSession.getFactHandles()) {
+ System.out.println("FACT: " + handle);
+ }
+ }
+
+ public static KieSession buildContainer(String droolsTemplate,
+ String closedLoopControlName,
+ String policyScope,
+ String policyName,
+ String policyVersion,
+ String actor,
+ String aaiURL,
+ String aaiUsername,
+ String aaiPassword,
+ String msoURL,
+ String msoUsername,
+ String msoPassword,
+ String aaiNamedQuery,
+ int aaiPatternMatch,
+ String notificationTopic,
+ String appcTopic ) throws IOException {
+ //
+ // Get our Drools Kie factory
+ //
+ KieServices ks = KieServices.Factory.get();
+
+ KieModuleModel kModule = ks.newKieModuleModel();
+
+ System.out.println("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,
+ aaiURL,
+ aaiUsername,
+ aaiPassword,
+ msoURL,
+ msoUsername,
+ msoPassword,
+ aaiNamedQuery,
+ aaiPatternMatch,
+ notificationTopic,
+ appcTopic
+ );
+
+ 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()) {
+ System.out.println(msg.toString());
+ }
+ //
+ // Create our kie Session and container
+ //
+ ReleaseId releaseId = ks.getRepository().getDefaultReleaseId();
+ System.out.println(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 aaiURL,
+ String aaiUsername,
+ String aaiPassword,
+ String msoURL,
+ String msoUsername,
+ String msoPassword,
+ String aaiNamedQueryUUID,
+ int aaiPatternMatch,
+ String notificationTopic,
+ String appcTopic) {
+
+ 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);
+ }
+
+ System.out.println(ruleContents);
+
+ return ruleContents;
+ }
+
+}
diff --git a/template.demo/src/test/java/org/openecomp/policy/template/demo/TestMSO.java b/template.demo/src/test/java/org/openecomp/policy/template/demo/TestMSO.java
new file mode 100644
index 000000000..a02e777f0
--- /dev/null
+++ b/template.demo/src/test/java/org/openecomp/policy/template/demo/TestMSO.java
@@ -0,0 +1,159 @@
+/*-
+ * ============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.openecomp.policy.template.demo;
+
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.util.UUID;
+
+import org.junit.Test;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Response;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ResponseWrapper;
+import org.openecomp.policy.aai.util.Serialization;
+import org.openecomp.policy.mso.MSOCloudConfiguration;
+import org.openecomp.policy.mso.MSOModelInfo;
+import org.openecomp.policy.mso.MSORelatedInstance;
+import org.openecomp.policy.mso.MSORelatedInstanceListElement;
+import org.openecomp.policy.mso.MSORequest;
+import org.openecomp.policy.mso.MSORequestDetails;
+import org.openecomp.policy.mso.MSORequestInfo;
+import org.openecomp.policy.mso.MSORequestParameters;
+
+import com.google.gson.Gson;
+import com.google.gson.stream.JsonReader;
+
+public class TestMSO {
+
+ @Test
+ public void test() throws FileNotFoundException {
+ Gson gson = new Gson();
+ JsonReader reader = new JsonReader(new FileReader("src/test/resources/aairesponse.json"));
+ AAINQF199Response response = gson.fromJson(reader, AAINQF199Response.class);
+
+ System.out.println(Serialization.gsonPretty.toJson(response));
+
+ AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper(UUID.randomUUID(), response);
+
+ //
+ //
+ // vnfItem
+ //
+ String vnfItemVnfId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;
+ String vnfItemVnfType = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;
+ vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf("/")+1);
+ String vnfItemPersonaModelId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;
+ String vnfItemPersonaModelVersion = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;
+ String vnfItemModelName = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
+ String vnfItemModelNameVersionId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
+ //
+ // serviceItem
+ //
+ String serviceItemServiceInstanceId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;
+ String serviceItemPersonaModelId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;
+ String serviceItemModelName = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
+ String serviceItemModelVersion = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;
+ String serviceItemModelNameVersionId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
+ //
+ // This comes from the base module
+ //
+ String vfModuleItemVfModuleName = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).vfModule.vfModuleName;
+ vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace("Vfmodule", "vDNS");
+ //
+ // vfModuleItem - NOT the base module
+ //
+ String vfModuleItemPersonaModelId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelId;
+ String vfModuleItemPersonaModelVersion = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelVersion;
+ String vfModuleItemModelName = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(0).propertyValue;
+ String vfModuleItemModelNameVersionId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(4).propertyValue;
+
+ //
+ // tenantItem
+ //
+ String tenantItemTenantId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;
+ //
+ // cloudRegionItem
+ //
+ String cloudRegionItemCloudRegionId = aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;
+
+ //
+ // Construct an MSO request
+ //
+ MSORequest request = new MSORequest();
+ request.requestDetails = new MSORequestDetails();
+ request.requestDetails.modelInfo = new MSOModelInfo();
+ request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();
+ request.requestDetails.requestInfo = new MSORequestInfo();
+ request.requestDetails.requestParameters = new MSORequestParameters();
+ request.requestDetails.requestParameters.userParams = null;
+ //
+ // cloudConfiguration
+ //
+ request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;
+ request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;
+ //
+ // modelInfo
+ //
+ request.requestDetails.modelInfo.modelType = "vfModule";
+ request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;
+ request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;
+ request.requestDetails.modelInfo.modelName = vfModuleItemModelName;
+ request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;
+ //
+ // requestInfo
+ //
+ request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;
+ request.requestDetails.requestInfo.source = "POLICY";
+ request.requestDetails.requestInfo.suppressRollback = false;
+ //
+ // relatedInstanceList
+ //
+ MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();
+ MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();
+ relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();
+ relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();
+ //
+ relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;
+ relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;
+ //
+ relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;
+ relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemPersonaModelVersion;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;
+ //
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
+ //
+ // print MSO request for debug
+ //
+ System.out.println("MSO request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(request));
+ }
+
+}
diff --git a/template.demo/src/test/resources/aairesponse.json b/template.demo/src/test/resources/aairesponse.json
new file mode 100644
index 000000000..66da8e715
--- /dev/null
+++ b/template.demo/src/test/resources/aairesponse.json
@@ -0,0 +1,227 @@
+{
+ "inventory-response-item": [
+ {
+ "extra-properties": {},
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model.model-name",
+ "property-value": "c15ce9e1-e914-4c8f-b8bb"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-version",
+ "property-value": "1"
+ },
+ {
+ "property-name": "model.model-id",
+ "property-value": "033a32ed-aa65-4764-a736-36f2942f1aa0"
+ },
+ {
+ "property-name": "model.model-name-version-id",
+ "property-value": "d4d072dc-4e21-4a03-9524-628985819a8e"
+ }
+ ]
+ },
+ "generic-vnf": {
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "orchestration-status": "Created",
+ "persona-model-id": "033a32ed-aa65-4764-a736-36f2942f1aa0",
+ "persona-model-version": "1.0",
+ "resource-version": "1485542422",
+ "service-id": "b3f70641-bdb9-4030-825e-6abb73a1f929",
+ "vnf-id": "594e2fe0-48b8-41ff-82e2-3d4bab69b192",
+ "vnf-name": "Vnf_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8",
+ "vnf-type": "8330e932-2a23-4943-8606/c15ce9e1-e914-4c8f-b8bb 1"
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model.model-name",
+ "property-value": "8330e932-2a23-4943-8606"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "service"
+ },
+ {
+ "property-name": "model.model-version",
+ "property-value": "1"
+ },
+ {
+ "property-name": "model.model-id",
+ "property-value": "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b"
+ },
+ {
+ "property-name": "model.model-name-version-id",
+ "property-value": "5c996219-b2e2-4c76-9b43-7e8672a33c1d"
+ }
+ ]
+ },
+ "service-instance": {
+ "persona-model-id": "4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b",
+ "persona-model-version": "1.0",
+ "resource-version": "1485542400",
+ "service-instance-id": "cf8426a6-0b53-4e3d-bfa6-4b2f4d5913a5",
+ "service-instance-name": "Service_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8"
+ }
+ },
+ {
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model.model-name",
+ "property-value": "C15ce9e1E9144c8fB8bb..base_vlb..module-0"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-version",
+ "property-value": "1"
+ },
+ {
+ "property-name": "model.model-id",
+ "property-value": "79ee24cd-fc9a-4f14-afae-5e1dd2ab2941"
+ },
+ {
+ "property-name": "model.model-name-version-id",
+ "property-value": "5484cabb-1a0d-4f29-a616-094a3f643d73"
+ }
+ ]
+ },
+ "model-name": "C15ce9e1E9144c8fB8bb..base_vlb..module-0",
+ "vf-module": {
+ "heat-stack-id": "Vfmodule_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8/5845f37b-6cda-4e91-8ca3-f5572d226488",
+ "is-base-vf-module": true,
+ "orchestration-status": "active",
+ "persona-model-id": "79ee24cd-fc9a-4f14-afae-5e1dd2ab2941",
+ "persona-model-version": "1",
+ "resource-version": "1485542667",
+ "vf-module-id": "b0eff878-e2e1-4947-9597-39afdd0f51dd",
+ "vf-module-name": "Vfmodule_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8"
+ }
+ },
+ {
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model.model-name",
+ "property-value": "C15ce9e1E9144c8fB8bb..dnsscaling..module-1"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-version",
+ "property-value": "1"
+ },
+ {
+ "property-name": "model.model-id",
+ "property-value": "f32568ec-2f1c-458a-864b-0593d53d141a"
+ },
+ {
+ "property-name": "model.model-name-version-id",
+ "property-value": "69615025-879d-4f0d-afe3-b7d1a7eeed1f"
+ }
+ ]
+ },
+ "vf-module": {
+ "is-base-vf-module": false,
+ "persona-model-id": "f32568ec-2f1c-458a-864b-0593d53d141a",
+ "persona-model-version": "1.0",
+ "resource-version": "1485561752",
+ "vf-module-id": "dummy",
+ "vf-module-name": "dummy"
+ }
+ },
+ {
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model.model-name",
+ "property-value": "C15ce9e1E9144c8fB8bb..dnsscaling..module-1"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-version",
+ "property-value": "1"
+ },
+ {
+ "property-name": "model.model-id",
+ "property-value": "f32568ec-2f1c-458a-864b-0593d53d141a"
+ },
+ {
+ "property-name": "model.model-name-version-id",
+ "property-value": "69615025-879d-4f0d-afe3-b7d1a7eeed1f"
+ }
+ ]
+ },
+ "vf-module": {
+ "heat-stack-id": "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8/f447ce51-14dd-4dcd-9957-68a047c79673",
+ "is-base-vf-module": false,
+ "orchestration-status": "active",
+ "persona-model-id": "f32568ec-2f1c-458a-864b-0593d53d141a",
+ "persona-model-version": "1.0",
+ "resource-version": "1485562712",
+ "vf-module-id": "8cd79e44-1fae-48c1-a160-609f90b46749",
+ "vf-module-name": "vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8"
+ }
+ }
+ ]
+ }
+ },
+ {
+ "extra-properties": {},
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "cloud-region": {
+ "cloud-owner": "Rackspace",
+ "cloud-region-id": "DFW",
+ "cloud-region-version": "v1",
+ "cloud-type": "SharedNode",
+ "cloud-zone": "CloudZone",
+ "owner-defined-type": "OwnerType",
+ "resource-version": "1485465545"
+ },
+ "extra-properties": {}
+ }
+ ]
+ },
+ "tenant": {
+ "resource-version": "1485465545",
+ "tenant-id": "1015548",
+ "tenant-name": "1015548"
+ }
+ }
+ ]
+ },
+ "vserver": {
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "prov-status": "ACTIVE",
+ "resource-version": "1485546436",
+ "vserver-id": "70f081eb-2a87-4c81-9296-4b93d7d145c6",
+ "vserver-name": "vlb-lb-32c8",
+ "vserver-name2": "vlb-lb-32c8",
+ "vserver-selflink": "https://dfw.servers.api.rackspacecloud.com/v2/1015548/servers/70f081eb-2a87-4c81-9296-4b93d7d145c6"
+ }
+ }
+ ]
+}
diff --git a/trafficgenerator/pom.xml b/trafficgenerator/pom.xml
new file mode 100644
index 000000000..d8306c95d
--- /dev/null
+++ b/trafficgenerator/pom.xml
@@ -0,0 +1,46 @@
+<!--
+ ============LICENSE_START=======================================================
+ Drools PDP Application Models
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>trafficgenerator</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGRequest.java b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGRequest.java
new file mode 100644
index 000000000..b20a09bad
--- /dev/null
+++ b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGRequest.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * trafficgenerator
+ * ================================================================================
+ * 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.openecomp.policy.vnf.trafficgenerator;
+
+import java.io.Serializable;
+
+
+import com.google.gson.annotations.SerializedName;
+
+public class PGRequest implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ @SerializedName("pg-streams")
+ public PGStreams pgStreams;
+
+ public PGRequest() {
+ }
+
+}
diff --git a/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStream.java b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStream.java
new file mode 100644
index 000000000..8f319624d
--- /dev/null
+++ b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStream.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * trafficgenerator
+ * ================================================================================
+ * 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.openecomp.policy.vnf.trafficgenerator;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class PGStream implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5567635677419358210L;
+
+ @SerializedName("id")
+ public String streamId;
+ @SerializedName("is-enabled")
+ public String isEnabled;
+
+ public PGStream() {
+ }
+
+}
diff --git a/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStreams.java b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStreams.java
new file mode 100644
index 000000000..698254801
--- /dev/null
+++ b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/PGStreams.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * trafficgenerator
+ * ================================================================================
+ * 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.openecomp.policy.vnf.trafficgenerator;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.google.gson.annotations.SerializedName;
+
+public class PGStreams implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5567635677419358210L;
+
+ @SerializedName("pg-stream")
+ public List<PGStream> pgStream= new LinkedList<PGStream>();
+
+ public PGStreams() {
+ }
+
+}
diff --git a/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/util/Serialization.java b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/util/Serialization.java
new file mode 100644
index 000000000..89816cdb3
--- /dev/null
+++ b/trafficgenerator/src/main/java/org/openecomp/policy/vnf/trafficgenerator/util/Serialization.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * trafficgenerator
+ * ================================================================================
+ * 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.openecomp.policy.vnf.trafficgenerator.util;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public final class Serialization {
+
+ final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
+ .setPrettyPrinting()
+// .registerTypeAdapter(AAIQueryParameters.class, new notificationTypeAdapter())
+ .create();
+}
diff --git a/trafficgenerator/src/test/java/org/openecomp/policy/vnf/trafficgenerator/TestDemo.java b/trafficgenerator/src/test/java/org/openecomp/policy/vnf/trafficgenerator/TestDemo.java
new file mode 100644
index 000000000..705faf3be
--- /dev/null
+++ b/trafficgenerator/src/test/java/org/openecomp/policy/vnf/trafficgenerator/TestDemo.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * trafficgenerator
+ * ================================================================================
+ * 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.openecomp.policy.vnf.trafficgenerator;
+
+
+import org.junit.Test;
+//import org.openecomp.policy.aai.util.Serialization;
+import org.openecomp.policy.vnf.trafficgenerator.PGRequest;
+import org.openecomp.policy.vnf.trafficgenerator.PGStream;
+import org.openecomp.policy.vnf.trafficgenerator.PGStreams;
+import org.openecomp.policy.vnf.trafficgenerator.util.Serialization;
+
+public class TestDemo {
+
+ @Test
+ public void test() {
+ PGRequest request = new PGRequest();
+ request.pgStreams = new PGStreams();
+
+ PGStream pgStream;
+ for(int i = 0; i < 5; i++){
+ pgStream = new PGStream();
+ pgStream.streamId = "fw_udp"+(i+1);
+ pgStream.isEnabled = "true";
+ request.pgStreams.pgStream.add(pgStream);
+ }
+
+ String body = Serialization.gsonPretty.toJson(request);
+ System.out.println(body);
+
+ // fail("Not yet implemented");
+ }
+
+}
diff --git a/vfwsim/pom.xml b/vfwsim/pom.xml
new file mode 100644
index 000000000..e95b6f761
--- /dev/null
+++ b/vfwsim/pom.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Drools PDP Application Models
+ ================================================================================
+ 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>drools-pdp-apps</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>vfwsim</artifactId>
+
+ <name>vFW simulator</name>
+ <description>Drools Application implementing vFW simulation</description>
+
+ <properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>demo</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>controlloop</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>rest</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>appc</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>aai</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>mso</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.policy.drools-applications</groupId>
+ <artifactId>trafficgenerator</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
+
diff --git a/vfwsim/src/main/java/org/openecomp/policy/sim/vfw/AppcResponseEvent.java b/vfwsim/src/main/java/org/openecomp/policy/sim/vfw/AppcResponseEvent.java
new file mode 100644
index 000000000..d135e79bc
--- /dev/null
+++ b/vfwsim/src/main/java/org/openecomp/policy/sim/vfw/AppcResponseEvent.java
@@ -0,0 +1,97 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * vFW simulator
+ * ================================================================================
+ * 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.openecomp.policy.sim.vfw;
+
+import java.io.Serializable;
+import java.util.UUID;
+
+import org.openecomp.policy.appc.CommonHeader;
+import org.openecomp.policy.appc.Response;
+import org.openecomp.policy.appc.ResponseStatus;
+
+public class AppcResponseEvent implements Serializable {
+
+ private static final long serialVersionUID = 6661836261200950007L;
+
+ public final String requestID;
+ public final String appcTopic;
+ public final int code;
+
+ public AppcResponseEvent(String requestID, String appcTopic, int code) {
+ this.requestID = requestID;
+ this.appcTopic = appcTopic;
+ this.code = code;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((appcTopic == null) ? 0 : appcTopic.hashCode());
+ result = prime * result + code;
+ result = prime * result + ((requestID == null) ? 0 : requestID.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ AppcResponseEvent other = (AppcResponseEvent) obj;
+ if (appcTopic == null) {
+ if (other.appcTopic != null)
+ return false;
+ } else if (!appcTopic.equals(other.appcTopic))
+ return false;
+ if (code != other.code)
+ return false;
+ if (requestID == null) {
+ if (other.requestID != null)
+ return false;
+ } else if (!requestID.equals(other.requestID))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "AppcResponseEvent [requestID=" + requestID + ", appcTopic=" + appcTopic + ", code=" + code + "]";
+ }
+
+ public static Response toResponse(String requestId, int code) {
+ Response response = new Response();
+
+ CommonHeader commonHeader = new CommonHeader();
+ commonHeader.RequestID = UUID.fromString(requestId);
+ response.CommonHeader = commonHeader;
+
+ ResponseStatus responseStatus = new ResponseStatus();
+ responseStatus.Code = responseStatus.Code = code;
+ response.Status = responseStatus;
+
+ return response;
+ }
+
+}
diff --git a/vfwsim/src/main/java/org/openecomp/policy/sim/vfw/OnsetEvent.java b/vfwsim/src/main/java/org/openecomp/policy/sim/vfw/OnsetEvent.java
new file mode 100644
index 000000000..5c371316e
--- /dev/null
+++ b/vfwsim/src/main/java/org/openecomp/policy/sim/vfw/OnsetEvent.java
@@ -0,0 +1,257 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * vFW simulator
+ * ================================================================================
+ * 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.openecomp.policy.sim.vfw;
+
+import java.io.Serializable;
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.UUID;
+
+import org.openecomp.policy.controlloop.ControlLoopEventStatus;
+import org.openecomp.policy.controlloop.ControlLoopTargetType;
+import org.openecomp.policy.controlloop.VirtualControlLoopEvent;
+
+public class OnsetEvent implements Serializable {
+
+ private static final long serialVersionUID = -7904064194557621526L;
+
+ public static String DEFAULT_CLOSEDLOOP_CONTROL_NAME = "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8";
+ public static String DEFAULT_CLOSEDLOOP_EVENT_CLIENT = "tca.instance00001";
+ public static String DEFAULT_REQUEST_ID = "664be3d2-6c12-4f4b-a3e7-c349acced200";
+ public static String DEFAULT_TARGET = "generic-vnf.vnf-id";
+ public static String DEFAULT_TARGET_TYPE = "VF";
+ public static String DEFAULT_FROM = "DCAE";
+
+ public static String DEFAULT_AAI_VNF_ID_NAME = DEFAULT_TARGET;
+ public static String DEFAULT_AAI_VNF_ID_VALUE = "fw0001vm001fw001";
+
+ public static String DEFAULT_AAI_VSERVER_NAME = "vserver.vserver-name";
+ public static String DEFAULT_AAI_VSERVER_VALUE = "vserver-name-16102016-aai3255-data-11-1";
+
+ public String closedLoopControlName = DEFAULT_CLOSEDLOOP_CONTROL_NAME;
+ public String closedLoopEventClient = DEFAULT_CLOSEDLOOP_EVENT_CLIENT;
+ public String requestID = UUID.randomUUID().toString();
+ public String target = DEFAULT_TARGET;
+ public String targetType = DEFAULT_TARGET_TYPE;
+ public String aaIVnfId = DEFAULT_AAI_VNF_ID_VALUE;
+ public String aaIServerName = DEFAULT_AAI_VSERVER_VALUE;
+ public String from = "DCAE";
+
+ public String dcaeTopic = "DCAE-CL-EVENT";
+ public String appcTopic = "APPC-CL";
+ public int appcResponseCode = 100;
+
+ public OnsetEvent() {
+ super();
+ }
+
+ public OnsetEvent(String closedLoopControlName) {
+ super();
+
+ if (closedLoopControlName != null && !closedLoopControlName.isEmpty())
+ this.closedLoopControlName = closedLoopControlName;
+ }
+
+ public OnsetEvent(String closedLoopControlName, String dcaeTopic, String appcTopic, int code) {
+ super();
+
+ if (closedLoopControlName != null && !closedLoopControlName.isEmpty())
+ this.closedLoopControlName = closedLoopControlName;
+
+ if (dcaeTopic != null && !dcaeTopic.isEmpty())
+ this.dcaeTopic = dcaeTopic;
+
+ if (appcTopic != null && !appcTopic.isEmpty())
+ this.appcTopic = appcTopic;
+
+ this.appcResponseCode = code;
+ }
+
+ public OnsetEvent(String closedLoopControlName, String requestID, String dcaeTopic, String appcTopic, int code) {
+ super();
+
+ if (closedLoopControlName != null && !closedLoopControlName.isEmpty())
+ this.closedLoopControlName = closedLoopControlName;
+
+ if (requestID != null)
+ this.requestID = requestID;
+
+ if (dcaeTopic != null && !dcaeTopic.isEmpty())
+ this.dcaeTopic = dcaeTopic;
+
+ if (appcTopic != null && !appcTopic.isEmpty())
+ this.appcTopic = appcTopic;
+
+ this.appcResponseCode = code;
+ }
+
+ public OnsetEvent(String closedLoopControlName, String closedLoopEventClient,
+ String requestID, String target,
+ String targetType, String aaIVnfId,
+ String aaIServerName, String from,
+ String dcaeTopic, String appcTopic,
+ int code) {
+ super();
+
+ if (closedLoopControlName != null && !closedLoopControlName.isEmpty())
+ this.closedLoopControlName = closedLoopControlName;
+
+ if (closedLoopEventClient != null && !closedLoopEventClient.isEmpty())
+ this.closedLoopEventClient = closedLoopEventClient;
+
+ if (requestID != null)
+ this.requestID = requestID;
+
+ if (target != null && !target.isEmpty())
+ this.target = target;
+
+ if (targetType != null && !targetType.isEmpty())
+ this.targetType = targetType;
+
+ if (aaIVnfId != null && !aaIVnfId.isEmpty())
+ this.aaIVnfId = aaIVnfId;
+
+ if (aaIServerName != null && !aaIServerName.isEmpty())
+ this.aaIServerName = aaIServerName;
+
+ if (from != null && !from.isEmpty())
+ this.from = from;
+
+ if (dcaeTopic != null && !dcaeTopic.isEmpty())
+ this.dcaeTopic = dcaeTopic;
+
+ if (appcTopic != null && !appcTopic.isEmpty())
+ this.appcTopic = appcTopic;
+
+ this.appcResponseCode = code;
+ }
+
+ public VirtualControlLoopEvent toDcaeOnset() {
+
+ VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
+
+ onsetEvent.closedLoopControlName = this.closedLoopControlName;
+ onsetEvent.requestID = UUID.fromString(this.requestID);
+ onsetEvent.closedLoopEventClient = this.closedLoopEventClient;
+ onsetEvent.target_type = ControlLoopTargetType.valueOf(this.targetType);
+ onsetEvent.target = this.target;
+ onsetEvent.from = this.from;
+ onsetEvent.closedLoopAlarmStart = Instant.now();
+ onsetEvent.AAI = new HashMap<String, String>();
+ onsetEvent.AAI.put(this.target, this.aaIVnfId);
+ onsetEvent.AAI.put(DEFAULT_AAI_VSERVER_NAME, "vserver-name-16102016-aai3255-data-11-1");
+ onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+
+ return onsetEvent;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((aaIServerName == null) ? 0 : aaIServerName.hashCode());
+ result = prime * result + ((aaIVnfId == null) ? 0 : aaIVnfId.hashCode());
+ result = prime * result + appcResponseCode;
+ result = prime * result + ((appcTopic == null) ? 0 : appcTopic.hashCode());
+ result = prime * result + ((closedLoopControlName == null) ? 0 : closedLoopControlName.hashCode());
+ result = prime * result + ((closedLoopEventClient == null) ? 0 : closedLoopEventClient.hashCode());
+ result = prime * result + ((dcaeTopic == null) ? 0 : dcaeTopic.hashCode());
+ result = prime * result + ((from == null) ? 0 : from.hashCode());
+ result = prime * result + ((requestID == null) ? 0 : requestID.hashCode());
+ result = prime * result + ((target == null) ? 0 : target.hashCode());
+ result = prime * result + ((targetType == null) ? 0 : targetType.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ OnsetEvent other = (OnsetEvent) obj;
+ if (aaIServerName == null) {
+ if (other.aaIServerName != null)
+ return false;
+ } else if (!aaIServerName.equals(other.aaIServerName))
+ return false;
+ if (aaIVnfId == null) {
+ if (other.aaIVnfId != null)
+ return false;
+ } else if (!aaIVnfId.equals(other.aaIVnfId))
+ return false;
+ if (appcResponseCode != other.appcResponseCode)
+ return false;
+ if (appcTopic == null) {
+ if (other.appcTopic != null)
+ return false;
+ } else if (!appcTopic.equals(other.appcTopic))
+ return false;
+ if (closedLoopControlName == null) {
+ if (other.closedLoopControlName != null)
+ return false;
+ } else if (!closedLoopControlName.equals(other.closedLoopControlName))
+ return false;
+ if (closedLoopEventClient == null) {
+ if (other.closedLoopEventClient != null)
+ return false;
+ } else if (!closedLoopEventClient.equals(other.closedLoopEventClient))
+ return false;
+ if (dcaeTopic == null) {
+ if (other.dcaeTopic != null)
+ return false;
+ } else if (!dcaeTopic.equals(other.dcaeTopic))
+ return false;
+ if (from == null) {
+ if (other.from != null)
+ return false;
+ } else if (!from.equals(other.from))
+ return false;
+ if (requestID == null) {
+ if (other.requestID != null)
+ return false;
+ } else if (!requestID.equals(other.requestID))
+ return false;
+ if (target == null) {
+ if (other.target != null)
+ return false;
+ } else if (!target.equals(other.target))
+ return false;
+ if (targetType == null) {
+ if (other.targetType != null)
+ return false;
+ } else if (!targetType.equals(other.targetType))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "OnsetEvent [closedLoopControlName=" + closedLoopControlName + ", closedLoopEventClient="
+ + closedLoopEventClient + ", requestID=" + requestID + ", target=" + target + ", targetType="
+ + targetType + ", aaIVnfId=" + aaIVnfId + ", aaIServerName=" + aaIServerName + ", from=" + from
+ + ", dcaeTopic=" + dcaeTopic + ", appcTopic=" + appcTopic + ", appcResponseCode=" + appcResponseCode
+ + "]";
+ }
+
+}
diff --git a/vfwsim/src/main/resources/META-INF/kmodule.xml b/vfwsim/src/main/resources/META-INF/kmodule.xml
new file mode 100644
index 000000000..0f1e22fef
--- /dev/null
+++ b/vfwsim/src/main/resources/META-INF/kmodule.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ vFW simulator
+ ================================================================================
+ 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=========================================================
+ -->
+
+<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
+ <kbase name="KBvFWsim">
+ <ksession name="vFWsim"/>
+ </kbase>
+</kmodule>
+
diff --git a/vfwsim/src/main/resources/vFWsim.drl b/vfwsim/src/main/resources/vFWsim.drl
new file mode 100644
index 000000000..cb303b674
--- /dev/null
+++ b/vfwsim/src/main/resources/vFWsim.drl
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * vFW simulator
+ * ================================================================================
+ * 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.openecomp.policy.sim.vfw;
+
+import org.openecomp.policy.appc.Request;
+
+import org.openecomp.policy.controlloop.ControlLoopEventStatus;
+import org.openecomp.policy.controlloop.ControlLoopTargetType;
+import org.openecomp.policy.controlloop.VirtualControlLoopEvent;
+
+import org.openecomp.policy.drools.system.PolicyEngine;
+
+rule "vFWsim.ONSET"
+when
+ $onset : OnsetEvent()
+then
+ String WHERE = drools.getRule().getPackage() + "." + drools.getRule().getName();
+
+ try {
+ System.out.println(WHERE + ": " + "DCAE[ONSET|" + $onset.requestID + "|" +
+ $onset.dcaeTopic + "] -> PDP-D" );
+ PolicyEngine.manager.deliver($onset.dcaeTopic, $onset.toDcaeOnset());
+ insert(new AppcResponseEvent($onset.requestID.toString(), $onset.appcTopic, $onset.appcResponseCode));
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ retract($onset);
+ }
+end
+
+rule "vFWsim.APPC.RESPONSE"
+when
+ $appcResponse : AppcResponseEvent( code > 0 )
+ $request : Request( getCommonHeader().RequestID.toString() == $appcResponse.requestID )
+then
+ String WHERE = drools.getRule().getPackage() + "." + drools.getRule().getName();
+
+ try {
+ System.out.println(WHERE + ": " + "APPC[" + $appcResponse.code + "|" + $appcResponse.requestID + "|" +
+ $appcResponse.appcTopic + "] -> PDP-D" );
+
+ PolicyEngine.manager.deliver($appcResponse.appcTopic,
+ AppcResponseEvent.toResponse($appcResponse.requestID, $appcResponse.code));
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ retract($appcResponse);
+ retract($request);
+ }
+end