diff options
author | liamfallon <liam.fallon@ericsson.com> | 2018-10-08 13:36:31 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2019-03-27 22:35:12 +0000 |
commit | f996ef829249c304550becb0cb57db3efd3baf6a (patch) | |
tree | ef2657cd8d44f80b02cfee8db0908a8f9ca7dbf1 /examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js | |
parent | cfcffbce70ddc3083e337f18377c0847f7233caa (diff) |
Change vCPE example to use POJOs
This review uses POJOs rather than Avro schema to unmarshal
and marshal events from and to DMaaP.
The POJO classes for interacting with DMaaP have been moved into
a common policy module.
This review is now ready for full review (finally!).
Issue-ID: POLICY-954
Change-Id: Ibb89d8af5b9006821e6a0a756e16bbe3815af15a
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: Liam Fallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
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.js | 66 |
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); |