2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Huawei. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
20 load("nashorn:mozilla_compat.js");
22 executor.logger.info("Begin Execution GetBBSCloseLoopEventTask.js");
23 executor.logger.info(executor.subject.id);
24 executor.logger.info(executor.inFields);
25 var returnValue = executor.isTrue;
27 var clEventType = Java.type(
28 "org.onap.policy.controlloop.VirtualControlLoopEvent");
29 var clEvent = executor.inFields.get("VirtualControlLoopEvent");
30 executor.logger.info(clEvent.toString());
31 executor.logger.info(clEvent.getClosedLoopControlName());
33 var requestID = clEvent.getRequestId();
34 executor.logger.info("requestID = " + requestID);
35 var attachmentPoint = null;
36 var NomadicONTContext = null;
37 var serviceInstanceId = null;
39 if (clEvent.getAai().get("attachmentPoint") != null) {
40 attachmentPoint = clEvent.getAai().get("attachmentPoint");
41 executor.logger.info("attachmentPoint = " + attachmentPoint);
42 NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").get(
44 serviceInstanceId = clEvent.getAai().get(
45 "service-information.hsia-cfs-service-instance-id");
46 executor.logger.info("serviceInstanceId = " + serviceInstanceId);
48 if (NomadicONTContext == null) {
50 "Creating context information for new ONT Device \"" +
51 attachmentPoint.toString() + "\"");
53 NomadicONTContext = executor.getContextAlbum("NomadicONTContextAlbum").getSchemaHelper()
56 NomadicONTContext.put("closedLoopControlName", clEvent.getClosedLoopControlName());
57 NomadicONTContext.put("closedLoopAlarmStart", clEvent.getClosedLoopAlarmStart()
59 NomadicONTContext.put("closedLoopEventClient", clEvent.getClosedLoopEventClient());
60 NomadicONTContext.put("closedLoopEventStatus", clEvent.getClosedLoopEventStatus()
62 NomadicONTContext.put("version", clEvent.getVersion());
63 NomadicONTContext.put("requestID", clEvent.getRequestId().toString());
64 NomadicONTContext.put("target_type", clEvent.getTargetType().toString());
65 NomadicONTContext.put("target", clEvent.getTarget());
66 NomadicONTContext.put("from", clEvent.getFrom());
67 NomadicONTContext.put("policyScope", "Nomadic ONT");
68 NomadicONTContext.put("policyName", clEvent.getPolicyName());
69 NomadicONTContext.put("policyVersion", "1.0.0");
70 NomadicONTContext.put("notificationTime", java.lang.System.currentTimeMillis());
71 NomadicONTContext.put("message", "");
72 NomadicONTContext.put("result", "SUCCESS");
73 var aaiInfo = executor.getContextAlbum("NomadicONTContextAlbum").getSchemaHelper()
74 .createNewSubInstance("VCPE_AAI_Type");
76 aaiInfo.put("attachmentPoint", clEvent.getAai().get("attachmentPoint"));
77 aaiInfo.put("cvlan", clEvent.getAai().get("cvlan"));
78 aaiInfo.put("service_information_hsia_cfs_service_instance_id", clEvent
80 "service-information.hsia-cfs-service-instance-id"));
81 aaiInfo.put("svlan", clEvent.getAai().get("svlan"));
82 aaiInfo.put("remoteId", clEvent.getAai().get("remoteId"));
85 NomadicONTContext.put("AAI", aaiInfo);
87 if (clEvent.getClosedLoopAlarmEnd() != null) {
88 NomadicONTContext.put("closedLoopAlarmEnd", clEvent.getClosedLoopAlarmEnd()
91 NomadicONTContext.put("closedLoopAlarmEnd", java.lang.Long.valueOf(
95 executor.getContextAlbum("NomadicONTContextAlbum").put(attachmentPoint.toString(),
97 executor.logger.info("Created context information for new vCPE VNF \"" +
98 attachmentPoint.toString() + "\"");
101 executor.outFields.put("requestID", requestID);
102 executor.outFields.put("attachmentPoint", attachmentPoint);
103 executor.outFields.put("serviceInstanceId", serviceInstanceId);
104 executor.logger.info(executor.outFields);
105 executor.logger.info("Event Successfully Received and stored in album");
109 executor.message = "Received NULL attachment-point";
110 returnValue = executor.isFalse;