summaryrefslogtreecommitdiffstats
path: root/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js
diff options
context:
space:
mode:
Diffstat (limited to 'examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js')
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js66
1 files changed, 45 insertions, 21 deletions
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);