summaryrefslogtreecommitdiffstats
path: root/examples/examples-onap-vcpe/src/main/resources/logic/definitive
diff options
context:
space:
mode:
Diffstat (limited to 'examples/examples-onap-vcpe/src/main/resources/logic/definitive')
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/definitive/AAILookupTask.js85
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFRequestTask.js67
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFResponseTask.js88
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/definitive/AbatedTask.js41
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/definitive/ControlLoopLogTask.js73
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/definitive/DeniedTask.js32
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/definitive/GetVCPEStateTask.js149
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardRequestTask.js44
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardResponseTask.js50
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/definitive/NoAAILookupTask.js26
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/definitive/OnsetOrAbatedStateTSL.js51
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/definitive/RestartAPPCRequestPolicyPermitOrDenyTSL.js37
12 files changed, 743 insertions, 0 deletions
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AAILookupTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AAILookupTask.js
new file mode 100644
index 000000000..fcb39052d
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AAILookupTask.js
@@ -0,0 +1,85 @@
+/*
+ * ============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 vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
+ executor.inFields.get("vnfID").toString());
+
+executor.logger.info("Executing A&AI Lookup");
+executor.logger.info(vcpeClosedLoopStatus);
+
+var aaiInfo = vcpeClosedLoopStatus.get("AAI");
+
+if (aaiInfo.get("vserverName") == null) {
+ executor.message = "the field vserver.vserver-name must exist in the onset control loop event";
+ executor.logger.warn(executor.message);
+ var returnValue = executor.isFalse;
+}
+else if (aaiInfo.get("genericVnfVnfId") == null && aaiInfo.get("genericVnfVnfName") == null) {
+ executor.message = "either the field generic-vnf.vnf-id or generic-vnf.vnf-name must exist"
+ + " in the onset control loop event";
+ executor.logger.warn(executor.message);
+ var returnValue = executor.isFalse;
+}
+else {
+ var restManager = new org.onap.policy.rest.RestManager;
+ var aaiManager = new org.onap.policy.aai.AaiManager(restManager);
+
+ // We need to instantiate the type in order to trigger the static JAXB handling
+ // in the AaiCqResponse class
+ var aaiCqResponseType = Java.type("org.onap.policy.aai.AaiCqResponse");
+
+ var aaiResponse = aaiManager.getCustomQueryResponse(
+ "http://localhost:54321/OnapVCpeSim/sim",
+ "aai.username",
+ "aai.password",
+ executor.inFields.get("requestID"),
+ vcpeClosedLoopStatus.get("AAI").get("vserverName")
+ );
+
+ var genericVnf;
+
+ if (aaiInfo.get("genericVnfVnfId") != null) {
+ genericVnf = aaiResponse.getGenericVnfByModelInvariantId(aaiInfo.get("genericVnfVnfId"));
+ }
+ else {
+ genericVnf = aaiResponse.getGenericVnfByVnfName(aaiInfo.get("genericVnfVnfId"));
+ }
+
+ aaiInfo.put("genericVnfResourceVersion", genericVnf.getResourceVersion());
+ aaiInfo.put("genericVnfVnfName", genericVnf.getVnfName());
+ aaiInfo.put("genericVnfProvStatus", genericVnf.getProvStatus());
+ aaiInfo.put("genericVnfIsClosedLoopDisabled", genericVnf.isIsClosedLoopDisabled().toString());
+ aaiInfo.put("genericVnfVnfType", genericVnf.getVnfType());
+ aaiInfo.put("genericVnfInMaint", genericVnf.isInMaint().toString());
+ aaiInfo.put("genericVnfServiceId", genericVnf.getServiceId());
+ aaiInfo.put("genericVnfVnfId", genericVnf.getVnfId());
+ aaiInfo.put("genericVnfOrchestrationStatus",
+ genericVnf.getVfModules().getVfModule().get(0).getOrchestrationStatus());
+
+ executor.outFields.put("requestID", executor.inFields.get("requestID"));
+ executor.outFields.put("vnfID", executor.inFields.get("vnfID"));
+
+ executor.logger.info(executor.outFields);
+
+ var returnValue = executor.isTrue;
+}
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFRequestTask.js
new file mode 100644
index 000000000..dd69dcb1d
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFRequestTask.js
@@ -0,0 +1,67 @@
+/*
+ * ============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 appcRequest = new org.onap.policy.appclcm.AppcLcmDmaapWrapper;
+appcRequest.setBody(new org.onap.policy.appclcm.AppcLcmBody);
+appcRequest.getBody().setInput(new org.onap.policy.appclcm.AppcLcmInput);
+appcRequest.getBody().getInput().setCommonHeader(
+ new org.onap.policy.appclcm.AppcLcmCommonHeader);
+
+appcRequest.setVersion("2.0.0");
+appcRequest.setRpcName("restart");
+appcRequest.setCorrelationId(executor.inFields.get("requestID"));
+appcRequest.setType("request");
+
+var vcpeClosedLoopStatus = executor
+ .getContextAlbum("VCPEClosedLoopStatusAlbum").get(
+ executor.inFields.get("vnfID").toString());
+
+appcRequest.getBody().getInput().getCommonHeader().setTimeStamp(java.time.Instant.now());
+appcRequest.getBody().getInput().getCommonHeader().setApiVer("2.00");
+appcRequest.getBody().getInput().getCommonHeader().setOriginatorId(
+ executor.inFields.get("requestID").toString());
+appcRequest.getBody().getInput().getCommonHeader().setRequestId(
+ executor.inFields.get("requestID"));
+appcRequest.getBody().getInput().getCommonHeader().setSubRequestId("1");
+appcRequest.getBody().getInput().getCommonHeader().getFlags().put("ttl", "10000");
+appcRequest.getBody().getInput().getCommonHeader().getFlags().put("force", "TRUE");
+appcRequest.getBody().getInput().getCommonHeader().getFlags().put("mode", "EXCLUSIVE");
+
+appcRequest.getBody().getInput().setAction("Restart");
+appcRequest.getBody().getInput().setActionIdentifiers(new java.util.HashMap());
+appcRequest.getBody().getInput().getActionIdentifiers().put("vnf-id",
+ executor.inFields.get("vnfID").toString());
+
+executor.getContextAlbum("RequestIDVNFIDAlbum").put(
+ executor.inFields.get("requestID").toString(),
+ executor.inFields.get("vnfID"));
+
+vcpeClosedLoopStatus.put("notification", "OPERATION");
+vcpeClosedLoopStatus.put("notificationTime", java.lang.System
+ .currentTimeMillis());
+
+executor.outFields.put("APPCLCMRequestEvent", appcRequest);
+
+executor.logger.info(executor.outFields);
+
+var returnValue = executor.isTrue;
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFResponseTask.js
new file mode 100644
index 000000000..75ab6a3af
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFResponseTask.js
@@ -0,0 +1,88 @@
+/*
+ * ============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.
+ *
+ * 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=========================================================
+ */
+
+executor.logger.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+
+var appcResponse = executor.inFields.get("APPCLCMResponseEvent");
+
+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());
+
+ executor.logger.info("Got from APPC code: "
+ + org.onap.policy.appclcm.AppcLcmResponseCode
+ .toResponseValue(appcResponse.getBody().getOutput()
+ .getStatus().getCode()));
+
+ if (org.onap.policy.appclcm.AppcLcmResponseCode
+ .toResponseValue(appcResponse.getBody().getOutput().getStatus()
+ .getCode()) == org.onap.policy.appclcm.AppcLcmResponseCode.SUCCESS) {
+ vcpeClosedLoopStatus.put("notification", "OPERATION_SUCCESS");
+ vcpeClosedLoopStatus.put("message", "vCPE restarted");
+ executor.getContextAlbum("RequestIDVNFIDAlbum").remove(requestIDString);
+ } else if (org.onap.policy.appclcm.AppcLcmResponseCode
+ .toResponseValue(appcResponse.getBody().getOutput().getStatus()
+ .getCode()) == "ACCEPTED"
+ || org.onap.policy.appclcm.AppcLcmResponseCode
+ .toResponseValue(appcResponse.getBody().getOutput()
+ .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.AppcLcmResponseCode
+ .toResponseValue(appcResponse.getBody()
+ .getOutput().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("vnfID", vnfID);
+} else {
+ 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/definitive/AbatedTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AbatedTask.js
new file mode 100644
index 000000000..f37b6f1b5
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AbatedTask.js
@@ -0,0 +1,41 @@
+/*
+ * ============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 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", "FINAL_SUCCESS");
+vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis());
+vcpeClosedLoopStatus.put("message", "situation has been abated");
+
+executor.logger.info(executor.outFields);
+
+var returnValue = executor.isTrue;
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/ControlLoopLogTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/ControlLoopLogTask.js
new file mode 100644
index 000000000..a5a692cbc
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/ControlLoopLogTask.js
@@ -0,0 +1,73 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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 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(vcpeClosedLoopStatus.get("target_type"));
+clNotification.setTarget(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);
+
+var returnValue = executor.isTrue;
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/DeniedTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/DeniedTask.js
new file mode 100644
index 000000000..353c21ef6
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/DeniedTask.js
@@ -0,0 +1,32 @@
+/*
+ * ============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 vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
+ executor.inFields.get("vnfID").toString());
+
+vcpeClosedLoopStatus.put("notification", "REJECTED");
+vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis());
+
+executor.logger.info(executor.outFields);
+
+var returnValue = executor.isTrue;
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GetVCPEStateTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GetVCPEStateTask.js
new file mode 100644
index 000000000..f4f6d908d
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GetVCPEStateTask.js
@@ -0,0 +1,149 @@
+/*
+ * ============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.
+ *
+ * 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=========================================================
+ */
+
+executor.logger.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+
+var clEventType = Java.type("org.onap.policy.controlloop.VirtualControlLoopEvent");
+var longType = Java.type("java.lang.Long");
+var uuidType = Java.type("java.util.UUID");
+
+var clEvent = executor.inFields.get("VirtualControlLoopEvent");
+
+executor.logger.info(clEvent.toString());
+executor.logger.info(clEvent.getClosedLoopControlName());
+
+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", "");
+
+ var aaiInfo = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewSubInstance("VCPE_AAI_Type");
+
+ 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"));
+ aaiInfo.put("vserverIsClosedLoopDisabled", clEvent.getAai().get("vserver.is-closed-loop-disabled"));
+ aaiInfo.put("vserverProvStatus", clEvent.getAai().get("vserver.prov-status"));
+ aaiInfo.put("vserverName", clEvent.getAai().get("vserver.vserver-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(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/definitive/GuardRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardRequestTask.js
new file mode 100644
index 000000000..d247f8a65
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardRequestTask.js
@@ -0,0 +1,44 @@
+/*
+ * ============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 vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
+ executor.inFields.get("vnfID").toString());
+
+var guardDecisionAttributes = executor.subject.getOutFieldSchemaHelper("decisionAttributes").createNewInstance();
+
+guardDecisionAttributes.put("actor", "APPC");
+guardDecisionAttributes.put("recipe", "Restart");
+guardDecisionAttributes.put("target", executor.inFields.get("vnfID").toString());
+guardDecisionAttributes.put("clname", "APEXvCPEImplementation");
+
+executor.logger.info(guardDecisionAttributes);
+
+executor.outFields.put("decisionAttributes", guardDecisionAttributes);
+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;
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardResponseTask.js
new file mode 100644
index 000000000..2a9100b7f
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardResponseTask.js
@@ -0,0 +1,50 @@
+/*
+ * ============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 vnfID = executor.getContextAlbum("ControlLoopExecutionIDAlbum").remove(executor.executionId.toString());
+
+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.FALSE;
+}
+
+var uuidType = Java.type("java.util.UUID");
+var requestID = uuidType.fromString(vcpeClosedLoopStatus.get("requestID"));
+
+executor.outFields.put("requestID", requestID);
+executor.outFields.put("vnfID", vnfID);
+
+executor.logger.info(executor.outFields);
+
+var returnValue = executor.isTrue;
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/NoAAILookupTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/NoAAILookupTask.js
new file mode 100644
index 000000000..ebc0e6387
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/NoAAILookupTask.js
@@ -0,0 +1,26 @@
+/*
+ * ============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);
+
+executor.logger.info(executor.outFields);
+
+var returnValue = executor.isTrue;
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/OnsetOrAbatedStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/OnsetOrAbatedStateTSL.js
new file mode 100644
index 000000000..c8a3bfba8
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/OnsetOrAbatedStateTSL.js
@@ -0,0 +1,51 @@
+/*
+ * ============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 status = null;
+
+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());
+ status = vcpeClosedLoopStatus.get("closedLoopEventStatus").toString();
+}
+
+var returnValue = executor.isTrue;
+
+if (status === "ONSET") {
+ executor.subject.getTaskKey("GuardRequestTask").copyTo(executor.selectedTask);
+} else if (status === "ABATED") {
+ executor.subject.getTaskKey("AbatedTask").copyTo(executor.selectedTask);
+ onsetFlag = executor.isFalse;
+} else {
+ executor.message = "closedLoopEventStatus is \"" + status + "\", it must be either \"ONSET\" or \"ABATED\"";
+ returnValue = executor.isFalse;
+}
+
+executor.logger.info("ReceiveEventPolicyOnsetOrAbatedStateTSL State Selected Task:" + executor.selectedTask);
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/definitive/RestartAPPCRequestPolicyPermitOrDenyTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/RestartAPPCRequestPolicyPermitOrDenyTSL.js
new file mode 100644
index 000000000..a1bac6546
--- /dev/null
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/RestartAPPCRequestPolicyPermitOrDenyTSL.js
@@ -0,0 +1,37 @@
+/*
+ * ============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 vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
+ executor.inFields.get("vnfID").toString());
+
+var guardResult = vcpeClosedLoopStatus.get("notification");
+
+if (guardResult === "OPERATION: GUARD_PERMIT") {
+ executor.subject.getTaskKey("APPCRestartVNFRequestTask").copyTo(executor.selectedTask);
+} else {
+ executor.subject.getTaskKey("DeniedTask").copyTo(executor.selectedTask);
+}
+
+executor.logger.info("RestartAPPCRequestPolicyPermitOrDenyTSL State Selected Task:" + executor.selectedTask);
+
+var returnValue = executor.isTrue;