b314dbdbe32590d34a09f6311c43681e3727282e
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl;
19
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.List;
23 import java.util.Optional;
24 import org.eclipse.jdt.annotation.NonNull;
25 import org.eclipse.jdt.annotation.Nullable;
26 import org.onap.ccsdk.features.sdnr.wt.common.YangHelper;
27 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.dataprovider.Onf14ToInternalDataModel;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14AirInterface;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14AirInterfaceNotificationListener;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14EthernetContainer;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14EthernetContainerNotificationListener;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14WireInterface;
36 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14WireInterfaceNotificationListener;
37 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
38 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
39 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
40 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
41 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
42 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
43 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
44 import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LAYERPROTOCOLNAMETYPEAIRLAYER;
45 import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.air._interface.lp.spec.AirInterfacePac;
46 import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.air._interface.pac.AirInterfaceCurrentProblems;
47 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ControlConstruct;
48 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.LAYERPROTOCOLNAMETYPE;
49 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId;
50 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.Equipment;
51 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.EquipmentKey;
52 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.LogicalTerminationPoint;
53 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.LogicalTerminationPointKey;
54 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolder;
55 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.logical.termination.point.LayerProtocol;
56 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.logical.termination.point.LayerProtocolKey;
57 import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.LAYERPROTOCOLNAMETYPEETHERNETCONTAINERLAYER;
58 import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ethernet.container.lp.spec.EthernetContainerPac;
59 import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ethernet.container.pac.EthernetContainerCurrentProblems;
60 import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.LAYERPROTOCOLNAMETYPEWIRELAYER;
61 import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.wire._interface.lp.spec.WireInterfacePac;
62 import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.wire._interface.pac.WireInterfaceCurrentProblems;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType;
67 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
68 import org.opendaylight.yangtools.concepts.ListenerRegistration;
69 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
70 import org.opendaylight.yangtools.yang.binding.NotificationListener;
71 import org.opendaylight.yangtools.yang.common.QName;
72 import org.slf4j.Logger;
73 import org.slf4j.LoggerFactory;
74
75 /**
76  * Repesentation of ONF Core model 1.4 device Top level element is "ControlConstruct" (replaces "NetworkElement" of
77  * older ONF Version)
78  */
79 public class Onf14NetworkElement implements NetworkElement {
80
81     private static final Logger log = LoggerFactory.getLogger(Onf14NetworkElement.class);
82
83     protected static final InstanceIdentifier<ControlConstruct> CONTROLCONSTRUCT_IID =
84             InstanceIdentifier.builder(ControlConstruct.class).build();
85
86     private static final int EQUIPMENTROOTLEVEL = 0;
87
88     private final NetconfBindingAccessor netconfAccessor;
89     private final DataProvider databaseService;
90     private final Onf14ToInternalDataModel onf14Mapper;
91     private final @NonNull FaultService faultService;
92
93     // for storing the Equipment UUIDs that are inserted in the DB
94     private final List<String> equipmentUuidList = new ArrayList<String>();
95
96     // air interface related members
97     private final List<TechnologySpecificPacKeys> airInterfaceList = new ArrayList<TechnologySpecificPacKeys>();
98     @SuppressWarnings("unused")
99     private ListenerRegistration<NotificationListener> airInterfaceNotificationListenerHandler;
100     private @NonNull final Onf14AirInterfaceNotificationListener airInterfaceNotificationListener;
101
102     // ethernet container related members
103     private final List<TechnologySpecificPacKeys> ethernetContainerList = new ArrayList<TechnologySpecificPacKeys>();
104     @SuppressWarnings("unused")
105     private ListenerRegistration<NotificationListener> etherneContainerNotificationListenerHandler;
106     private @NonNull final Onf14EthernetContainerNotificationListener ethernetContainerNotificationListener;
107
108     // wire interface related members
109     private final List<TechnologySpecificPacKeys> wireInterfaceList = new ArrayList<TechnologySpecificPacKeys>();
110     @SuppressWarnings("unused")
111     private ListenerRegistration<NotificationListener> wireInterfaceNotificationListenerHandler;
112     private @NonNull final Onf14WireInterfaceNotificationListener wireInterfaceNotificationListener;
113
114     Onf14NetworkElement(NetconfBindingAccessor netconfAccess, DeviceManagerServiceProvider serviceProvider) {
115         log.info("Create {}", Onf14NetworkElement.class.getSimpleName());
116         this.netconfAccessor = netconfAccess;
117         this.databaseService = serviceProvider.getDataProvider();
118         this.faultService = serviceProvider.getFaultService();
119         this.onf14Mapper = new Onf14ToInternalDataModel();
120         this.airInterfaceNotificationListenerHandler = null;
121         this.airInterfaceNotificationListener =
122                 new Onf14AirInterfaceNotificationListener(netconfAccess, serviceProvider);
123         this.etherneContainerNotificationListenerHandler = null;
124         ethernetContainerNotificationListener =
125                 new Onf14EthernetContainerNotificationListener(netconfAccess, serviceProvider);
126         this.wireInterfaceNotificationListenerHandler = null;
127         wireInterfaceNotificationListener = new Onf14WireInterfaceNotificationListener(netconfAccess, serviceProvider);
128     }
129
130     public void initialReadFromNetworkElement() {
131
132         // reading the inventory (CoreModel 1.4 Equipment Model) and adding it to the DB
133         readEquipmentData();
134
135         FaultData resultList = new FaultData();
136
137         int problems = faultService.removeAllCurrentProblemsOfNode(netconfAccessor.getNodeId());
138         log.debug("Removed all {} problems from database at registration", problems);
139
140         readAllAirInterfaceCurrentProblems(resultList);
141         problems = resultList.size();
142         log.debug("NETCONF read air interface current problems completed. Got back {} problems.", problems);
143
144         readAllEhernetContainerCurrentProblems(resultList);
145         problems = resultList.size() - problems;
146         log.debug("NETCONF read current problems completed. Got back {} problems.", resultList.size());
147
148         readAllWireInterfaceCurrentProblems(resultList);
149         problems = resultList.size();
150         log.debug("NETCONF read wire interface current problems completed. Got back {} problems.", problems);
151
152         faultService.initCurrentProblemStatus(netconfAccessor.getNodeId(), resultList);
153         log.debug("DB write current problems completed");
154
155     }
156
157     public void readAllAirInterfaceCurrentProblems(FaultData resultList) {
158
159         int idxStart; // Start index for debug messages
160
161         for (TechnologySpecificPacKeys key : airInterfaceList) {
162             idxStart = resultList.size();
163
164             readAirInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList);
165             debugResultList(key.getLtpUuid().getValue(), resultList, idxStart);
166         }
167     }
168
169     public void readAllEhernetContainerCurrentProblems(FaultData resultList) {
170
171         int idxStart; // Start index for debug messages
172
173         for (TechnologySpecificPacKeys key : ethernetContainerList) {
174             idxStart = resultList.size();
175
176             readEthernetConainerCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList);
177             debugResultList(key.getLtpUuid().getValue(), resultList, idxStart);
178         }
179     }
180
181     public void readAllWireInterfaceCurrentProblems(FaultData resultList) {
182
183         int idxStart; // Start index for debug messages
184
185         for (TechnologySpecificPacKeys key : wireInterfaceList) {
186             idxStart = resultList.size();
187
188             readWireInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList);
189             debugResultList(key.getLtpUuid().getValue(), resultList, idxStart);
190         }
191     }
192
193     /**
194      * @param nNode set core-model-capability
195      */
196     public void setCoreModel(@NonNull NetconfNode nNode) {
197         NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder();
198         log.info("In setCoreModel for Onf14NetworkElement");
199         String namespaceRevision;
200         QName QNAME_COREMODEL14 = QName.create("urn:onf:yang:core-model-1-4", "2019-11-27", "core-model-1-4").intern();
201
202         Capabilities availableCapabilities = Capabilities.getAvailableCapabilities(nNode);
203         namespaceRevision = availableCapabilities.getRevisionForNamespace(QNAME_COREMODEL14);
204         log.info("In setCoreModel for Onf14NetworkElement- namespaceRevision = " + namespaceRevision);
205         if (Capabilities.isNamespaceSupported(namespaceRevision)) {
206             eb.setCoreModelCapability(namespaceRevision);
207         } else {
208             eb.setCoreModelCapability("Unsupported");
209         }
210         databaseService.updateNetworkConnection22(eb.build(), netconfAccessor.getNodeId().getValue());
211     }
212
213     @Override
214     public void register() {
215         // Set core-model revision value in "core-model-capability" field
216         setCoreModel(netconfAccessor.getNetconfNode());
217         initialReadFromNetworkElement();
218
219         // Register netconf stream
220         airInterfaceNotificationListenerHandler =
221                 netconfAccessor.doRegisterNotificationListener(airInterfaceNotificationListener);
222         etherneContainerNotificationListenerHandler =
223                 netconfAccessor.doRegisterNotificationListener(ethernetContainerNotificationListener);
224         wireInterfaceNotificationListenerHandler =
225                 netconfAccessor.doRegisterNotificationListener(wireInterfaceNotificationListener);
226         netconfAccessor.registerNotificationsStream(NetconfBindingAccessor.DefaultNotificationsStream);
227     }
228
229     @Override
230     public void deregister() {}
231
232
233     @Override
234     public NodeId getNodeId() {
235         return netconfAccessor.getNodeId();
236     }
237
238     @Override
239     public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) {
240         return Optional.empty();
241     }
242
243     @Override
244     public void warmstart() {}
245
246     @Override
247     public Optional<NetconfAccessor> getAcessor() {
248         return Optional.of(netconfAccessor);
249     }
250
251     @Override
252     public NetworkElementDeviceType getDeviceType() {
253         return NetworkElementDeviceType.Wireless;
254     }
255
256     private void readEquipmentData() {
257
258         Optional<ControlConstruct> controlConstruct = readControlConstruct(netconfAccessor);
259
260         if (controlConstruct.isPresent()) {
261             // the top-level-equipment list contains the root objects of the Equipment Model
262             log.debug("Getting list of topLevelEquipment for mountpoint {}", netconfAccessor.getNodeId());
263             @Nullable
264             List<UniversalId> topLevelEquipment = controlConstruct.get().getTopLevelEquipment();
265
266             if (topLevelEquipment != null) {
267                 List<Inventory> inventoryList = new ArrayList<>();
268                 for (UniversalId uuid : topLevelEquipment) {
269                     log.debug("Got back topLevelEquipment with uuid {}", uuid.getValue());
270
271                     // adding all root Equipment objects to the DB
272                     @Nullable
273                     Equipment equipmentInstance = readEquipmentInstance(netconfAccessor, uuid);
274                     if (equipmentInstance != null) {
275                         // recursively adding the root equipment and all its children into the DB
276                         collectEquipment(inventoryList, equipmentInstance, null, EQUIPMENTROOTLEVEL);
277                     }
278                 }
279                 this.databaseService.writeInventory(this.netconfAccessor.getNodeId().getValue(), inventoryList);
280
281             }
282         }
283
284         // storing all the LTP UUIDs internally, for later usage, for air-interface and ethernet-container
285         readKeys(controlConstruct);
286     }
287
288     private List<Inventory> collectEquipment(List<Inventory> list, Equipment currentEq, Equipment parentEq,
289             long treeLevel) {
290
291         // if the Equipment UUID is already in the list, it was already processed
292         // needed for solving possible circular dependencies
293         if (equipmentUuidList.contains(currentEq.getUuid().getValue())) {
294             log.debug("Not adding equipment with uuid {} because it was aleady added...",
295                     currentEq.getUuid().getValue());
296             return list;
297         }
298
299         // we add this to our internal list, such that we avoid circular dependencies
300         equipmentUuidList.add(currentEq.getUuid().getValue());
301         log.debug("Adding equipment with uuid {} to the database...", currentEq.getUuid().getValue());
302
303         // we add our current equipment to the database
304         list.add(onf14Mapper.getInternalEquipment(netconfAccessor.getNodeId(), currentEq, parentEq, treeLevel));
305
306         // we iterate the kids of our current equipment and add them to the database recursively
307         // the actual reference is here: /core-model:control-construct/equipment/contained-holder/occupying-fru
308         @NonNull
309         Collection<ContainedHolder> holderList = YangHelper.getCollection(currentEq.nonnullContainedHolder());
310
311         for (ContainedHolder holder : holderList) {
312             @Nullable
313             UniversalId occupyingFru = holder.getOccupyingFru();
314             if (occupyingFru != null) {
315                 @Nullable
316                 Equipment childEq = readEquipmentInstance(netconfAccessor, occupyingFru);
317
318                 if (childEq != null) {
319                     // current becomes parent and tree level increases by 1
320                     collectEquipment(list, childEq, currentEq, treeLevel + 1);
321                 }
322             }
323         }
324         return list;
325     }
326
327     private void readKeys(Optional<ControlConstruct> controlConstruct) {
328
329         if (controlConstruct.isPresent()) {
330             @NonNull
331             Collection<LogicalTerminationPoint> ltpList =
332                     YangHelper.getCollection(controlConstruct.get().nonnullLogicalTerminationPoint());
333             log.debug("Iterating the LTP list for node {}", netconfAccessor.getNodeId().getValue());
334
335             // iterating all the Logical Termination Point list
336             for (LogicalTerminationPoint ltp : ltpList) {
337                 @NonNull
338                 List<LayerProtocol> lpList = YangHelper.getList(ltp.nonnullLayerProtocol());
339                 // the Layer Protocol list should contain only one item, since we have an 1:1 relationship between the LTP and the LP
340                 if (lpList.size() != 1) {
341                     log.debug("Layer protocol has no 1:1 relationship with the LTP.");
342                     return;
343                 }
344                 // accessing the LP, which should be only 1
345                 LayerProtocol lp = lpList.get(0);
346                 @Nullable
347                 Class<? extends LAYERPROTOCOLNAMETYPE> layerProtocolName = lp.getLayerProtocolName();
348                 if (layerProtocolName != null) {
349                     // if the LTP has an airInterface technology extension, the layer protocol name is air-layer
350                     if (layerProtocolName.getTypeName() == LAYERPROTOCOLNAMETYPEAIRLAYER.class.getName()) {
351                         TechnologySpecificPacKeys airInterfaceKey =
352                                 new TechnologySpecificPacKeys(ltp.getUuid(), lp.getLocalId());
353                         airInterfaceList.add(airInterfaceKey);
354                         log.debug("Adding Ltp with uuid {} and local-id {} to the air-interface list",
355                                 ltp.getUuid().getValue(), lp.getLocalId());
356                     }
357                     // if the LTP has an ethernetContainier technology extension, the layer protocol name is ethernet-container-layer
358                     else if (layerProtocolName.getTypeName() == LAYERPROTOCOLNAMETYPEETHERNETCONTAINERLAYER.class
359                             .getName()) {
360                         TechnologySpecificPacKeys ethernetContainerKey =
361                                 new TechnologySpecificPacKeys(ltp.getUuid(), lp.getLocalId());
362                         ethernetContainerList.add(ethernetContainerKey);
363                         log.debug("Adding Ltp with uuid {} and local-id {} to the ethernet-contatinier list",
364                                 ltp.getUuid().getValue(), lp.getLocalId());
365                     } else if (layerProtocolName.getTypeName() == LAYERPROTOCOLNAMETYPEWIRELAYER.class.getName()) {
366                         TechnologySpecificPacKeys wireInterfaceKey =
367                                 new TechnologySpecificPacKeys(ltp.getUuid(), lp.getLocalId());
368                         wireInterfaceList.add(wireInterfaceKey);
369                         log.debug("Adding Ltp with uuid {} and local-id {} to the wire-interface list",
370                                 ltp.getUuid().getValue(), lp.getLocalId());
371                     }
372                 }
373             }
374         }
375     }
376
377     private void readAirInterfaceCurrentProblemForLtp(UniversalId ltpUuid, String localId, FaultData resultList) {
378
379         final Class<AirInterfacePac> clazzPac = AirInterfacePac.class;
380
381         log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}",
382                 clazzPac.getSimpleName(), netconfAccessor.getNodeId().getValue(), ltpUuid.getValue(), localId);
383
384         // constructing the IID needs the augmentation exposed byy the air-interface-2-0 model
385         InstanceIdentifier<AirInterfaceCurrentProblems> airInterfaceCurrentProblem_IID = InstanceIdentifier
386                 .builder(ControlConstruct.class)
387                 .child(LogicalTerminationPoint.class, new LogicalTerminationPointKey(ltpUuid))
388                 .child(LayerProtocol.class, new LayerProtocolKey(localId))
389                 .augmentation(
390                         org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LayerProtocol1.class)
391                 .child(AirInterfacePac.class).child(AirInterfaceCurrentProblems.class).build();
392
393         // reading all the current-problems list for this specific LTP and LP
394         AirInterfaceCurrentProblems problems = netconfAccessor.getTransactionUtils().readData(
395                 netconfAccessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, airInterfaceCurrentProblem_IID);
396
397         if (problems == null) {
398             log.debug("DBRead Id {} no AirInterfaceCurrentProblems", ltpUuid);
399         } else if (problems.getCurrentProblemList() == null) {
400             log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);
401         } else {
402             for (org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.air._interface.current.problems.CurrentProblemList problem : YangHelper
403                     .getCollection(problems.nonnullCurrentProblemList())) {
404                 resultList.add(netconfAccessor.getNodeId(), (int) problem.getSequenceNumber(), problem.getTimestamp(),
405                         ltpUuid.getValue(), problem.getProblemName(),
406                         Onf14AirInterface.mapSeverity(problem.getProblemSeverity()));
407             }
408         }
409     }
410
411     private void readEthernetConainerCurrentProblemForLtp(UniversalId ltpUuid, String localId, FaultData resultList) {
412
413         final Class<EthernetContainerPac> clazzPac = EthernetContainerPac.class;
414
415         log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}",
416                 clazzPac.getSimpleName(), netconfAccessor.getNodeId().getValue(), ltpUuid.getValue(), localId);
417
418         // constructing the IID needs the augmentation exposed by the ethernet-container-2-0 model
419         InstanceIdentifier<EthernetContainerCurrentProblems> etherneContainerCurrentProblem_IID = InstanceIdentifier
420                 .builder(ControlConstruct.class)
421                 .child(LogicalTerminationPoint.class, new LogicalTerminationPointKey(ltpUuid))
422                 .child(LayerProtocol.class, new LayerProtocolKey(localId))
423                 .augmentation(
424                         org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.LayerProtocol1.class)
425                 .child(EthernetContainerPac.class).child(EthernetContainerCurrentProblems.class).build();
426
427         // reading all the current-problems list for this specific LTP and LP
428         EthernetContainerCurrentProblems problems = netconfAccessor.getTransactionUtils().readData(
429                 netconfAccessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, etherneContainerCurrentProblem_IID);
430
431         if (problems == null) {
432             log.debug("DBRead Id {} no EthernetContainerCurrentProblems", ltpUuid);
433         } else if (problems.getCurrentProblemList() == null) {
434             log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);
435         } else {
436             for (org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ethernet.container.current.problems.CurrentProblemList problem : YangHelper
437                     .getCollection(problems.nonnullCurrentProblemList())) {
438                 resultList.add(netconfAccessor.getNodeId(), (int) problem.getSequenceNumber(), problem.getTimestamp(),
439                         ltpUuid.getValue(), problem.getProblemName(),
440                         Onf14EthernetContainer.mapSeverity(problem.getProblemSeverity()));
441             }
442         }
443     }
444
445     private void readWireInterfaceCurrentProblemForLtp(UniversalId ltpUuid, String localId, FaultData resultList) {
446
447         final Class<WireInterfacePac> clazzPac = WireInterfacePac.class;
448
449         log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}",
450                 clazzPac.getSimpleName(), netconfAccessor.getNodeId().getValue(), ltpUuid.getValue(), localId);
451
452         // constructing the IID needs the augmentation exposed by the wire-interface-2-0 model
453         InstanceIdentifier<WireInterfaceCurrentProblems> wireInterfaceCurrentProblem_IID = InstanceIdentifier
454                 .builder(ControlConstruct.class)
455                 .child(LogicalTerminationPoint.class, new LogicalTerminationPointKey(ltpUuid))
456                 .child(LayerProtocol.class, new LayerProtocolKey(localId))
457                 .augmentation(
458                         org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.LayerProtocol1.class)
459                 .child(WireInterfacePac.class).child(WireInterfaceCurrentProblems.class).build();
460
461         // reading all the current-problems list for this specific LTP and LP
462         WireInterfaceCurrentProblems problems = netconfAccessor.getTransactionUtils().readData(
463                 netconfAccessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, wireInterfaceCurrentProblem_IID);
464
465         if (problems == null) {
466             log.debug("DBRead Id {} no WireInterfaceCurrentProblems", ltpUuid);
467         } else if (problems.getCurrentProblemList() == null) {
468             log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);
469         } else {
470             for (org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.wire._interface.current.problems.CurrentProblemList problem : YangHelper
471                     .getCollection(problems.nonnullCurrentProblemList())) {
472                 resultList.add(netconfAccessor.getNodeId(), (int) problem.getSequenceNumber(), problem.getTimestamp(),
473                         ltpUuid.getValue(), problem.getProblemName(),
474                         Onf14WireInterface.mapSeverity(problem.getProblemSeverity()));
475             }
476         }
477     }
478
479     private Optional<ControlConstruct> readControlConstruct(NetconfBindingAccessor netconfAccessor) {
480         return Optional.ofNullable(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(),
481                 LogicalDatastoreType.CONFIGURATION, CONTROLCONSTRUCT_IID));
482     }
483
484     private @Nullable Equipment readEquipmentInstance(NetconfBindingAccessor accessData, UniversalId equipmentUuid) {
485
486         final Class<?> clazzPac = Equipment.class;
487
488         log.info("DBRead Get equipment for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
489                 accessData.getNodeId().getValue(), equipmentUuid.getValue());
490
491         InstanceIdentifier<Equipment> equipmentIID = InstanceIdentifier.builder(ControlConstruct.class)
492                 .child(Equipment.class, new EquipmentKey(equipmentUuid)).build();
493
494         return accessData.getTransactionUtils().readData(accessData.getDataBroker(), LogicalDatastoreType.CONFIGURATION,
495                 equipmentIID);
496     }
497
498     // defining a structure that can map the LP local-id and its corresponding LTP uuid
499     private class TechnologySpecificPacKeys {
500
501         private UniversalId ltpUuid;
502         private String localId;
503
504         public TechnologySpecificPacKeys(UniversalId uuid, String lId) {
505             this.ltpUuid = uuid;
506             this.localId = lId;
507         }
508
509         public UniversalId getLtpUuid() {
510             return ltpUuid;
511         }
512
513         public String getLocalId() {
514             return localId;
515         }
516
517         @SuppressWarnings("unused")
518         public void setLtpUuid(UniversalId uuid) {
519             this.ltpUuid = uuid;
520         }
521
522         @SuppressWarnings("unused")
523         public void setLocalId(String lId) {
524             this.localId = lId;
525         }
526     }
527
528
529     /**
530      * LOG the newly added problems of the interface pac
531      *
532      * @param idxStart
533      * @param uuid
534      * @param resultList
535      */
536     private void debugResultList(String uuid, FaultData resultList, int idxStart) {
537         StringBuilder sb = new StringBuilder();
538         int idx = 0;
539         for (int t = idxStart; t < resultList.size(); t++) {
540             sb.append(idx++);
541             sb.append(":{");
542             sb.append(resultList.get(t));
543             sb.append('}');
544         }
545         log.debug("Found problems {} {}", uuid, sb);
546     }
547
548 }