aboutsummaryrefslogtreecommitdiffstats
path: root/examples/examples-onap-vcpe/src/main/resources/logic
diff options
context:
space:
mode:
Diffstat (limited to 'examples/examples-onap-vcpe/src/main/resources/logic')
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js23
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js37
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js65
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js46
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js15
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js66
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js4
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js153
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js4
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js2
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/OnsetOrAbatedStateTSL.js (renamed from examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyOnsetOrAbatedStateTSL.js)16
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyAAILookupStateTSL.js46
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyRequestAAIStateTSL.js54
13 files changed, 342 insertions, 189 deletions
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js
index bf66dbb22..cab75f6cd 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js
@@ -24,17 +24,24 @@ executor.logger.info(executor.inFields);
var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
executor.inFields.get("vnfID").toString());
-var guardDecisionAttributes = executor.subject.getOutFieldSchemaHelper("decisionAttributes").createNewInstance();
+var aaiRequest = new org.onap.policy.aai.AaiNqRequest;
+aaiRequest.setQueryParameters(new org.onap.policy.aai.AaiNqQueryParameters);
+aaiRequest.setInstanceFilters(new org.onap.policy.aai.AaiNqInstanceFilters);
-guardDecisionAttributes.put("actor", "APPC");
-guardDecisionAttributes.put("recipe", "Restart");
-guardDecisionAttributes.put("target", executor.inFields.get("vnfID").toString());
-guardDecisionAttributes.put("clname", "APEXvCPEImplementation");
+aaiRequest.getQueryParameters().setNamedQuery(new org.onap.policy.aai.AaiNqNamedQuery);
+aaiRequest.getQueryParameters().getNamedQuery().setNamedQueryUuid(executor.inFields.get("requestID"));
-executor.logger.info(guardDecisionAttributes);
+var genericVnfInstanceFilterMap = new java.util.HashMap();
+genericVnfInstanceFilterMap.put("vnf-id", vcpeClosedLoopStatus.get("AAI").get("genericVnfVnfId"));
-executor.outFields.put("decisionAttributes", guardDecisionAttributes);
-executor.outFields.put("onapName", "APEX");
+var genericVnfFilterMap = new java.util.HashMap();
+genericVnfFilterMap.put("generic-vnf", genericVnfInstanceFilterMap);
+
+aaiRequest.getInstanceFilters().getInstanceFilter().add(genericVnfFilterMap);
+
+executor.logger.info(aaiRequest);
+
+executor.outFields.put("AAINamedQueryRequest", aaiRequest);
executor.getContextAlbum("ControlLoopExecutionIDAlbum").put(executor.executionId.toString(),
executor.inFields.get("vnfID"));
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js
index 69cd03771..50961c214 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js
@@ -28,17 +28,36 @@ executor.logger.info("Continuing execution with VNF ID: " + vnfID);
var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID.toString());
executor.logger.info(vcpeClosedLoopStatus);
-var guardResult = executor.inFields.get("decision");
-
-if (guardResult === "PERMIT") {
- vcpeClosedLoopStatus.put("notification", "OPERATION: GUARD_PERMIT");
-} else if (guardResult === "DENY") {
- vcpeClosedLoopStatus.put("notification", "OPERATION: GUARD_DENY");
-} else {
- executor.message = "guard result must be either \"PERMIT\" or \"DENY\"";
- returnValue = executor.isFalse;
+var aaiResponse = executor.inFields.get("AAINamedQueryResponse");
+
+for (var iterator = aaiResponse.getInventoryResponseItems().iterator(); iterator.hasNext(); ) {
+ var responseItem = iterator.next();
+
+ if (responseItem.getModelName() != "vCPE") {
+ continue;
+ }
+
+ var aaiInfo = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewSubInstance("VCPE_AAI_Type");
+
+ aaiInfo.put("genericVnfResourceVersion", responseItem.getGenericVnf().getResourceVersion());
+ aaiInfo.put("genericVnfVnfName", responseItem.getGenericVnf().getVnfName());
+ aaiInfo.put("genericVnfProvStatus", responseItem.getGenericVnf().getProvStatus());
+ aaiInfo.put("genericVnfIsClosedLoopDisabled", responseItem.getGenericVnf().getIsClosedLoopDisabled().toString());
+ aaiInfo.put("genericVnfVnfType", responseItem.getGenericVnf().getVnfType());
+ aaiInfo.put("genericVnfInMaint", responseItem.getGenericVnf().getInMaint().toString());
+ aaiInfo.put("genericVnfServiceId", responseItem.getGenericVnf().getServiceId());
+ aaiInfo.put("genericVnfVnfId", responseItem.getGenericVnf().getVnfId());
+
+ aaiInfo.put("genericVnfOrchestrationStatus", responseItem.getVfModule().getOrchestrationStatus());
+
+ vcpeClosedLoopStatus.put("AAI", aaiInfo);
+
+ break;
}
+// We should check here for the case where AAI returns an error or no data for the query
+
+
var uuidType = Java.type("java.util.UUID");
var requestID = uuidType.fromString(vcpeClosedLoopStatus.get("requestID"));
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js
index 184340288..7d17e25bc 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js
@@ -21,55 +21,36 @@
executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
-var genericDataRecordType = Java.type("org.apache.avro.generic.GenericData.Record");
+var appcRequest = new org.onap.policy.appclcm.LcmRequestWrapper;
+appcRequest.setBody(new org.onap.policy.appclcm.LcmRequest);
+appcRequest.getBody().setCommonHeader(new org.onap.policy.appclcm.LcmCommonHeader);
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
- executor.inFields.get("vnfID").toString());
+appcRequest.setVersion("2.0.0");
+appcRequest.setRpcName("restart");
+appcRequest.setCorrelationId(executor.inFields.get("requestID"));
+appcRequest.setType("request");
-var appcBodyRecord = executor.subject.getOutFieldSchemaHelper("body").createNewInstance();
-var appcBodyRecordSchema = appcBodyRecord.getSchema();
+var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(executor.inFields.get("vnfID").toString());
-var inputRecord = new genericDataRecordType(appcBodyRecordSchema.getField("input").schema());
-var inputRecordRecordSchema = inputRecord.getSchema();
+appcRequest.getBody().getCommonHeader().setTimeStamp(java.time.Instant.now());
+appcRequest.getBody().getCommonHeader().setApiVer("2.00");
+appcRequest.getBody().getCommonHeader().setOriginatorId(executor.inFields.get("requestID").toString());
+appcRequest.getBody().getCommonHeader().setRequestId(executor.inFields.get("requestID"));
+appcRequest.getBody().getCommonHeader().setSubRequestId("1");
+appcRequest.getBody().getCommonHeader().getFlags().put("ttl", "10000");
+appcRequest.getBody().getCommonHeader().getFlags().put("force", "TRUE");
+appcRequest.getBody().getCommonHeader().getFlags().put("mode", "EXCLUSIVE");
-var actionIndentifiersRecord = new genericDataRecordType(inputRecordRecordSchema.getField("action_DasH_identifiers")
- .schema());
+appcRequest.getBody().setAction("Restart");
+appcRequest.getBody().setActionIdentifiers(new java.util.HashMap());
+appcRequest.getBody().getActionIdentifiers().put("vnf-id", executor.inFields.get("vnfID").toString());
-var commonHeaderRecord = new genericDataRecordType(inputRecordRecordSchema.getField("common_DasH_header").schema());
-var commonHeaderRecordSchema = commonHeaderRecord.getSchema();
+executor.getContextAlbum("RequestIDVNFIDAlbum").put(executor.inFields.get("requestID").toString(), executor.inFields.get("vnfID"));
-var commonHeaderFlagsRecord = new genericDataRecordType(commonHeaderRecordSchema.getField("flags").schema());
+vcpeClosedLoopStatus.put("notification", "OPERATION");
+vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis());
-appcBodyRecord.put("input", inputRecord);
-inputRecord.put("action_DasH_identifiers", actionIndentifiersRecord);
-inputRecord.put("common_DasH_header", commonHeaderRecord);
-commonHeaderRecord.put("flags", commonHeaderFlagsRecord);
-
-inputRecord.put("action", "Restart");
-inputRecord.put("payload", "{}");
-
-actionIndentifiersRecord.put("vnf_DasH_id", executor.inFields.get("vnfID").toString());
-
-commonHeaderRecord.put("timestamp", new Date().toISOString());
-commonHeaderRecord.put("api_DasH_ver", "2.00");
-commonHeaderRecord.put("originator_DasH_id", executor.inFields.get("requestID").toString());
-commonHeaderRecord.put("request_DasH_id", executor.inFields.get("requestID").toString());
-commonHeaderRecord.put("sub_DasH_request_DasH_id", "1");
-
-commonHeaderFlagsRecord.put("ttl", "10000");
-commonHeaderFlagsRecord.put("force", "TRUE");
-commonHeaderFlagsRecord.put("mode", "EXCLUSIVE");
-
-executor.outFields.put("version", "2.0");
-executor.outFields.put("rpc-name", "restart");
-executor.outFields.put("correlation-id", executor.inFields.get("vnfID"));
-executor.outFields.put("type", "request");
-executor.outFields.put("body", appcBodyRecord);
-
-executor.getContextAlbum("RequestIDVNFIDAlbum").put(executor.inFields.get("requestID").toString(),
- executor.inFields.get("vnfID"));
-
-vcpeClosedLoopStatus.put("notification", "OPERATION: RESTART REQUESTED");
+executor.outFields.put("APPCLCMRequestEvent", appcRequest);
executor.logger.info(executor.outFields);
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js
index 5e20f1569..afaa72536 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js
@@ -14,6 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
+ * APPC LCM Response code: 100 ACCEPTED
+ * 200 ERROR UNEXPECTED ERROR means failure
+ * 312 REJECTED DUPLICATE REQUEST
+ * 400 SUCCESS
+ *
+ * Note: Sometimes the corelationId has a -1 at the tail, need to get rid of it when present.
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -21,30 +28,43 @@
executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
-var uuidType = Java.type("java.util.UUID");
-var integerType = Java.type("java.lang.Integer");
+var appcResponse = executor.inFields.get("APPCLCMResponseEvent");
-var requestID = uuidType.fromString(executor.inFields.get("correlation-id"));
-var vnfID = executor.getContextAlbum("RequestIDVNFIDAlbum").remove(requestID.toString());
+var requestIDString = appcResponse.getCorrelationId().substr(0, 36);
+executor.logger.info("requestIDString = " + requestIDString);
+var vnfID = executor.getContextAlbum("RequestIDVNFIDAlbum").get(requestIDString);
+executor.logger.info("Size of RequestIDVNFIDAlbum = " + executor.getContextAlbum("RequestIDVNFIDAlbum").size());
+executor.logger.info("vnfID = " + vnfID);
var returnValue = executor.isTrue;
if (vnfID != null) {
var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID.toString());
+ var requestId = java.util.UUID.fromString(vcpeClosedLoopStatus.get("requestID"));
+
+ vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis());
- var notification = "OPERATION: VNF RESTART WITH RETURN CODE "
- + executor.inFields.get("body").get("output").get("status").get("code") + ", "
- + executor.inFields.get("body").get("output").get("status").get("message");
+ executor.logger.info("Got from APPC code: " + org.onap.policy.appclcm.LcmResponseCode.toResponseValue(appcResponse.getBody().getStatus().getCode()));
- vcpeClosedLoopStatus.put("notification", notification);
- vcpeClosedLoopStatus.put("notificationTime", executor.inFields.get("body").get("output").get("common_DasH_header")
- .get("timestamp"));
+ if (org.onap.policy.appclcm.LcmResponseCode.toResponseValue(appcResponse.getBody().getStatus().getCode()) == org.onap.policy.appclcm.LcmResponseCode.SUCCESS) {
+ vcpeClosedLoopStatus.put("notification", "OPERATION_SUCCESS");
+ vcpeClosedLoopStatus.put("message", "vCPE restarted");
+ executor.getContextAlbum("RequestIDVNFIDAlbum").remove(requestIDString);
+ } else if (org.onap.policy.appclcm.LcmResponseCode.toResponseValue(appcResponse.getBody().getStatus().getCode()) == "ACCEPTED" ||
+ org.onap.policy.appclcm.LcmResponseCode.toResponseValue(appcResponse.getBody().getStatus().getCode()) == "REJECT" ) {
+ executor.logger.info("Got ACCEPTED 100 or REJECT 312, keep the context, wait for next response. Code is: " + org.onap.policy.appclcm.LcmResponseCode.toResponseValue(appcResponse.getBody().getStatus().getCode()));
+ }
+ else {
+ executor.getContextAlbum("RequestIDVNFIDAlbum").remove(requestIDString);
+ vcpeClosedLoopStatus.put("notification", "OPERATION_FAILURE");
+ vcpeClosedLoopStatus.put("message", "vCPE restart failed");
+ }
- executor.outFields.put("requestID", requestID);
+ executor.outFields.put("requestID", requestId);
executor.outFields.put("vnfID", vnfID);
} else {
- executor.message = "VNF ID not found in context album for request ID " + requestID;
- returnValue = executor.isFalse
+ executor.message = "VNF ID not found in context album for request ID " + requestIDString;
+ returnValue = executor.isFalse;
}
executor.logger.info(executor.outFields);
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js
index a8b1fe8e4..f37b6f1b5 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js
@@ -21,11 +21,20 @@
executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
+var vcpeClosedLoopStatus = null;
+if( executor.inFields.get("vnfID") == null) {
+ executor.logger.info("AbatedTask: vnfID is null");
+ var vnfName = executor.inFields.get("vnfName");
+ vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
+ executor.inFields.get("vnfName"));
+} else {
+ vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
executor.inFields.get("vnfID").toString());
+}
-vcpeClosedLoopStatus.put("notification", "VCPE NOTIFICATION HAS BEEN ABATED");
-vcpeClosedLoopStatus.put("notificationTime", new Date().toISOString());
+vcpeClosedLoopStatus.put("notification", "FINAL_SUCCESS");
+vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis());
+vcpeClosedLoopStatus.put("message", "situation has been abated");
executor.logger.info(executor.outFields);
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js
index bceb628e2..d42aef9d0 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js
@@ -21,27 +21,51 @@
executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
- executor.inFields.get("vnfID").toString());
-
-executor.logger.info("Logging context information for VNF \"" + executor.inFields.get("vnfID") + "\"");
-
-executor.outFields.put("AAI", vcpeClosedLoopStatus.get("AAI"));
-executor.outFields.put("closedLoopControlName", vcpeClosedLoopStatus.get("closedLoopControlName"));
-executor.outFields.put("closedLoopAlarmStart", vcpeClosedLoopStatus.get("closedLoopAlarmStart"));
-executor.outFields.put("closedLoopAlarmEnd", vcpeClosedLoopStatus.get("closedLoopAlarmEnd"));
-executor.outFields.put("closedLoopEventClient", vcpeClosedLoopStatus.get("closedLoopEventClient"));
-executor.outFields.put("closedLoopEventStatus", vcpeClosedLoopStatus.get("closedLoopEventStatus"));
-executor.outFields.put("version", vcpeClosedLoopStatus.get("version"));
-executor.outFields.put("requestID", vcpeClosedLoopStatus.get("requestID"));
-executor.outFields.put("target_type", vcpeClosedLoopStatus.get("target_type"));
-executor.outFields.put("target", vcpeClosedLoopStatus.get("target"));
-executor.outFields.put("from", vcpeClosedLoopStatus.get("from"));
-executor.outFields.put("policyScope", vcpeClosedLoopStatus.get("policyScope"));
-executor.outFields.put("policyName", vcpeClosedLoopStatus.get("policyName"));
-executor.outFields.put("policyVersion", vcpeClosedLoopStatus.get("policyVersion"));
-executor.outFields.put("notification", vcpeClosedLoopStatus.get("notification"));
-executor.outFields.put("notificationTime", vcpeClosedLoopStatus.get("notificationTime"));
+var vnfID = executor.inFields.get("vnfID");
+if(vnfID == null) {
+ vnfID = executor.inFields.get("vnfName");
+}
+executor.logger.info("vnfID=" + vnfID);
+
+var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID.toString());
+
+executor.logger.info("Logging context information for VNF \"" + vnfID + "\"");
+
+var clNotification = new org.onap.policy.controlloop.VirtualControlLoopNotification();
+
+clNotification.setClosedLoopControlName(vcpeClosedLoopStatus.get("closedLoopControlName"));
+clNotification.setClosedLoopAlarmStart(java.time.Instant.ofEpochMilli(vcpeClosedLoopStatus.get("closedLoopAlarmStart")));
+clNotification.setClosedLoopAlarmEnd(java.time.Instant.ofEpochMilli(vcpeClosedLoopStatus.get("closedLoopAlarmEnd")));
+clNotification.setClosedLoopEventClient(vcpeClosedLoopStatus.get("closedLoopEventClient"));
+clNotification.setVersion(vcpeClosedLoopStatus.get("version"));
+clNotification.setRequestId(java.util.UUID.fromString(vcpeClosedLoopStatus.get("requestID")));
+clNotification.setTargetType(org.onap.policy.controlloop.ControlLoopTargetType.toType(vcpeClosedLoopStatus.get("target_type")));
+clNotification.setTarget(org.onap.policy.controlloop.ControlLoopEventStatus.toStatus(vcpeClosedLoopStatus.get("target")));
+clNotification.setFrom(vcpeClosedLoopStatus.get("from"));
+clNotification.setPolicyScope(vcpeClosedLoopStatus.get("policyScope"));
+clNotification.setPolicyName(vcpeClosedLoopStatus.get("policyName"));
+clNotification.setPolicyVersion(vcpeClosedLoopStatus.get("policyVersion"));
+clNotification.setNotification(org.onap.policy.controlloop.ControlLoopNotificationType.toType(vcpeClosedLoopStatus.get("notification")));
+clNotification.setMessage(vcpeClosedLoopStatus.get("message"));
+
+var notificationInstant = java.time.Instant.ofEpochSecond(vcpeClosedLoopStatus.get("notificationTime"));
+var notificationTime = java.time.ZonedDateTime.ofInstant(notificationInstant, java.time.ZoneOffset.UTC);
+clNotification.setNotificationTime(notificationTime);
+
+var aaiInfo = vcpeClosedLoopStatus.get("AAI");
+
+clNotification.getAai().put("generic-vnf.resource-version", aaiInfo.get("genericVnfResourceVersion"));
+clNotification.getAai().put("generic-vnf.vnf-name", aaiInfo.get("genericVnfVnfName"));
+clNotification.getAai().put("generic-vnf.prov-status", aaiInfo.get("genericVnfProvStatus"));
+clNotification.getAai().put("generic-vnf.is-closed-loop-disabled", aaiInfo.get("genericVnfIsClosedLoopDisabled"));
+clNotification.getAai().put("generic-vnf.orchestration-status", aaiInfo.get("genericVnfOrchestrationStatus"));
+clNotification.getAai().put("generic-vnf.vnf-type", aaiInfo.get("genericVnfVnfType"));
+clNotification.getAai().put("generic-vnf.in-maint", aaiInfo.get("genericVnfInMaint"));
+clNotification.getAai().put("generic-vnf.service-id", aaiInfo.get("genericVnfServiceId"));
+if(vnfID != null) {
+ clNotification.getAai().put("generic-vnf.vnf-id", aaiInfo.get("genericVnfVnfId"));
+}
+executor.outFields.put("VirtualControlLoopNotification", clNotification);
executor.logger.info(executor.outFields);
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js
index 4ee73750d..353c21ef6 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js
@@ -24,8 +24,8 @@ executor.logger.info(executor.inFields);
var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
executor.inFields.get("vnfID").toString());
-vcpeClosedLoopStatus.put("notification", "VCPE VNF RESTART HAS BEEN DENIED BY GUARD");
-vcpeClosedLoopStatus.put("notificationTime", new Date().toISOString());
+vcpeClosedLoopStatus.put("notification", "REJECTED");
+vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis());
executor.logger.info(executor.outFields);
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js
index 18bd418bf..0ba3c0985 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js
@@ -14,6 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
+ * Note: The incoming closedloop message can be ONSET with both VNF-name and VNF-ID
+ * or ABATED with only VNF-name. So need to handle differently. For ABATED case,
+ * since we still keep the RequireIDVNFID context album, we can get it from there.
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -21,49 +25,122 @@
executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
-var uuidType = Java.type("java.util.UUID");
+var clEventType = Java.type("org.onap.policy.controlloop.VirtualControlLoopEvent");
var longType = Java.type("java.lang.Long");
+var uuidType = Java.type("java.util.UUID");
-var requestID = uuidType.fromString(executor.inFields.get("requestID"));
-var vnfID = uuidType.fromString(executor.inFields.get("AAI").get("generic_DasH_vnf_DoT_vnf_DasH_id"));
-
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID);
-
-if (vcpeClosedLoopStatus == null) {
- executor.logger.info("Creating context information for new vCPE VNF \"" + vnfID.toString() + "\"");
-
- vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewInstance();
-
- vcpeClosedLoopStatus.put("AAI", executor.inFields.get("AAI"));
- vcpeClosedLoopStatus.put("closedLoopControlName", executor.inFields.get("closedLoopControlName"));
- vcpeClosedLoopStatus.put("closedLoopAlarmStart", executor.inFields.get("closedLoopAlarmStart"));
- vcpeClosedLoopStatus.put("closedLoopEventClient", executor.inFields.get("closedLoopEventClient"));
- vcpeClosedLoopStatus.put("closedLoopEventStatus", executor.inFields.get("closedLoopEventStatus"));
- vcpeClosedLoopStatus.put("version", executor.inFields.get("version"));
- vcpeClosedLoopStatus.put("requestID", executor.inFields.get("requestID"));
- vcpeClosedLoopStatus.put("target_type", executor.inFields.get("target_type"));
- vcpeClosedLoopStatus.put("target", executor.inFields.get("target"));
- vcpeClosedLoopStatus.put("from", executor.inFields.get("from"));
- vcpeClosedLoopStatus.put("policyScope", "vCPE");
- vcpeClosedLoopStatus.put("policyName", "ONAPvCPEPolicyModel");
- vcpeClosedLoopStatus.put("policyVersion", "0.0.1");
- vcpeClosedLoopStatus.put("notification", "");
- vcpeClosedLoopStatus.put("notificationTime", "");
-
- if (executor.inFields.get("closedLoopAlarmEnd") != null) {
- vcpeClosedLoopStatus.put("closedLoopAlarmEnd", executor.inFields.get("closedLoopAlarmEnd"));
- } else {
- vcpeClosedLoopStatus.put("closedLoopAlarmEnd", longType.valueOf(0));
- }
+var clEvent = executor.inFields.get("VirtualControlLoopEvent");
- executor.getContextAlbum("VCPEClosedLoopStatusAlbum").put(vnfID.toString(), vcpeClosedLoopStatus);
+executor.logger.info(clEvent.toString());
+executor.logger.info(clEvent.getClosedLoopControlName());
- executor.logger.info("Created context information for new vCPE VNF \"" + vnfID.toString() + "\"");
-}
+var requestID = clEvent.getRequestId();
+executor.logger.info("requestID = " + requestID);
+var vnfID = null;
+var vcpeClosedLoopStatus = null;
+
+if (clEvent.getAai().get("generic-vnf.vnf-id") != null) {
+ vnfID = uuidType.fromString(clEvent.getAai().get("generic-vnf.vnf-id"));
+ executor.logger.info("vnfID = " + vnfID);
+ vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID);
+
+ if (vcpeClosedLoopStatus == null) {
+ executor.logger.info("Creating context information for new vCPE VNF \"" + vnfID.toString() + "\"");
+
+ vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewInstance();
+
+ vcpeClosedLoopStatus.put("closedLoopControlName", clEvent.getClosedLoopControlName());
+ vcpeClosedLoopStatus.put("closedLoopAlarmStart", clEvent.getClosedLoopAlarmStart().toEpochMilli());
+ vcpeClosedLoopStatus.put("closedLoopEventClient", clEvent.getClosedLoopEventClient());
+ vcpeClosedLoopStatus.put("closedLoopEventStatus", clEvent.getClosedLoopEventStatus().toString());
+ vcpeClosedLoopStatus.put("version", clEvent.getVersion());
+ vcpeClosedLoopStatus.put("requestID", clEvent.getRequestId().toString());
+ vcpeClosedLoopStatus.put("target_type", clEvent.getTargetType().toString());
+ vcpeClosedLoopStatus.put("target", clEvent.getTarget());
+ vcpeClosedLoopStatus.put("from", clEvent.getFrom());
+ vcpeClosedLoopStatus.put("policyScope", "vCPE");
+ vcpeClosedLoopStatus.put("policyName", "ONAPvCPEPolicyModel");
+ vcpeClosedLoopStatus.put("policyVersion", "0.0.1");
+ vcpeClosedLoopStatus.put("notification", "ACTIVE");
+ vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis());
+ vcpeClosedLoopStatus.put("message", "");
-executor.outFields.put("requestID", requestID);
-executor.outFields.put("vnfID", vnfID);
+ var aaiInfo = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewSubInstance("VCPE_AAI_Type");
-executor.logger.info(executor.outFields);
+ aaiInfo.put("genericVnfResourceVersion", clEvent.getAai().get("generic-vnf.resource-version"));
+ aaiInfo.put("genericVnfVnfName", clEvent.getAai().get("generic-vnf.vnf-name"));
+ aaiInfo.put("genericVnfProvStatus", clEvent.getAai().get("generic-vnf.prov-status"));
+ aaiInfo.put("genericVnfIsClosedLoopDisabled", clEvent.getAai().get("generic-vnf.is-closed-loop-disabled"));
+ aaiInfo.put("genericVnfOrchestrationStatus", clEvent.getAai().get("generic-vnf.orchestration-status"));
+ aaiInfo.put("genericVnfVnfType", clEvent.getAai().get("generic-vnf.vnf-type"));
+ aaiInfo.put("genericVnfInMaint", clEvent.getAai().get("generic-vnf.in-maint"));
+ aaiInfo.put("genericVnfServiceId", clEvent.getAai().get("generic-vnf.service-id"));
+ aaiInfo.put("genericVnfVnfId", clEvent.getAai().get("generic-vnf.vnf-id"));
+
+ vcpeClosedLoopStatus.put("AAI", aaiInfo);
+
+ if (clEvent.getClosedLoopAlarmEnd() != null) {
+ vcpeClosedLoopStatus.put("closedLoopAlarmEnd", clEvent.getClosedLoopAlarmEnd().toEpochMilli());
+ } else {
+ vcpeClosedLoopStatus.put("closedLoopAlarmEnd", java.lang.Long.valueOf(0));
+ }
+
+ executor.getContextAlbum("VCPEClosedLoopStatusAlbum").put(vnfID.toString(), vcpeClosedLoopStatus);
+
+ executor.logger.info("Created context information for new vCPE VNF \"" + vnfID.toString() + "\"");
+ }
+
+ executor.outFields.put("requestID", requestID);
+ executor.outFields.put("vnfID", vnfID);
+
+ executor.logger.info(executor.outFields);
+}
+else {
+ executor.logger.info("No vnf-id in VirtualControlLoopEvent, status:" + clEvent.getClosedLoopEventStatus().toString());
+ var vnfName = clEvent.getAai().get("generic-vnf.vnf-name");
+ executor.logger.info("No vnf-id in VirtualControlLoopEvent for " + vnfName);
+
+ vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfName.toString());
+
+ if (vcpeClosedLoopStatus == null) {
+ executor.logger.info("Creating context information for new vCPE VNF \"" + vnfName.toString() + "\"");
+
+ vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewInstance();
+
+ vcpeClosedLoopStatus.put("closedLoopControlName", clEvent.getClosedLoopControlName());
+ vcpeClosedLoopStatus.put("closedLoopAlarmStart", clEvent.getClosedLoopAlarmStart().toEpochMilli());
+ vcpeClosedLoopStatus.put("closedLoopEventClient", clEvent.getClosedLoopEventClient());
+ vcpeClosedLoopStatus.put("closedLoopEventStatus", clEvent.getClosedLoopEventStatus().toString());
+ vcpeClosedLoopStatus.put("version", clEvent.getVersion());
+ vcpeClosedLoopStatus.put("requestID", clEvent.getRequestId().toString());
+ vcpeClosedLoopStatus.put("target_type", clEvent.getTargetType().toString());
+ vcpeClosedLoopStatus.put("target", clEvent.getTarget());
+ vcpeClosedLoopStatus.put("from", clEvent.getFrom());
+ vcpeClosedLoopStatus.put("policyScope", "vCPE");
+ vcpeClosedLoopStatus.put("policyName", "ONAPvCPEPolicyModel");
+ vcpeClosedLoopStatus.put("policyVersion", "0.0.1");
+ vcpeClosedLoopStatus.put("notification", "ACTIVE");
+ vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis());
+ vcpeClosedLoopStatus.put("message", "");
+
+ var aaiInfo = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewSubInstance("VCPE_AAI_Type");
+
+ aaiInfo.put("genericVnfVnfName", clEvent.getAai().get("generic-vnf.vnf-name"));
+ vcpeClosedLoopStatus.put("AAI", aaiInfo);
+
+ if (clEvent.getClosedLoopAlarmEnd() != null) {
+ vcpeClosedLoopStatus.put("closedLoopAlarmEnd", clEvent.getClosedLoopAlarmEnd().toEpochMilli());
+ } else {
+ vcpeClosedLoopStatus.put("closedLoopAlarmEnd", java.lang.Long.valueOf(0));
+ }
+
+ executor.getContextAlbum("VCPEClosedLoopStatusAlbum").put(vnfName.toString(), vcpeClosedLoopStatus);
+
+ executor.logger.info("Created context information for new vCPE VNF \"" + vnfName.toString() + "\"");
+ }
+ executor.outFields.put("requestID", requestID);
+ executor.outFields.put("vnfName", vnfName);
+ executor.logger.info(executor.outFields);
+}
returnValue = executor.isTrue;
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js
index bf66dbb22..d247f8a65 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js
@@ -34,11 +34,11 @@ guardDecisionAttributes.put("clname", "APEXvCPEImplementation");
executor.logger.info(guardDecisionAttributes);
executor.outFields.put("decisionAttributes", guardDecisionAttributes);
-executor.outFields.put("onapName", "APEX");
+executor.outFields.put("onapName", "PDPD");
executor.getContextAlbum("ControlLoopExecutionIDAlbum").put(executor.executionId.toString(),
executor.inFields.get("vnfID"));
executor.logger.info(executor.outFields);
-var returnValue = executor.isTrue; \ No newline at end of file
+var returnValue = executor.isTrue;
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js
index 69cd03771..2a9100b7f 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js
@@ -36,7 +36,7 @@ if (guardResult === "PERMIT") {
vcpeClosedLoopStatus.put("notification", "OPERATION: GUARD_DENY");
} else {
executor.message = "guard result must be either \"PERMIT\" or \"DENY\"";
- returnValue = executor.isFalse;
+ returnValue = executor.FALSE;
}
var uuidType = Java.type("java.util.UUID");
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyOnsetOrAbatedStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/OnsetOrAbatedStateTSL.js
index b97fe5a0c..c8a3bfba8 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyOnsetOrAbatedStateTSL.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/OnsetOrAbatedStateTSL.js
@@ -22,11 +22,19 @@ executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
var returnValue = executor.isTrue;
+var status = null;
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
+if( executor.inFields.get("vnfID") == null) {
+ executor.logger.info("OnsetOrAbatedStateTSL: vnfID is null");
+ var vnfName = executor.inFields.get("vnfName");
+ var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
+ executor.inFields.get("vnfName"));
+ status = vcpeClosedLoopStatus.get("closedLoopEventStatus").toString();
+} else {
+ var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
executor.inFields.get("vnfID").toString());
-
-var status = vcpeClosedLoopStatus.get("closedLoopEventStatus");
+ status = vcpeClosedLoopStatus.get("closedLoopEventStatus").toString();
+}
var returnValue = executor.isTrue;
@@ -36,7 +44,7 @@ if (status === "ONSET") {
executor.subject.getTaskKey("AbatedTask").copyTo(executor.selectedTask);
onsetFlag = executor.isFalse;
} else {
- executor.message = "closedLoopEventStatus must be either \"ONSET\" or \"ABATED\"";
+ executor.message = "closedLoopEventStatus is \"" + status + "\", it must be either \"ONSET\" or \"ABATED\"";
returnValue = executor.isFalse;
}
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyAAILookupStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyAAILookupStateTSL.js
deleted file mode 100644
index ce627950c..000000000
--- a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyAAILookupStateTSL.js
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-executor.logger.info(executor.subject.id);
-executor.logger.info(executor.inFields);
-
-var returnValue = executor.isTrue;
-
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
- executor.inFields.get("vnfID").toString());
-var aaiInfo = vcpeClosedLoopStatus.get("AAI");
-
-executor.logger.info(aaiInfo);
-
-if (aaiInfo.get("generic_DasH_vnf.resource_DasH_version") != null
- && aaiInfo.get("generic_DasH_vnf.vnf_DasH_name") != null
- && aaiInfo.get("generic_DasH_vnf.prov_DasH_status") != null
- && aaiInfo.get("generic_DasH_vnf.is_DasH_closed_DasH_loop_DasH_disabled") != null
- && aaiInfo.get("generic_DasH_vnf.orchestration_DasH_status") != null
- && aaiInfo.get("generic_DasH_vnf.vnf_DasH_type") != null
- && aaiInfo.get("generic_DasH_vnf.in_DasH_maint") != null
- && aaiInfo.get("generic_DasH_vnf.service_DasH_id") != null
- && aaiInfo.get("generic_DasH_vnf.vnf_DasH_id") != null) {
- executor.subject.getTaskKey("AAILookupRequestTask").copyTo(executor.selectedTask);
-} else {
- executor.subject.getTaskKey("NoAAILookupTask").copyTo(executor.selectedTask);
-}
-
-executor.logger.info("ReceiveEventPolicyOnsetOrAbatedStateTSL State Selected Task:" + executor.selectedTask);
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyRequestAAIStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyRequestAAIStateTSL.js
new file mode 100644
index 000000000..b397a5f7c
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyRequestAAIStateTSL.js
@@ -0,0 +1,54 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+executor.logger.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+
+var returnValue = executor.isTrue;
+
+if( executor.inFields.get("vnfID") == null) {
+ executor.logger.info("ReceiveEventPolicyRequestAAIStateTSL: vnfID is null");
+ var vnfName = executor.inFields.get("vnfName");
+ var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
+ executor.inFields.get("vnfName"));
+ executor.logger.info("CL event status: " + vcpeClosedLoopStatus.get("closedLoopEventStatus"));
+ executor.subject.getTaskKey("NoAAILookupTask").copyTo(executor.selectedTask);
+ } else {
+ var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
+ executor.inFields.get("vnfID").toString());
+ var aaiInfo = vcpeClosedLoopStatus.get("AAI");
+
+ executor.logger.info(aaiInfo);
+
+ if (aaiInfo.get("genericVnfResourceVersion") != null
+ && aaiInfo.get("genericVnfVnfName") != null
+ && aaiInfo.get("genericVnfProvStatus") != null
+ && aaiInfo.get("genericVnfIsClosedLoopDisabled") != null
+ && aaiInfo.get("genericVnfOrchestrationStatus") != null
+ && aaiInfo.get("genericVnfVnfType") != null
+ && aaiInfo.get("genericVnfInMaint") != null
+ && aaiInfo.get("genericVnfServiceId") != null
+ && aaiInfo.get("genericVnfVnfId") != null) {
+ executor.subject.getTaskKey("NoAAILookupTask").copyTo(executor.selectedTask);
+ } else {
+ executor.subject.getTaskKey("AAILookupRequestTask").copyTo(executor.selectedTask);
+ }
+}
+executor.logger.info("ReceiveEventPolicyOnsetOrAbatedStateTSL State Selected Task:" + executor.selectedTask);