2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
16 * ============LICENSE_END==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave;
22 import java.lang.reflect.Constructor;
23 import java.lang.reflect.InvocationTargetException;
24 import java.util.Collection;
25 import java.util.Optional;
26 import org.eclipse.jdt.annotation.NonNull;
27 import org.onap.ccsdk.features.sdnr.wt.common.YangHelper;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.pm.PerformanceDataAirInterface170324Builder;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.notifications.NotificationWorker;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp;
36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
37 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
38 import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService;
39 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
40 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
42 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceCurrentProblemTypeG;
43 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceDiversityCurrentProblemTypeG;
44 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceHistoricalPerformanceTypeG;
45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AttributeValueChangedNotification;
46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerCurrentProblemTypeG;
47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerHistoricalPerformanceTypeG;
48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MicrowaveModelListener;
49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPac;
50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPacKey;
51 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePac;
52 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePacKey;
53 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPac;
54 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPacKey;
55 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePac;
56 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePacKey;
57 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePac;
58 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePacKey;
59 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPac;
60 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPacKey;
61 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ObjectCreationNotification;
62 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ObjectDeletionNotification;
63 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ProblemNotification;
64 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.SeverityType;
65 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.StructureCurrentProblemTypeG;
66 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems;
67 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceConfiguration;
68 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceCurrentProblems;
69 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceHistoricalPerformances;
70 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerCurrentProblems;
71 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances;
72 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems;
73 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems;
74 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.tdm.container.pac.TdmContainerCurrentProblems;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType;
80 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
81 import org.opendaylight.yangtools.yang.binding.NotificationListener;
82 import org.opendaylight.yangtools.yang.common.QName;
83 import org.slf4j.Logger;
84 import org.slf4j.LoggerFactory;
87 public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, MicrowaveModelListener {
89 private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev170324.class);
91 public static final QName QNAME = MwAirInterfacePac.QNAME;
94 private final NotificationService microwaveModelListener;
95 private final NetconfBindingAccessor acessor;
96 private final TransactionUtils genericTransactionUtils;
97 private final FaultService faultService;
99 private Optional<NotificationWorker<EventlogEntity>> notificationQueue;
101 private final WebsocketManagerService notificationService;
104 * @param acessor to access device
106 public WrapperMicrowaveModelRev170324(@NonNull NetconfBindingAccessor acessor,
107 @NonNull DeviceManagerServiceProvider serviceProvider) {
108 this.acessor = acessor;
109 this.genericTransactionUtils = acessor.getTransactionUtils();
110 this.microwaveModelListener = serviceProvider.getNotificationService();
111 this.faultService = serviceProvider.getFaultService();
112 this.notificationService = serviceProvider.getWebsocketService();
113 this.notificationQueue = Optional.empty();
116 /*-----------------------------------------------------------------------------
120 @SuppressWarnings("unchecked")
122 public <T extends NotificationListener> T getNotificationListener() {
127 public void setNotificationQueue(NotificationWorker<EventlogEntity> notificationQueue) {
128 this.notificationQueue = Optional.of(notificationQueue);
131 /*-----------------------------------------------------------------------------
132 * Interface functions
136 public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid,
137 FaultData resultList) {
141 readTheFaultsOfMwAirInterfacePac(uuid, resultList);
144 case ETHERNETCONTAINER12:
145 readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
149 readTheFaultsOfMwTdmContainerPac(uuid, resultList);
153 if (lpClass == MwHybridMwStructurePac.class) {
154 readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
156 } else if (lpClass == MwAirInterfaceDiversityPac.class) {
157 readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
159 } else if (lpClass == MwPureEthernetStructurePac.class) {
160 readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
163 LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
167 // No alarms supported
169 case ETHERNETCONTAINER10:
171 LOG.warn("Unassigned or not expected lp in model {}", lpName);
176 public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName,
178 PerformanceDataLtp res = new PerformanceDataLtp();
179 readAirInterfacePerformanceData(lp, res);
180 readEthernetContainerPerformanceData(lp, res);
186 public Class<?> getClassForLtpExtension(QName qName) {
188 if (qName.equals(MwAirInterfacePac.QNAME)) {
189 res = MwAirInterfacePac.class;
190 } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) {
191 res = MwAirInterfaceDiversityPac.class;
192 } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) {
193 res = MwPureEthernetStructurePac.class;
194 } else if (qName.equals(MwHybridMwStructurePac.QNAME)) {
195 res = MwHybridMwStructurePac.class;
196 } else if (qName.equals(MwEthernetContainerPac.QNAME)) {
197 res = MwEthernetContainerPac.class;
198 } else if (qName.equals(MwTdmContainerPac.QNAME)) {
199 res = MwTdmContainerPac.class;
201 LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res));
206 public void onObjectCreationNotification(ObjectCreationNotification notification) {
207 LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName());
208 if (notification != null) {
209 // Send devicemanager specific notification for database and ODLUX
210 microwaveModelListener.creationNotification(acessor.getNodeId(), notification.getCounter(),
211 notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue());
212 // Send model specific notification to WebSocketManager
213 notificationService.sendNotification(notification, acessor.getNodeId(),
214 ObjectCreationNotification.QNAME, notification.getTimeStamp());
219 public void onObjectDeletionNotification(ObjectDeletionNotification notification) {
220 LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
221 if (notification != null) {
222 // Send devicemanager specific notification for database and ODLUX
223 microwaveModelListener.deletionNotification(acessor.getNodeId(), notification.getCounter(),
224 notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue());
225 // Send model specific notification to WebSocketManager
226 notificationService.sendNotification(notification, acessor.getNodeId(),
227 ObjectDeletionNotification.QNAME, notification.getTimeStamp());
232 public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) {
233 LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName());
234 EventlogEntity beventlogEntity = new EventlogBuilder().setNodeId(acessor.getNodeId().getValue())
235 .setCounter(notification.getCounter()).setTimestamp(notification.getTimeStamp())
236 .setObjectId(Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue())
237 .setAttributeName(notification.getAttributeName()).setNewValue(notification.getNewValue()).build();
238 // Send devicemanager specific notification for database and ODLUX
239 microwaveModelListener.eventNotification(beventlogEntity);
240 // Send model specific notification to WebSocketManager
241 notificationService.sendNotification(notification, acessor.getNodeId(),
242 AttributeValueChangedNotification.QNAME, notification.getTimeStamp());
243 if (notificationQueue.isPresent()) {
244 notificationQueue.get().put(beventlogEntity);
249 public void onProblemNotification(ProblemNotification notification) {
251 LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
252 FaultlogEntity faultAlarm = new FaultlogBuilder().setObjectId(notification.getObjectIdRef().getValue())
253 .setProblem(notification.getProblem()).setSourceType(SourceType.Netconf)
254 .setTimestamp(notification.getTimeStamp())
255 .setNodeId(this.acessor.getNodeId().getValue())
256 .setSeverity(mapSeverity(notification.getSeverity())).setCounter(notification.getCounter())
258 // Send devicemanager specific notification for database and ODLUX
259 faultService.faultNotification(faultAlarm);
260 // Send model specific notification to WebSocketManager
261 notificationService.sendNotification(notification, acessor.getNodeId(), ProblemNotification.QNAME,
262 notification.getTimeStamp());
265 /*-----------------------------------------------------------------------------
266 * Reading problems for specific interface pacs
270 * Read problems of specific interfaces
272 * @param uuId Universal Id String of the interface
273 * @return number of alarms
275 private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid, FaultData resultList) {
277 final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
279 String mountpointId = acessor.getNodeId().getValue();
280 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
281 mountpointId, interfacePacUuid.getValue());
283 // Step 2.2: construct data and the relative iid
284 InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID =
285 InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
286 .child(AirInterfaceCurrentProblems.class).build();
288 // Step 2.3: read to the config data store
289 AirInterfaceCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
290 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
292 if (problems == null) {
293 LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
295 for (AirInterfaceCurrentProblemTypeG problem : YangHelper
296 .getCollection(problems.nonnullCurrentProblemList())) {
297 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
298 interfacePacUuid.getValue(), problem.getProblemName(),
299 mapSeverity(problem.getProblemSeverity()));
307 * Read problems of specific interfaces
309 * @param uuId Universal index of Interfacepac
310 * @return number of alarms
312 private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid, FaultData resultList) {
314 final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
316 String mountpointId = acessor.getNodeId().getValue();
317 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
318 mountpointId, interfacePacUuid.getValue());
320 InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
321 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid))
322 .child(EthernetContainerCurrentProblems.class).build();
324 EthernetContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
325 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
326 if (problems == null) {
327 LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid);
329 for (ContainerCurrentProblemTypeG problem : YangHelper
330 .getCollection(problems.nonnullCurrentProblemList())) {
331 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
332 interfacePacUuid.getValue(), problem.getProblemName(),
333 mapSeverity(problem.getProblemSeverity()));
340 * Read problems of specific interfaces
342 * @param uuId Universal index of Interfacepac
343 * @return number of alarms
345 private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid, FaultData resultList) {
347 final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
348 final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
350 String mountpointId = acessor.getNodeId().getValue();
351 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
352 mountpointId, interfacePacUuid.getValue());
354 InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
355 .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build();
357 AirInterfaceDiversityCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
358 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
359 if (problems == null) {
360 LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid);
362 for (AirInterfaceDiversityCurrentProblemTypeG problem : YangHelper
363 .getCollection(problems.nonnullCurrentProblemList())) {
364 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
365 interfacePacUuid.getValue(), problem.getProblemName(),
366 mapSeverity(problem.getProblemSeverity()));
373 * Read problems of specific interfaces
375 * @param uuId Universal index of Interfacepac
376 * @return number of alarms
378 private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid, FaultData resultList) {
380 final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
381 final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
383 String mountpointId = acessor.getNodeId().getValue();
384 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
385 mountpointId, interfacePacUuid.getValue());
387 InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
388 .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
390 PureEthernetStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
391 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
392 if (problems == null) {
393 LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid);
395 for (StructureCurrentProblemTypeG problem : YangHelper
396 .getCollection(problems.nonnullCurrentProblemList())) {
397 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
398 interfacePacUuid.getValue(), problem.getProblemName(),
399 mapSeverity(problem.getProblemSeverity()));
406 * Read problems of specific interfaces
408 * @param uuId Universal index of Interfacepac
409 * @return number of alarms
411 private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid, FaultData resultList) {
413 final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
414 final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
416 String mountpointId = acessor.getNodeId().getValue();
417 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
418 mountpointId, interfacePacUuid.getValue());
420 InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
421 .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
423 HybridMwStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
424 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
425 if (problems == null) {
426 LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid);
428 for (StructureCurrentProblemTypeG problem : YangHelper
429 .getCollection(problems.nonnullCurrentProblemList())) {
430 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
431 interfacePacUuid.getValue(), problem.getProblemName(),
432 mapSeverity(problem.getProblemSeverity()));
439 * Read problems of specific interfaces. TODO Goal for future implementation without usage of explicit new. Key is
440 * generated by newInstance() function here to verify this approach.
442 * @param uuId Universal index of Interfacepac
443 * @return number of alarms
444 * @throws SecurityException
445 * @throws NoSuchMethodException
446 * @throws InvocationTargetException
447 * @throws IllegalArgumentException
448 * @throws IllegalAccessException
449 * @throws InstantiationException
451 private FaultData readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid, FaultData resultList) {
453 final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
454 final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
455 final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
457 String mountpointId = acessor.getNodeId().getValue();
458 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
459 mountpointId, interfacePacUuid.getValue());
462 // -- Specific part 1
463 Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
464 InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
465 .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
467 // -- Specific part 2
468 TdmContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
469 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
470 if (problems == null) {
471 LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid);
473 // -- Specific part 3
474 for (ContainerCurrentProblemTypeG problem : YangHelper
475 .getCollection(problems.nonnullCurrentProblemList())) {
476 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
477 interfacePacUuid.getValue(), problem.getProblemName(),
478 mapSeverity(problem.getProblemSeverity()));
481 } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
482 | IllegalArgumentException | InvocationTargetException e) {
483 LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
489 * Read and add performance data
491 * @param lp to read from
492 * @param result Object to be filled with data
495 private @NonNull PerformanceDataLtp readAirInterfacePerformanceData(Lp lp, PerformanceDataLtp result) {
497 LOG.debug("DBRead Get {} MWAirInterfacePac: {}", acessor.getNodeId(), lp.getUuid());
499 UniversalId mwAirInterfacePacuuId = lp.getUuid();
500 // Step 2.1: construct data and the relative iid
501 InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID =
502 InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
503 .child(AirInterfaceConfiguration.class).build();
504 AirInterfaceConfiguration airConfiguration = acessor.getTransactionUtils().readData(acessor.getDataBroker(),
505 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
507 if (airConfiguration == null) {
508 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
511 // Step 2.2: construct data and the relative iid
512 InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID =
513 InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
514 .child(AirInterfaceHistoricalPerformances.class).build();
516 // Step 2.3: read to the config data store
517 AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtils.readData(
518 acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
520 if (airHistoricalPerformanceData == null) {
521 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances",
522 mwAirInterfacePacuuId);
524 // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
525 Collection<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
526 YangHelper.getCollection(airHistoricalPerformanceData.nonnullHistoricalPerformanceDataList());
527 LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
528 airHistPMList.size());
529 for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistPMList) {
530 result.add(new PerformanceDataAirInterface170324Builder(acessor.getNodeId(), lp, pmRecord,
535 LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, result.size());
540 private @NonNull PerformanceDataLtp readEthernetContainerPerformanceData(Lp lp, PerformanceDataLtp result) {
541 final String myName = "MWEthernetContainerPac";
543 String mountpointId = acessor.getNodeId().getValue();
545 LOG.debug("DBRead Get {} : {}", mountpointId, myName, lp.getUuid());
547 UniversalId ethContainerPacuuId = lp.getUuid();
548 // Step 2.2: construct data and the relative iid
549 InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
550 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId))
551 .child(EthernetContainerHistoricalPerformances.class).build();
553 // Step 2.3: read to the config data store
554 EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = acessor.getTransactionUtils()
555 .readData(acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID);
557 if (ethContainerHistoricalPerformanceData == null) {
558 LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
560 Collection<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
561 YangHelper.getCollection(
562 ethContainerHistoricalPerformanceData.nonnullHistoricalPerformanceDataList());
563 LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
564 for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
565 result.add(new PerformanceDataAirInterface170324Builder(acessor.getNodeId(), lp, pmRecord));
568 LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, result.size());
572 private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType mapSeverity(
573 SeverityType severity) {
575 Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType> res =
576 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType
577 .forName(severity.name());
579 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.NonAlarmed);