aboutsummaryrefslogtreecommitdiffstats
path: root/packages/base/src/files/install/servers/pap
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-02-14 19:41:00 -0500
committerPamela Dragosh <pdragosh@research.att.com>2017-02-14 19:41:32 -0500
commit91d04c64771832a0b8815ffbe1f0f9920320d94d (patch)
treefb02d5e1c84a3d91def9a7ee95bc87f9c046cc96 /packages/base/src/files/install/servers/pap
parentb9d4caa40ef8e3566ac475968bce17b9b64b6939 (diff)
Initial OpenECOMP policy/engine commit
Change-Id: I7dbff37733b661643dd4d1caefa3d7dccc361b6e Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'packages/base/src/files/install/servers/pap')
-rw-r--r--packages/base/src/files/install/servers/pap/bin/autopush.properties22
-rw-r--r--packages/base/src/files/install/servers/pap/bin/config/policyLogger.properties44
-rw-r--r--packages/base/src/files/install/servers/pap/bin/test.properties21
-rw-r--r--packages/base/src/files/install/servers/pap/bin/xacml.pap.properties132
-rw-r--r--packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt1116
-rw-r--r--packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.txt1116
-rw-r--r--packages/base/src/files/install/servers/pap/webapps/Config/com.Config_MS_vFirewall.1.json1
-rw-r--r--packages/base/src/files/install/servers/pap/webapps/Config/com.Config_MS_vLoadBalancer.1.json1
8 files changed, 2453 insertions, 0 deletions
diff --git a/packages/base/src/files/install/servers/pap/bin/autopush.properties b/packages/base/src/files/install/servers/pap/bin/autopush.properties
new file mode 100644
index 000000000..8d780842f
--- /dev/null
+++ b/packages/base/src/files/install/servers/pap/bin/autopush.properties
@@ -0,0 +1,22 @@
+###
+# ============LICENSE_START=======================================================
+# ECOMP Policy Engine
+# ================================================================================
+# 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=========================================================
+###
+
+default.policyType=
+default.policyScope= \ No newline at end of file
diff --git a/packages/base/src/files/install/servers/pap/bin/config/policyLogger.properties b/packages/base/src/files/install/servers/pap/bin/config/policyLogger.properties
new file mode 100644
index 000000000..0deb1b3d6
--- /dev/null
+++ b/packages/base/src/files/install/servers/pap/bin/config/policyLogger.properties
@@ -0,0 +1,44 @@
+###
+# ============LICENSE_START=======================================================
+# ECOMP Policy Engine
+# ================================================================================
+# 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=========================================================
+###
+
+################################### Set concurrentHashMap and timer info #######################
+#Timer initial delay and the delay between in milliseconds before task is to be execute.
+timer.delay.time=1000
+#Timer scheduleAtFixedRate period - time in milliseconds between successive task executions.
+check.interval= 30000
+#Longest time an event info can be stored in the concurrentHashMap for logging - in seconds.
+event.expired.time=86400
+#Size of the concurrentHashMap which stores the event starting time, etc - when its size reaches this limit, the Timer gets executed
+#to remove all expired records from this concurrentHashMap.
+concurrentHashMap.limit=5000
+#Size of the concurrentHashMap - when its size drops to this point, stop the Timer
+stop.check.point=2500
+################################### Set logging format #############################################
+# set EELF for EELF logging format, set LOG4J for using log4j, set SYSTEMOUT for using system.out.println
+logger.type=EELF
+#################################### Set level for EELF or SYSTEMOUT logging ##################################
+# Set level for debug file. Set DEBUG to enable .info, .warn and .debug; set INFO for enable .info and .warn; set OFF to disable all
+debugLogger.level=INFO
+# Set level for metrics file. Set OFF to disable; set ON to enable
+metricsLogger.level=ON
+# Set level for error file. Set OFF to disable; set ON to enable
+error.level=ON
+# Set level for audit file. Set OFF to disable; set ON to enable
+audit.level=ON
diff --git a/packages/base/src/files/install/servers/pap/bin/test.properties b/packages/base/src/files/install/servers/pap/bin/test.properties
new file mode 100644
index 000000000..e983c3b7c
--- /dev/null
+++ b/packages/base/src/files/install/servers/pap/bin/test.properties
@@ -0,0 +1,21 @@
+###
+# ============LICENSE_START=======================================================
+# ECOMP Policy Engine
+# ================================================================================
+# 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=========================================================
+###
+
+PDP_URL=${{PAP_PDP_URL}},${{PAP_PDP_HTTP_USER_ID}},${{PAP_PDP_HTTP_PASSWORD}}
diff --git a/packages/base/src/files/install/servers/pap/bin/xacml.pap.properties b/packages/base/src/files/install/servers/pap/bin/xacml.pap.properties
new file mode 100644
index 000000000..0393bdefa
--- /dev/null
+++ b/packages/base/src/files/install/servers/pap/bin/xacml.pap.properties
@@ -0,0 +1,132 @@
+###
+# ============LICENSE_START=======================================================
+# ECOMP Policy Engine
+# ================================================================================
+# 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=========================================================
+###
+
+#
+# This is our factory that will create our engine
+#
+xacml.PAP.papEngineFactory=org.openecomp.policy.xacml.std.pap.StdEngineFactory
+
+#
+# Where we store our PAP PDP Group/Node information
+#
+xacml.pap.pdps=${{PAP_PDPS}}
+
+#
+# Need the PAP's url (how PDPs will reach it) configured here
+# because we need it to generate the URLs of the Policy Files
+# sent to the PDPs in the configuration when the PAP is first brought up.
+# (In other cases, such as the PDP calling the PAP, we could generate this URL,
+# but for startup there is no other way to get it.)
+#
+#
+xacml.rest.pap.url=${{PAP_URL}}
+
+#
+# Upon startup, have the PAP servlet send latest configuration information to all
+# the PDP nodes it knows about.
+#
+xacml.rest.pap.initiate.pdp=${{PAP_INITIATE_PDP}}
+#
+# Heartbeat from PAP to PDPs
+#
+# How much time (in milliseconds) between heartbeats
+# (i.e. the time between completing the heartbeat with all PDPs and starting the next cycle)
+#
+xacml.rest.pap.heartbeat.interval=${{PAP_HEARTBEAT_INTERVAL}}
+#
+# Heartbeat connection timeout (in milliseconds)
+#
+xacml.rest.pap.heartbeat.timeout=${{PAP_HEARTBEAT_TIMEOUT}}
+
+################################################################################################
+# Adding properties for getting properties previously used by PAP-ADMIN for creating Policies
+# THis is part of the Policy Creation API project
+################################################################################################
+
+# Set your domain here:
+xacml.rest.pap.domain=${{REST_ADMIN_DOMAIN}}
+
+# Location where all the user workspaces are located.
+xacml.rest.pap.workspace=${{REST_ADMIN_WORKSPACE}}
+
+# Location where the GIT repository is located
+xacml.rest.pap.repository=${{REST_ADMIN_REPOSITORY}}
+
+# PAP-REST webapps Location here.
+xacml.rest.config.webapps=${{POLICY_HOME}}/servers/pap/webapps
+
+# id
+xacml.rest.pap.userid=${{PAP_HTTP_USER_ID}}
+# pass
+xacml.rest.pap.password=${{PAP_HTTP_PASSWORD}}
+# pdps file
+xacml.rest.pdp.idfile=test.properties
+
+#New values added 10-21-2015
+#database driver for PAP
+javax.persistence.jdbc.driver=${{JDBC_DRIVER}}
+#database URL for PAP
+javax.persistence.jdbc.url=${{JDBC_URL}}
+#database username for PAP
+javax.persistence.jdbc.user=${{JDBC_USER}}
+#database password for PAP
+javax.persistence.jdbc.password=${{JDBC_PASSWORD}}
+#Time in ms which a Policy DB transaction will wait to get the transaction lock object
+xacml.rest.pap.transaction.waitms=${{PROP_PAP_TRANS_WAIT}}
+#Policy DB transaction timeout in ms after it has obtained the transaction lock object
+xacml.rest.pap.transaction.timeoutms=${{PROP_PAP_TRANS_TIMEOUT}}
+#Policy Audit timeout in ms after it has obtained the transaction lock object
+xacml.rest.pap.audit.timeoutms=${{PROP_PAP_AUDIT_TIMEOUT}}
+#Turning audit ON (set to true) will synchronize the policies in the filesystem with those in the database.
+#Turning audit OFF (set to false) will not synchronize policies
+xacml.rest.pap.run.audit.flag=${{PROP_PAP_RUN_AUDIT_FLAG}}
+#The audit can run in two directions.
+# 1.The file system can duplicate the database: database>file system (set property to true)
+# 2.The database can duplicate the file system: file system>database (set property to false)
+xacml.rest.pap.filesystem.audit=${{PROP_PAP_AUDIT_FLAG}}
+#AutoPush Policy Flag
+xacml.rest.pap.autopush.flag=false
+#AutoPush Policy
+xacml.rest.pap.autopush.file=autopush.properties
+#Patter to identify if a attribute is ready. Currently just a place holder
+xacm.xcor.required.pattern=1,1
+
+#***Properties for IntegrityMonitor integration defined in XACMLRestProperties.java***
+#The name of the PAP. Must be unique across the system
+xacml.rest.pap.resource.name=${{resource_name}}
+
+#***Properties for IntegrityMonitor integration defined in IntegrityMonitorProperties.java***
+site_name=${{site_name}}
+node_type=${{node_type}}
+dependency_groups=${{dependency_groups}}
+fp_monitor_interval=${{fp_monitor_interval}}
+failed_counter_threshold=${{failed_counter_threshold}}
+test_trans_interval=${{test_trans_interval}}
+write_fpc_interval=${{write_fpc_interval}}
+max_fpc_update_interval=${{max_fpc_update_interval}}
+test_via_jmx=${{test_via_jmx}}
+
+# The (optional) period of time in seconds between executions of the integrity audit.
+# Value < 0 : Audit does not run (default value if property is not present = -1)
+# Value = 0 : Audit runs continuously
+# Value > 0 : The period of time in seconds between execution of the audit on a particular node
+integrity_audit_period_seconds=${{integrity_audit_period_seconds}}
+# Environment should be Set either DEV, TEST or PROD
+ENVIRONMENT=${{ENVIRONMENT}} \ No newline at end of file
diff --git a/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt b/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt
new file mode 100644
index 000000000..42b67999f
--- /dev/null
+++ b/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt
@@ -0,0 +1,1116 @@
+/* Autogenerated Code Please Don't change/remove this comment section. This is for the UI purpose.
+ <$%BRMSParamTemplate=ControlLoopDemo__closedLoopControlName%$>
+ */
+
+
+/*-
+ * ============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 "BRMSParamvFWDemoPolicy.SETUP"
+* when
+* then
+* System.out.println("rule SETUP is triggered.");
+* Params params = new Params();
+* params.setClosedLoopControlName("CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8");
+* params.setActor("APPC");
+* params.setAaiURL("null");
+* params.setAaiUsername("null");
+* params.setAaiPassword("null");
+* params.setMsoURL("null");
+* params.setMsoUsername("null");
+* params.setMsoPassword("null");
+* params.setAaiNamedQueryUUID("null");
+* params.setAaiPatternMatch(1);
+* params.setNotificationTopic("POLICY-CL-MGT");
+* params.setAppcTopic("APPC-CL");
+* //
+* // This stays in memory as long as the rule is alive and running
+* //
+* insert(params);
+*end
+*/
+/*
+*
+* This rule responds to DCAE Events
+*
+*/
+rule "BRMSParamvFWDemoPolicy.EVENT"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 = "com";
+ notification.policyVersion = "1";
+ //
+ // 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 = "com";
+ notification.policyVersion = "1";
+ //
+ // 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 = "com";
+ notification.policyVersion = "1";
+ //
+ //
+ //
+ 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 "BRMSParamvFWDemoPolicy.EVENT.MANAGER"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 = "com";
+ notification.policyVersion = "1";
+ 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 "BRMSParamvFWDemoPolicy.EVENT.MANAGER.AAINQF199REQUEST"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 "BRMSParamvFWDemoPolicy.EVENT.MANAGER.AAINQF199RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 = "com";
+ notification.policyVersion = "1";
+ //
+ 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 = "com";
+ notification.policyVersion = "1";
+ 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 = "com";
+ notification.policyVersion = "1";
+ 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 "BRMSParamvFWDemoPolicy.APPC.RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 = "com";
+ notification.policyVersion = "1";
+ 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 "BRMSParamvFWDemoPolicy.APPC.RESPONSE.CLEANUP"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 "BRMSParamvFWDemoPolicy.MSO.RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 = "com";
+ notification.policyVersion = "1";
+ 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
+rule "Params"
+ salience 1000
+ when
+ then
+ Params params = new Params();
+ params.setAaiPatternMatch(1);
+ params.setAppcTopic("APPC-CL");
+ params.setAaiURL("null");
+ params.setMsoPassword("null");
+ params.setClosedLoopControlName("CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8");
+ params.setAaiUsername("null");
+ params.setMsoURL("null");
+ params.setActor("APPC");
+ params.setMsoUsername("null");
+ params.setAaiNamedQueryUUID("null");
+ params.setAaiPassword("null");
+ params.setNotificationTopic("POLICY-CL-MGT");
+ insert(params);
+end
diff --git a/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.txt b/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.txt
new file mode 100644
index 000000000..2fdfa6736
--- /dev/null
+++ b/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.txt
@@ -0,0 +1,1116 @@
+/* Autogenerated Code Please Don't change/remove this comment section. This is for the UI purpose.
+ <$%BRMSParamTemplate=ControlLoopDemo__closedLoopControlName%$>
+ */
+
+
+/*-
+ * ============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 "BRMSParamvLBDemoPolicy.SETUP"
+* when
+* then
+* System.out.println("rule SETUP is triggered.");
+* Params params = new Params();
+* params.setClosedLoopControlName("CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8");
+* params.setActor("MSO");
+* params.setAaiURL("https://aai.api.simpledemo.openecomp.org:8443");
+* params.setAaiUsername("POLICY");
+* params.setAaiPassword("POLICY");
+* params.setMsoURL("http://vm1.mso.simpledemo.openecomp.org:8080/ecomp/mso/infra");
+* params.setMsoUsername("InfraPortalClient");
+* params.setMsoPassword("password1$");
+* params.setAaiNamedQueryUUID("f199cb88-5e69-4b1f-93e0-6f257877d066");
+* params.setAaiPatternMatch(0);
+* params.setNotificationTopic("POLICY-CL-MGT");
+* params.setAppcTopic("APPC-CL");
+* //
+* // This stays in memory as long as the rule is alive and running
+* //
+* insert(params);
+*end
+*/
+/*
+*
+* This rule responds to DCAE Events
+*
+*/
+rule "BRMSParamvLBDemoPolicy.EVENT"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 = "com";
+ notification.policyVersion = "1";
+ //
+ // 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 = "com";
+ notification.policyVersion = "1";
+ //
+ // 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 = "com";
+ notification.policyVersion = "1";
+ //
+ //
+ //
+ 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 "BRMSParamvLBDemoPolicy.EVENT.MANAGER"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 = "com";
+ notification.policyVersion = "1";
+ 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 "BRMSParamvLBDemoPolicy.EVENT.MANAGER.AAINQF199REQUEST"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 "BRMSParamvLBDemoPolicy.EVENT.MANAGER.AAINQF199RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 = "com";
+ notification.policyVersion = "1";
+ //
+ 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 = "com";
+ notification.policyVersion = "1";
+ 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 = "com";
+ notification.policyVersion = "1";
+ 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 "BRMSParamvLBDemoPolicy.APPC.RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 = "com";
+ notification.policyVersion = "1";
+ 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 "BRMSParamvLBDemoPolicy.APPC.RESPONSE.CLEANUP"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 "BRMSParamvLBDemoPolicy.MSO.RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $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 = "com";
+ notification.policyVersion = "1";
+ 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
+rule "Params"
+ salience 1000
+ when
+ then
+ Params params = new Params();
+ params.setAaiPatternMatch(0);
+ params.setAppcTopic("APPC-CL");
+ params.setAaiURL("https://aai.api.simpledemo.openecomp.org:8443");
+ params.setMsoPassword("password1$");
+ params.setClosedLoopControlName("CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8");
+ params.setAaiUsername("POLICY");
+ params.setMsoURL("http://vm1.mso.simpledemo.openecomp.org:8080/ecomp/mso/infra");
+ params.setActor("MSO");
+ params.setMsoUsername("InfraPortalClient");
+ params.setAaiNamedQueryUUID("f199cb88-5e69-4b1f-93e0-6f257877d066");
+ params.setAaiPassword("POLICY");
+ params.setNotificationTopic("POLICY-CL-MGT");
+ insert(params);
+end
diff --git a/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_MS_vFirewall.1.json b/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_MS_vFirewall.1.json
new file mode 100644
index 000000000..800c87a93
--- /dev/null
+++ b/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_MS_vFirewall.1.json
@@ -0,0 +1 @@
+{"service":"TcaMetrics","location":"SampleServiceLocation","uuid":"/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall","policyName":"vFirewall","description":"Micro Service vFirewall Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:","configName":"SampleConfigName","templateVersion":"OpenSource.version.1","version":"1.0.0.5","priority":"1","policyScope":"resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop","content":{"thresholds":[{"severity":"MAJOR","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn","thresholdValue":"300","closedLoopControlName":"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8","version":"1.0.2","direction":"LESS_OR_EQUAL"},{"severity":"CRITICAL","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn","thresholdValue":"700","closedLoopControlName":"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8","version":"1.0.2","direction":"GREATER_OR_EQUAL"}],"functionalRole":"vFirewall","name":"0"}}
diff --git a/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_MS_vLoadBalancer.1.json b/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_MS_vLoadBalancer.1.json
new file mode 100644
index 000000000..d03206fc1
--- /dev/null
+++ b/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_MS_vLoadBalancer.1.json
@@ -0,0 +1 @@
+{"service":"TcaMetrics","location":"SampleServiceLocation","uuid":"/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vLoadBalancer","policyName":"vLoadBalancer","description":"Micro Service vLoadBalancer Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:","configName":"SampleConfigName","templateVersion":"OpenSource.version.1","version":"1.0.0.5","priority":"1","policyScope":"resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop","content":{"thresholds":[{"severity":"MAJOR","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn","thresholdValue":"200","closedLoopControlName":"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8","version":"1.0.2","direction":"GREATER_OR_EQUAL"}],"functionalRole":"vLoadBalancer","name":"0"}}