Support for PM (Performance Management)
[ccsdk/features.git] / sdnr / wt / devicemanager-onap / onf14 / provider / src / main / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / onf14 / dom / impl / interfaces / Onf14DomInterfacePacManager.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2022 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  */
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces;
23
24 import com.google.common.collect.Sets;
25 import java.util.ArrayList;
26 import java.util.Collection;
27 import java.util.List;
28 import java.util.Objects;
29 import java.util.Optional;
30 import org.eclipse.jdt.annotation.NonNull;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.pm.PerformanceDataAirInterface;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Debug;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames;
36 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.notifications.Onf14DomAirInterfaceNotificationListener;
37 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.notifications.Onf14DomEthernetContainerNotificationListener;
38 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.notifications.Onf14DomWireInterfaceNotificationListener;
39 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
40 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
41 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
42 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp;
43 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
44 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
46 import org.opendaylight.yangtools.yang.common.QName;
47 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
48 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
49 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder;
50 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
51 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
52 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
53 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
54 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
55 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
56 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory;
58
59 /*
60 * Notifications streams provided by device NTSSim ONF14
61 * Stream{getName=StreamNameType{_value=nc-notifications}, isReplaySupport=true, augmentation=[]},
62 * Stream{getName=StreamNameType{_value=hybrid-mw-structure-2-0}, isReplaySupport=true, augmentation=[]},
63 * Stream{getName=StreamNameType{_value=vlan-interface-1-0}, isReplaySupport=true, augmentation=[]},
64 * Stream{getName=StreamNameType{_value=tdm-container-2-0}, isReplaySupport=true, augmentation=[]},
65 * Stream{getName=StreamNameType{_value=ethernet-container-2-0}, isReplaySupport=true, augmentation=[]},
66 * Stream{getName=StreamNameType{_value=ietf-yang-library}, isReplaySupport=false, augmentation=[]},
67 * Stream{getDescription=Default NETCONF stream containing all the Event Notifications., getName=StreamNameType{_value=NETCONF}, isReplaySupport=true, augmentation=[]},
68 * Stream{getName=StreamNameType{_value=vlan-fd-1-0}, isReplaySupport=true, augmentation=[]},
69 * Stream{getName=StreamNameType{_value=wire-interface-2-0}, isReplaySupport=true, augmentation=[]},
70 * Stream{getName=StreamNameType{_value=mac-fd-1-0}, isReplaySupport=true, augmentation=[]},
71 * Stream{getName=StreamNameType{_value=co-channel-profile-1-0}, isReplaySupport=true, augmentation=[]},
72 * Stream{getName=StreamNameType{_value=mac-interface-1-0}, isReplaySupport=true, augmentation=[]},
73 * Stream{getName=StreamNameType{_value=ietf-keystore}, isReplaySupport=true, augmentation=[]},
74 * Stream{getName=StreamNameType{_value=pure-ethernet-structure-2-0}, isReplaySupport=true, augmentation=[]},
75 * Stream{getName=StreamNameType{_value=ietf-netconf-notifications}, isReplaySupport=true, augmentation=[]},
76 * Stream{getName=StreamNameType{_value=mac-fc-1-0}, isReplaySupport=true, augmentation=[]},
77 * Stream{getName=StreamNameType{_value=wred-profile-1-0}, isReplaySupport=true, augmentation=[]},
78 * Stream{getName=StreamNameType{_value=air-interface-2-0}, isReplaySupport=true, augmentation=[]},
79 * Stream{getName=StreamNameType{_value=ip-interface-1-0}, isReplaySupport=true, augmentation=[]},
80 * Stream{getName=StreamNameType{_value=qos-profile-1-0}, isReplaySupport=true, augmentation=[]},
81 * Stream{getName=StreamNameType{_value=vlan-fc-1-0}, isReplaySupport=true, augmentation=[]},
82 * Stream{getName=StreamNameType{_value=l-3vpn-profile-1-0}, isReplaySupport=true, augmentation=[]}]
83 */
84
85 public class Onf14DomInterfacePacManager {
86
87     private static final Logger log = LoggerFactory.getLogger(Onf14DomInterfacePacManager.class);
88
89     private static final YangInstanceIdentifier LTP_IID =
90             YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER)
91                     .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP).build();
92
93     private final NetconfDomAccessor netconfDomAccessor;
94     private final @NonNull DeviceManagerServiceProvider serviceProvider;
95
96     // air interface related members
97     private final List<TechnologySpecificPacKeys> airInterfaceList = new ArrayList<>();
98     @NonNull
99     private final Onf14DomAirInterfaceNotificationListener airInterfaceNotificationListener;
100
101     // ethernet container related members
102     private final List<TechnologySpecificPacKeys> ethernetContainerList = new ArrayList<>();
103     @NonNull
104     private final Onf14DomEthernetContainerNotificationListener ethernetContainerNotificationListener;
105
106     // wire interface related members
107     private final List<TechnologySpecificPacKeys> wireInterfaceList = new ArrayList<>();
108     @NonNull
109     private final Onf14DomWireInterfaceNotificationListener wireInterfaceNotificationListener;
110
111     private final @NonNull FaultService faultService;
112
113     public Onf14DomInterfacePacManager(@NonNull NetconfDomAccessor netconfDomAccessor,
114             @NonNull DeviceManagerServiceProvider serviceProvider) {
115
116         this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor);
117         this.serviceProvider = Objects.requireNonNull(serviceProvider);
118         this.faultService = Objects.requireNonNull(serviceProvider.getFaultService());
119
120         this.airInterfaceNotificationListener =
121                 new Onf14DomAirInterfaceNotificationListener(netconfDomAccessor, serviceProvider);
122         this.ethernetContainerNotificationListener =
123                 new Onf14DomEthernetContainerNotificationListener(netconfDomAccessor, serviceProvider);
124         this.wireInterfaceNotificationListener =
125                 new Onf14DomWireInterfaceNotificationListener(netconfDomAccessor, serviceProvider);
126     }
127
128     public void register() {
129         // storing all the LTP UUIDs internally, for later usage, for air-interface and
130         // ethernet-container and wire-interface
131         readKeys();
132         readAndWriteInterfaceCurrentProblems();
133         registerForNotifications();
134     }
135
136     public List<TechnologySpecificPacKeys> getAirInterfaceList() {
137         return airInterfaceList;
138     }
139
140     public PerformanceDataLtp readAirInterfaceHistoricalPerformanceData(String ltpUuid, String localId,
141             PerformanceDataLtp res) {
142         log.debug("Get historical performance data for class {} from mountpoint {} for LTP uuid {} and local-id {}",
143                 Onf14DevicemanagerQNames.AIR_INTERFACE_2_0_MODULE, netconfDomAccessor.getNodeId().getValue(), ltpUuid,
144                 localId);
145
146         // constructing the IID needs the augmentation exposed by the air-interface-2-0
147         // model
148
149         InstanceIdentifierBuilder layerProtocolIID =
150                 YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER)
151                         .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP)
152                         .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP,
153                                 QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, "uuid").intern(), ltpUuid)
154                         .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL)
155                         .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, QName
156                                 .create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, "local-id").intern(),
157                                 localId);
158
159         @NonNull
160         AugmentationIdentifier airInterfacePacIID = YangInstanceIdentifier.AugmentationIdentifier
161                 .create(Sets.newHashSet(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC));
162
163         InstanceIdentifierBuilder augmentedAirInterfacePacIID =
164                 YangInstanceIdentifier.builder(layerProtocolIID.build()).node(airInterfacePacIID);
165
166         // reading historical performance list for this specific LTP and LP
167         Optional<NormalizedNode> airInterfacePacDataOpt =
168                 netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedAirInterfacePacIID.build());
169         log.debug("Performance Data = {}", airInterfacePacDataOpt.get().body());
170         if (airInterfacePacDataOpt.isPresent()) {
171             AugmentationNode airInterfacePacData = (AugmentationNode) airInterfacePacDataOpt.get();
172             ContainerNode cn = (ContainerNode) airInterfacePacData
173                     .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC));
174             if (cn != null) {
175                 ContainerNode airIntfHistPerf = (ContainerNode) cn
176                         .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_HISTORICAL_PERFORMANCES));
177                 if (airIntfHistPerf != null) {
178                     MapNode airInterfaceHistoricalPerformanceList = (MapNode) airIntfHistPerf.childByArg(
179                             new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_HISTORICAL_PERFORMANCES_LIST));
180                     if (airInterfaceHistoricalPerformanceList != null) {
181                         Collection<MapEntryNode> airInterfaceHistoricalPerfCollection =
182                                 airInterfaceHistoricalPerformanceList.body();
183                         for (MapEntryNode airInterfaceHistPerf : airInterfaceHistoricalPerfCollection) {
184                             res.add(new PerformanceDataAirInterface(netconfDomAccessor.getNodeId(), ltpUuid, localId,
185                                     airInterfaceHistPerf));
186                         }
187                         return res;
188                     } else {
189                         log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);
190                     }
191                 }
192             }
193         }
194         return null;
195     }
196
197     private void readAndWriteInterfaceCurrentProblems() {
198         // Read all fault data
199         FaultData resultList = new FaultData();
200         int problems = 0;
201         readAllAirInterfaceCurrentProblems(resultList);
202         problems = resultList.size();
203         log.debug("NETCONF read air interface current problems completed. Got back {} problems.", problems);
204
205
206         readAllEthernetContainerCurrentProblems(resultList);
207         problems = resultList.size() - problems;
208         log.debug("NETCONF read current problems completed. Got back {} problems.", problems);
209
210         readAllWireInterfaceCurrentProblems(resultList);
211         problems = resultList.size();
212         log.debug("NETCONF read wire interface current problems completed. Got back {} problems.", problems);
213
214
215         if (resultList.size() > 0) {
216             faultService.initCurrentProblemStatus(netconfDomAccessor.getNodeId(), resultList);
217             log.debug("DB write current problems completed");
218         }
219
220     }
221
222     private void readKeys() {
223         Optional<NormalizedNode> ltpData = readLtpData(netconfDomAccessor);
224         log.debug("LTP Data is - {}", ltpData);
225         if (ltpData.isPresent()) {
226
227             MapNode ccLtp = (MapNode) ltpData.get();
228             if (ccLtp != null) {
229                 log.debug("Iterating the LTP list for node {}", netconfDomAccessor.getNodeId().getValue());
230                 Collection<MapEntryNode> ltpList = ccLtp.body();
231
232                 // iterating all the Logical Termination Point list
233                 for (MapEntryNode ltp : ltpList) {
234                     MapNode lpList = (MapNode) ltp
235                             .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL));
236                     // the Layer Protocol list should contain only one item, since we have an 1:1
237                     // relationship between the LTP and the LP
238                     if (lpList != null && lpList.size() != 1) {
239                         log.debug("Layer protocol has no 1:1 relationship with the LTP.");
240                         return;
241                     }
242                     // accessing the LP, which should be only 1
243                     Collection<MapEntryNode> lp = lpList.body();
244                     for (MapEntryNode lpEntry : lp) {
245                         String layerProtocolName = Onf14DMDOMUtility.getLeafValue(lpEntry,
246
247                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_NAME);
248                         if (layerProtocolName != null) {
249                             // if the LTP has an airInterface technology extension, the layer protocol name
250                             // is air-layer
251                             if (layerProtocolName.contains("LAYER_PROTOCOL_NAME_TYPE_AIR_LAYER")) {
252                                 TechnologySpecificPacKeys airInterfaceKey = new TechnologySpecificPacKeys(
253                                         Onf14DMDOMUtility.getLeafValue(ltp,
254                                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID),
255                                         Onf14DMDOMUtility.getLeafValue(lpEntry,
256                                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID));
257                                 airInterfaceList.add(airInterfaceKey);
258                                 log.debug("Adding Ltp with uuid {} and local-id {} to the air-interface list",
259                                         Onf14DMDOMUtility.getLeafValue(ltp,
260                                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID),
261                                         Onf14DMDOMUtility.getLeafValue(lpEntry,
262                                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID));
263                             }
264                             // if the LTP has an ethernetContainer technology extension, the layer protocol
265                             // name is ethernet-container-layer
266                             else if (layerProtocolName.contains("LAYER_PROTOCOL_NAME_TYPE_ETHERNET_CONTAINER_LAYER")) {
267                                 TechnologySpecificPacKeys ethernetContainerKey = new TechnologySpecificPacKeys(
268                                         Onf14DMDOMUtility.getLeafValue(ltp,
269                                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID),
270                                         Onf14DMDOMUtility.getLeafValue(lpEntry,
271                                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID));
272                                 ethernetContainerList.add(ethernetContainerKey);
273                                 log.debug("Adding Ltp with uuid {} and local-id {} to the ethernet-container list",
274                                         Onf14DMDOMUtility.getLeafValue(ltp,
275                                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID),
276                                         Onf14DMDOMUtility.getLeafValue(lpEntry,
277                                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID));
278                             } else if (layerProtocolName.contains("LAYER_PROTOCOL_NAME_TYPE_WIRE_LAYER")) {
279                                 TechnologySpecificPacKeys wireInterfaceKey = new TechnologySpecificPacKeys(
280                                         Onf14DMDOMUtility.getLeafValue(ltp,
281                                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID),
282                                         Onf14DMDOMUtility.getLeafValue(lpEntry,
283                                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID));
284                                 wireInterfaceList.add(wireInterfaceKey);
285                                 log.debug("Adding Ltp with uuid {} and local-id {} to the wire-interface list",
286                                         Onf14DMDOMUtility.getLeafValue(ltp,
287                                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID),
288                                         Onf14DMDOMUtility.getLeafValue(lpEntry,
289                                                 Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID));
290                             }
291                         }
292                     }
293                 }
294             }
295         }
296     }
297
298     private void readAllAirInterfaceCurrentProblems(FaultData resultList) {
299
300         int idxStart; // Start index for debug messages
301
302         for (TechnologySpecificPacKeys key : airInterfaceList) {
303             idxStart = resultList.size();
304
305             readAirInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList);
306             Debug.debugResultList(key.getLtpUuid(), resultList, idxStart);
307         }
308     }
309
310     private void readAllEthernetContainerCurrentProblems(FaultData resultList) {
311
312         int idxStart; // Start index for debug messages
313
314         for (TechnologySpecificPacKeys key : ethernetContainerList) {
315             idxStart = resultList.size();
316
317             readEthernetContainerCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList);
318             Debug.debugResultList(key.getLtpUuid(), resultList, idxStart);
319         }
320     }
321
322     private void readAllWireInterfaceCurrentProblems(FaultData resultList) {
323
324         int idxStart; // Start index for debug messages
325
326         for (TechnologySpecificPacKeys key : wireInterfaceList) {
327             idxStart = resultList.size();
328
329             readWireInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList);
330             Debug.debugResultList(key.getLtpUuid(), resultList, idxStart);
331         }
332     }
333
334     private void readAirInterfaceCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) {
335
336         log.debug("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}",
337                 Onf14DevicemanagerQNames.AIR_INTERFACE_2_0_MODULE, netconfDomAccessor.getNodeId().getValue(), ltpUuid,
338                 localId);
339
340         // constructing the IID needs the augmentation exposed by the air-interface-2-0
341         // model
342
343         InstanceIdentifierBuilder layerProtocolIID =
344                 YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER)
345                         .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP)
346                         .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP,
347                                 QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, "uuid").intern(), ltpUuid)
348                         .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL)
349                         .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, QName
350                                 .create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, "local-id").intern(),
351                                 localId);
352
353         @NonNull
354         AugmentationIdentifier airInterfacePacIID = YangInstanceIdentifier.AugmentationIdentifier
355                 .create(Sets.newHashSet(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC));
356
357         InstanceIdentifierBuilder augmentedAirInterfacePacIID =
358                 YangInstanceIdentifier.builder(layerProtocolIID.build()).node(airInterfacePacIID);
359
360         // reading all the current-problems list for this specific LTP and LP
361         Optional<NormalizedNode> airInterfacePacDataOpt =
362                 netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedAirInterfacePacIID.build());
363
364         if (airInterfacePacDataOpt.isPresent()) {
365             AugmentationNode airInterfacePacData = (AugmentationNode) airInterfacePacDataOpt.get();
366             MapNode airInterfaceCurrentProblemsList = (MapNode) airInterfacePacData
367                     .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_LIST));
368             if (airInterfaceCurrentProblemsList != null) {
369                 Collection<MapEntryNode> airInterfaceProblemsCollection = airInterfaceCurrentProblemsList.body();
370                 for (MapEntryNode airInterfaceProblem : airInterfaceProblemsCollection) {
371                     resultList.add(netconfDomAccessor.getNodeId(),
372                             Integer.parseInt(Onf14DMDOMUtility.getLeafValue(airInterfaceProblem,
373                                     Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_SEQ_NO)),
374                             new DateAndTime(Onf14DMDOMUtility.getLeafValue(airInterfaceProblem,
375                                     Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_TIMESTAMP)),
376                             ltpUuid,
377                             Onf14DMDOMUtility.getLeafValue(airInterfaceProblem,
378                                     Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_PROBLEM_NAME),
379                             InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(airInterfaceProblem,
380                                     Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_PROBLEM_SEVERITY)));
381                 }
382             } else {
383                 log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);
384             }
385         }
386     }
387
388     private void readEthernetContainerCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) {
389
390         log.debug(
391                 "DBRead Get current problems for Ethernet Container from mountpoint {} for LTP uuid {} and local-id {}",
392                 netconfDomAccessor.getNodeId().getValue(), ltpUuid, localId);
393
394         // constructing the IID needs the augmentation exposed by the
395         // ethernet-container-2-0 model
396         InstanceIdentifierBuilder layerProtocolIID =
397                 YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER)
398                         .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP)
399                         .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP,
400                                 QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, "uuid").intern(), ltpUuid)
401                         .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL)
402                         .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, QName
403                                 .create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, "local-id").intern(),
404                                 localId);
405
406         @NonNull
407         AugmentationIdentifier ethernetContainerIID = YangInstanceIdentifier.AugmentationIdentifier
408                 .create(Sets.newHashSet(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_PAC));
409
410         InstanceIdentifierBuilder augmentedEthernetContainerConfigurationIID =
411                 YangInstanceIdentifier.builder(layerProtocolIID.build()).node(ethernetContainerIID);
412
413         // reading all the current-problems list for this specific LTP and LP
414         Optional<NormalizedNode> etherntContainerConfigurationOpt = netconfDomAccessor
415                 .readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedEthernetContainerConfigurationIID.build());
416
417         if (etherntContainerConfigurationOpt.isPresent()) {
418             AugmentationNode etherntContainerConfiguration = (AugmentationNode) etherntContainerConfigurationOpt.get();
419             MapNode ethernetContainerCurrentProblemsList = (MapNode) etherntContainerConfiguration
420                     .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_LIST));
421             if (ethernetContainerCurrentProblemsList != null) {
422                 Collection<MapEntryNode> ethernetContainerProblemsCollection =
423                         ethernetContainerCurrentProblemsList.body();
424                 for (MapEntryNode ethernetContainerProblem : ethernetContainerProblemsCollection) {
425                     resultList.add(netconfDomAccessor.getNodeId(),
426                             Integer.parseInt(Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem,
427                                     Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_SEQ_NO)),
428                             new DateAndTime(Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem,
429                                     Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_TIMESTAMP)),
430                             ltpUuid,
431                             Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem,
432                                     Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_PROBLEM_NAME),
433                             InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(
434                                     ethernetContainerProblem,
435                                     Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_PROBLEM_SEVERITY)));
436                 }
437             } else {
438                 log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);
439             }
440         }
441
442     }
443
444     private void readWireInterfaceCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) {
445
446         log.debug("DBRead Get current problems for Wire Interface from mountpoint {} for LTP uuid {} and local-id {}",
447                 netconfDomAccessor.getNodeId().getValue(), ltpUuid, localId);
448
449         // constructing the IID needs the augmentation exposed by the wire-interface-2-0
450         // model
451         InstanceIdentifierBuilder layerProtocolIID =
452                 YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER)
453                         .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP)
454                         .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP,
455                                 QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, "uuid").intern(), ltpUuid)
456                         .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL)
457                         .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, QName
458                                 .create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, "local-id").intern(),
459                                 localId);
460
461         @NonNull
462         AugmentationIdentifier wireInterfacePacIID = YangInstanceIdentifier.AugmentationIdentifier
463                 .create(Sets.newHashSet(Onf14DevicemanagerQNames.WIRE_INTERFACE_PAC));
464
465         InstanceIdentifierBuilder augmentedWireInterfaceConfigurationIID =
466                 YangInstanceIdentifier.builder(layerProtocolIID.build()).node(wireInterfacePacIID);
467
468         // reading all the current-problems list for this specific LTP and LP
469         Optional<NormalizedNode> wireInterfaceConfigurationOpt = netconfDomAccessor
470                 .readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedWireInterfaceConfigurationIID.build());
471
472         if (wireInterfaceConfigurationOpt.isPresent()) {
473             AugmentationNode wireInterfaceConfiguration = (AugmentationNode) wireInterfaceConfigurationOpt.get();
474             MapNode wireInterfaceCurrentProblemsList = (MapNode) wireInterfaceConfiguration
475                     .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_LIST));
476             if (wireInterfaceCurrentProblemsList != null) {
477                 Collection<MapEntryNode> wireInterfaceProblemsCollection = wireInterfaceCurrentProblemsList.body();
478                 for (MapEntryNode wireInterfaceProblem : wireInterfaceProblemsCollection) {
479                     resultList.add(netconfDomAccessor.getNodeId(),
480                             Integer.parseInt(Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem,
481                                     Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_SEQ_NO)),
482                             new DateAndTime(Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem,
483                                     Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_TIMESTAMP)),
484                             ltpUuid,
485                             Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem,
486                                     Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_PROBLEM_NAME),
487                             InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem,
488                                     Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_PROBLEM_SEVERITY)));
489                 }
490             } else {
491                 log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);
492             }
493         }
494
495     }
496
497     private void registerForNotifications() {
498
499         QName[] airInterfaceNotifications = {Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION,
500                 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION,
501                 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION,
502                 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION};
503         netconfDomAccessor.doRegisterNotificationListener(airInterfaceNotificationListener, airInterfaceNotifications);
504
505         QName[] ethernetContainerNotifications =
506                 {Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION,
507                         Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION,
508                         Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION,
509                         Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION};
510         netconfDomAccessor.doRegisterNotificationListener(ethernetContainerNotificationListener,
511                 ethernetContainerNotifications);
512
513         QName[] wireInterfaceNotifications = {Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION,
514                 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION,
515                 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION,
516                 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION};
517         netconfDomAccessor.doRegisterNotificationListener(wireInterfaceNotificationListener,
518                 wireInterfaceNotifications);
519     }
520
521     public Optional<NormalizedNode> readLtpData(NetconfDomAccessor netconfDomAccessor) {
522         log.info("Reading Logical Termination Point data");
523         return netconfDomAccessor.readDataNode(LogicalDatastoreType.CONFIGURATION, LTP_IID);
524     }
525
526     public PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull TechnologySpecificPacKeys lp) {
527         PerformanceDataLtp res = new PerformanceDataLtp();
528         readAirInterfaceHistoricalPerformanceData(lp.getLtpUuid(), lp.getLocalId(), res);
529         return res;
530     }
531 }