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