aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/templates
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/templates')
-rw-r--r--controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/pom.xml10
-rw-r--r--controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/vPCI.pcims.onset.json18
-rw-r--r--controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/vPCI.sdnr.success.json23
-rw-r--r--controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl114
-rw-r--r--controlloop/templates/template.demo/pom.xml12
5 files changed, 177 insertions, 0 deletions
diff --git a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/pom.xml b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/pom.xml
index 1fc31bae2..e458ae963 100644
--- a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/pom.xml
+++ b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/pom.xml
@@ -60,6 +60,11 @@
</dependency>
<dependency>
<groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId>
+ <artifactId>sdnr</artifactId>
+ <version>${dependenciesVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId>
<artifactId>appclcm</artifactId>
<version>${dependenciesVersion}</version>
</dependency>
@@ -110,6 +115,11 @@
</dependency>
<dependency>
<groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId>
+ <artifactId>actor.sdnr</artifactId>
+ <version>${dependenciesVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId>
<artifactId>actor.appclcm</artifactId>
<version>${dependenciesVersion}</version>
</dependency>
diff --git a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/vPCI.pcims.onset.json b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/vPCI.pcims.onset.json
new file mode 100644
index 000000000..0e67d3251
--- /dev/null
+++ b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/vPCI.pcims.onset.json
@@ -0,0 +1,18 @@
+{
+ "closedLoopControlName": "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459",
+ "closedLoopAlarmStart": 1510187409180,
+ "closedLoopEventClient": "microservice.PCI",
+ "closedLoopEventStatus": "ONSET",
+ "requestID": "9d2d790e-a5f0-11e8-98d0-529269fb1459",
+ "target_type": "VNF",
+ "target": "generic-vnf.vnf-id",
+ "AAI": {
+ "generic-vnf.is-closed-loop-disabled": "false",
+ "generic-vnf.prov-status": "ACTIVE",
+ "generic-vnf.vnf-id": "notused"
+ },
+ "from": "PCIMS",
+ "version": "1.0.2",
+ "Action": "ModifyConfig",
+ "payload": "{ \"Configurations\":[ { \"data\":{ \"FAPService\":{ \"alias\":\"Cell1\", \"X0005b9Lte\" : { \"PhyCellIdInUse\" : \"35\", \"PnfName\" : \"cu1\" }, \"CellConfig\":{ \"LTE\":{ \"RAN\":{ \"Common\":{ \"CellIdentity\":\"1\" } } } } } } } ] }"
+}
diff --git a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/vPCI.sdnr.success.json b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/vPCI.sdnr.success.json
new file mode 100644
index 000000000..74d7f60bb
--- /dev/null
+++ b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/vPCI.sdnr.success.json
@@ -0,0 +1,23 @@
+{
+ "body": {
+ "output": {
+ "CommonHeader": {
+ "TimeStamp": "2018-09-10T07:10:05.614Z",
+ "APIver": "1.0",
+ "RequestID": "9d2d790e-a5f0-11e8-98d0-529269fb1459",
+ "SubRequestID": "1",
+ "RequestTrack": [],
+ "Flags": []
+ },
+ "Status": {
+ "Code": 200,
+ "Value": "SUCCESS"
+ },
+ "Payload": "{ \"Configurations\":[ { \"Status\": { \"Code\": 200, \"Value\": \"SUCCESS\" }, \"data\":{ \"FAPService\":{ \"alias\":\"Network1\", \"X0005b9Lte\" : { \"PnfName\" : \"cu1\" }, \"CellConfig\":{ \"LTE\":{ \"RAN\":{ \"Common\":{ \"CellIdentity\":\"1\" } } } } } } } ] }"
+ }
+ },
+ "version": "1.0",
+ "rpc-name": "ModifyConfig",
+ "correlation-id": "9d2d790e-a5f0-11e8-98d0-529269fb1459-1",
+ "type": "response"
+}
diff --git a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index 0352dec10..24f70cdd9 100644
--- a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -42,6 +42,10 @@ import org.onap.policy.appclcm.LcmResponseWrapper;
import org.onap.policy.appclcm.LcmRequest;
import org.onap.policy.appclcm.LcmResponse;
import org.onap.policy.appclcm.LcmCommonHeader;
+import org.onap.policy.sdnr.PciRequestWrapper;
+import org.onap.policy.sdnr.PciResponseWrapper;
+import org.onap.policy.sdnr.PciRequest;
+import org.onap.policy.sdnr.PciResponse;
import org.onap.policy.vfc.VFCRequest;
import org.onap.policy.vfc.VFCResponse;
import org.onap.policy.vfc.VFCManager;
@@ -535,6 +539,11 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
t.start();
}
break;
+ case "SDNR":
+ if (request instanceof PciRequestWrapper) {
+ PolicyEngine.manager.deliver("SDNR-CL", request);
+ }
+ break;
}
} else {
//
@@ -1268,3 +1277,108 @@ rule "EVENT.CLEANUP"
retract($event);
end
+
+/*
+*
+* This rule responds to SDNR Response Events.
+*
+*/
+rule "SDNR.RESPONSE"
+ when
+ $params : ControlLoopParams( $clName : getClosedLoopControlName() )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $response : PciResponseWrapper( getBody().getCommonHeader().getRequestId() == $event.getRequestId() )
+ then
+
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ logger.info("{}: {}", $clName, $params.getPolicyName() + "." + drools.getRule().getName());
+ logger.debug("{}: {}: event={} manager={} operation={} lock={} opTimer={} response={}",
+ $clName, $params.getPolicyName() + "." + drools.getRule().getName(),
+ $event, $manager, $operation, $lock, $operation, $opTimer, $response);
+
+ //
+ // Get the result of the operation
+ //
+ PolicyResult policyResult = $operation.onResponse($response);
+ if (policyResult != null) {
+ logger.debug("{}: {}: operation finished - result={}",
+ $clName, $params.getPolicyName() + "." + drools.getRule().getName(),
+ policyResult);
+
+ //
+ // This Operation has completed, construct a notification showing our results. (DB write - end operation)
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.setFrom("policy");
+ notification.setPolicyName($params.getPolicyName() + "." + drools.getRule().getName());
+ notification.setPolicyScope($params.getPolicyScope());
+ notification.setPolicyVersion($params.getPolicyVersion());
+ notification.setMessage($operation.getOperationHistory());
+ notification.setHistory($operation.getHistory());
+ if (policyResult.equals(PolicyResult.SUCCESS)) {
+ notification.setNotification(ControlLoopNotificationType.OPERATION_SUCCESS);
+ } else {
+ notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
+ }
+ PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ //
+ // Ensure the operation is complete
+ //
+ if ($operation.isOperationComplete() == true) {
+ //
+ // It is complete, remove it from memory
+ //
+ retract($operation);
+ //
+ // We must also retract the timer object
+ // NOTE: We could write a Rule to do this
+ //
+ retract($opTimer);
+ //
+ // Complete the operation
+ //
+ modify($manager) {finishOperation($operation)};
+ } else {
+ //
+ // Just doing this will kick off the LOCKED rule again
+ //
+ modify($operation) {};
+ }
+ } else {
+ //
+ // Its not finished yet (i.e. expecting more Response objects)
+ //
+ // Or possibly it is a leftover response that we timed the request out previously
+ //
+ }
+ //
+ // We are going to retract these objects from memory
+ //
+ retract($response);
+end
+
+/*
+*
+* Clean Up any lingering SDNR reponses.
+*
+*/
+rule "SDNR.RESPONSE.CLEANUP"
+ when
+ $params : ControlLoopParams( $clName : getClosedLoopControlName() )
+ $response : PciResponseWrapper($id : getBody().getCommonHeader().getRequestId )
+ not ( VirtualControlLoopEvent( requestId == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) )
+ then
+
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ logger.info("{}: {}", $clName, $params.getPolicyName() + "." + drools.getRule().getName());
+ logger.debug("{}: {}: orphan sdnr response={}",
+ $clName, $params.getPolicyName() + "." + drools.getRule().getName(), $id);
+ //
+ // Retract it
+ //
+ retract($response);
+end
diff --git a/controlloop/templates/template.demo/pom.xml b/controlloop/templates/template.demo/pom.xml
index c793d97f6..6b1302240 100644
--- a/controlloop/templates/template.demo/pom.xml
+++ b/controlloop/templates/template.demo/pom.xml
@@ -68,6 +68,12 @@
</dependency>
<dependency>
<groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId>
+ <artifactId>sdnr</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId>
<artifactId>appclcm</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
@@ -166,6 +172,12 @@
</dependency>
<dependency>
<groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId>
+ <artifactId>actor.sdnr</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId>
<artifactId>actor.appclcm</artifactId>
<version>${project.version}</version>
<scope>provided</scope>