2 * Copyright (c) 2017 highstreet technologies GmbH and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.mwtn.base.netconf;
11 import java.lang.reflect.Constructor;
12 import java.lang.reflect.InvocationTargetException;
13 import java.util.ArrayList;
14 import java.util.Collections;
15 import java.util.Iterator;
16 import java.util.List;
17 import java.util.concurrent.CopyOnWriteArrayList;
19 import javax.annotation.Nonnull;
20 import javax.annotation.Nullable;
22 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
23 import org.opendaylight.controller.md.sal.binding.api.MountPoint;
24 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
25 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
26 import org.opendaylight.mwtn.base.internalTypes.InternalDateAndTime;
27 import org.opendaylight.mwtn.base.internalTypes.InternalSeverity;
28 import org.opendaylight.mwtn.base.internalTypes.InventoryInformation;
29 import org.opendaylight.mwtn.devicemanager.impl.ProviderClient;
30 import org.opendaylight.mwtn.devicemanager.impl.database.service.HtDatabaseEventsService;
31 import org.opendaylight.mwtn.devicemanager.impl.listener.MicrowaveEventListener12;
32 import org.opendaylight.mwtn.devicemanager.impl.xml.ProblemNotificationXml;
33 import org.opendaylight.mwtn.devicemanager.impl.xml.WebSocketServiceClient;
34 import org.opendaylight.mwtn.performancemanager.impl.database.types.EsHistoricalPerformance15Minutes;
35 import org.opendaylight.mwtn.performancemanager.impl.database.types.EsHistoricalPerformance24Hours;
36 //import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.networkelement.currentproblemlist.rev161120.GenericCurrentProblemType;
37 //import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.networkelement.currentproblemlist.rev161120.NetworkElementCurrentProblems;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceList;
39 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListKey;
40 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.PortDsEntry;
41 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsList;
42 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentity;
43 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.Equipment;
44 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.EquipmentKey;
45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension;
48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp;
50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType;
51 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
52 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceCurrentProblemTypeG;
53 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceDiversityCurrentProblemTypeG;
54 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceHistoricalPerformanceTypeG;
55 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerCurrentProblemTypeG;
56 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerHistoricalPerformanceTypeG;
57 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPac;
58 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPacKey;
59 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePac;
60 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePacKey;
61 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPac;
62 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPacKey;
63 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePac;
64 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePacKey;
65 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePac;
66 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePacKey;
67 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPac;
68 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPacKey;
69 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.StructureCurrentProblemTypeG;
70 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems;
71 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceConfiguration;
72 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceCurrentProblems;
73 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceHistoricalPerformances;
74 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerCurrentProblems;
75 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances;
76 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems;
77 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems;
78 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.tdm.container.pac.TdmContainerCurrentProblems;
79 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac;
80 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.pac.NetworkElementCurrentProblems;
81 //import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac;
82 //import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.pac.NetworkElementCurrentProblems;
83 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.ethernet.conditional.packages.rev170402.EthernetPac;
84 import org.opendaylight.yangtools.concepts.ListenerRegistration;
85 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
86 import org.opendaylight.yangtools.yang.common.QName;
87 import org.slf4j.Logger;
88 import org.slf4j.LoggerFactory;
90 import com.google.common.base.Optional;
93 * Get information over NETCONF device according to ONF Coremodel. Read
94 * networkelement and conditional packages.
96 * Get conditional packages from Networkelement Possible interfaces are: MWPS,
97 * LTP(MWPS-TTP), MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface
98 * ETH-CTP,LTP(Client), MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD),
99 * MWAirInterfaceDiversityPac,
100 * MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
101 * ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP),
102 * ,MicrowaveModel-ObjectClasses-PureEthernetStructure
107 public class ONFCoreNetworkElement12 extends ONFCoreNetworkElementBase {
109 private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12.class);
111 private static final List<Extension> EMPTYLTPEXTENSIONLIST = new ArrayList<>();
112 // private static final List<Ltp> EMPTYLTPLIST = new ArrayList<>();
114 private static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier
115 .builder(NetworkElement.class).build();
117 private static final InstanceIdentifier<InstanceList> PTPINSTANCES_IID = InstanceIdentifier
118 .builder(InstanceList.class, new InstanceListKey(1)).build();
120 /*-----------------------------------------------------------------------------
124 // Non specific part. Used by all functions.
125 /** interfaceList is used by PM task and should be synchonized */
126 private final @Nonnull List<Lp> interfaceList = Collections.synchronizedList(new CopyOnWriteArrayList<>());
127 private final @Nonnull MicrowaveEventListener12 microwaveEventListener;
128 private @Nullable NetworkElement optionalNe = null;
130 // Performance monitoring specific part
131 /** Lock for the PM access specific elements that could be null */
132 private final @Nonnull Object pmLock = new Object();
133 private @Nullable Iterator<Lp> interfaceListIterator = null;
134 /** Actual pmLp used during iteration over interfaces */
135 private @Nullable Lp pmLp = null;
137 // Device monitoring specific part
138 /** Lock for the DM access specific elements that could be null */
139 private final @Nonnull Object dmLock = new Object();
141 * Interface used for device monitoring (dm). If not null it contains the
142 * interface that is used for monitoring calls
144 private @Nullable InstanceIdentifier<AirInterfaceCurrentProblems> dmAirIfCurrentProblemsIID = null;
145 private final boolean isNetworkElementCurrentProblemsSupporting12;
146 private ListenerRegistration<MicrowaveEventListener12> listenerRegistrationresult;
148 /*-----------------------------------------------------------------------------
155 * @param mountPointNodeName
157 * @param capabilities
158 * of the specific network element
159 * @param netconfNodeDataBroker
160 * for the network element specific data
161 * @param webSocketService
162 * to forward event notifications
163 * @param databaseService
164 * to access the database
165 * @param dcaeProvider
166 * to forward problem / change notifications
168 private ONFCoreNetworkElement12(String mountPointNodeName, Capabilities capabilities,
169 DataBroker netconfNodeDataBroker, WebSocketServiceClient webSocketService,
170 HtDatabaseEventsService databaseService, ProviderClient dcaeProvider,
171 @Nullable ProviderClient aotsmClient) {
173 super(mountPointNodeName, netconfNodeDataBroker, capabilities);
175 // Create MicrowaveService here
176 this.microwaveEventListener = new MicrowaveEventListener12(mountPointNodeName, webSocketService,
177 databaseService, dcaeProvider, aotsmClient);
178 this.isNetworkElementCurrentProblemsSupporting12 = capabilities.isSupportingNamespace(NetworkElementPac.QNAME);
179 LOG.debug("support necurrent-problem-list=" + this.isNetworkElementCurrentProblemsSupporting12);
180 LOG.info("Create NE instance {}", InstanceList.QNAME.getLocalName());
184 * Check capabilities are matching the this specific implementation and create
185 * network element representation if so.
187 * @param mountPointNodeName
189 * @param capabilities
190 * of the specific network element
191 * @param netconfNodeDataBroker
192 * for the network element specific data
193 * @param webSocketService
194 * to forward event notifications
195 * @param databaseService
196 * to access the database
197 * @param dcaeProvider
198 * to forward problem / change notifications
199 * @return created Object if conditions are OK or null if not.
201 public static @Nullable ONFCoreNetworkElement12 build(String mountPointNodeName, Capabilities capabilities,
202 DataBroker netconfNodeDataBroker, WebSocketServiceClient webSocketService,
203 HtDatabaseEventsService databaseService, ProviderClient dcaeProvider,
204 @Nullable ProviderClient aotsmClient) {
205 return checkType(capabilities)
206 ? new ONFCoreNetworkElement12(mountPointNodeName, capabilities, netconfNodeDataBroker, webSocketService,
207 databaseService, dcaeProvider, aotsmClient)
211 /*-----------------------------------------------------------------------------
215 private static boolean checkType(Capabilities capabilities) {
216 return capabilities.isSupportingNamespace(NetworkElement.QNAME);
220 * Prepare check by updating NE state and reading all interfaces.
222 * @see org.opendaylight.mwtn.deviceMonitor.impl.DeviceMonitorSupport#prepareCheck()
225 public void prepareCheck() {
226 synchronized (dmLock) {
227 boolean change = readNetworkElementAndInterfaces();
229 int problems = microwaveEventListener.removeAllCurrentProblemsOfNode();
230 List<ProblemNotificationXml> resultList = readAllCurrentProblemsToDB();
231 microwaveEventListener.initCurrentProblem(resultList);
232 LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", mountPointNodeName,
233 getUuId(), problems, resultList.size());
241 * @see org.opendaylight.mwtn.deviceMonitor.impl.DeviceMonitorSupport#checkAndConnectionToMediatorIsOk()
244 public boolean checkAndConnectionToMediatorIsOk() {
245 synchronized (dmLock) {
246 return optionalNe != null;
251 * New implementation to interpret status with empty LTP List as notConnected =>
254 * @see org.opendaylight.mwtn.deviceMonitor.impl.DeviceMonitorSupport#checkAndConnectionToNeIsOk()
257 public boolean checkAndConnectionToNeIsOk() {
258 synchronized (dmLock) {
259 return optionalNe != null && !interfaceList.isEmpty();
265 * /** Check connection by requesting NetworkElement object
267 * @see org.opendaylight.mwtn.base.netconf.ONFCoreNetworkElementRepresentation#
268 * checkAndConnectionToMediatorIsOk() /
270 * @Override public boolean checkAndConnectionToMediatorIsOk() {
272 * //Read to the config data store AtomicBoolean noErrorIndicator = new
273 * AtomicBoolean(); AtomicReference<String> status = new AtomicReference<>();
275 * GenericTransactionUtils.readDataOptionalWithStatus(netconfNodeDataBroker,
276 * LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID, noErrorIndicator,
278 * LOG.debug("Status noErrorIndicator: {} statusTxt:{}",noErrorIndicator.get(),
279 * status.get()); return noErrorIndicator.get(); }
283 * /** Check connection only possible if AirInterface (MWTN) exists. Request
285 * @see org.opendaylight.mwtn.base.netconf.ONFCoreNetworkElementRepresentation#
286 * checkAndConnectionToNeIsOk() /
288 * @Override public boolean checkAndConnectionToNeIsOk() { synchronized (dmLock)
289 * { if (dmAirIfCurrentProblemsIID != null) { //Read to the config data store
290 * AtomicBoolean noErrorIndicator = new AtomicBoolean(); AtomicReference<String>
291 * status = new AtomicReference<>();
293 * GenericTransactionUtils.readDataOptionalWithStatus(netconfNodeDataBroker,
294 * LogicalDatastoreType.OPERATIONAL, dmAirIfCurrentProblemsIID,
295 * noErrorIndicator, status);
296 * LOG.debug("Status noErrorIndicator: {} statusTxt:{}",noErrorIndicator.get(),
297 * status.get()); return noErrorIndicator.get(); } } return true; }
300 /*-----------------------------------------------------------------------------
305 * Query synchronization information out of NE
309 public void initSynchronizationExtension() {
310 // ClockIdentityType vv;
312 if (!capabilities.isSupportingNamespace(InstanceList.QNAME)) {
313 LOG.debug("Mountpoint {} does not support PTP", mountPointNodeName);
315 StringBuffer sb = new StringBuffer();
316 sb.append("NE " + mountPointNodeName + " does support synchronisation.\n");
317 InstanceList ptpInstance = readPTPClockInstances();
318 if (ptpInstance != null) {
319 List<PortDsList> dsList = ptpInstance.getPortDsList();
320 if (dsList != null) {
322 for (PortDsEntry portDs : ptpInstance.getPortDsList()) {
323 PortIdentity portId = portDs.getPortIdentity();
324 if (portId != null) {
326 sb.append(portId.getPortNumber());
327 sb.append("]{ ClockId: ");
328 sb.append(portId.getClockIdentity());
329 sb.append(", Portstate: ");
330 sb.append(portDs.getPortState());
333 sb.append("Incomplete port #" + t + ", ");
338 sb.append("dsList contains null");
341 sb.append("ptpInstance equals null");
342 LOG.trace(sb.toString());
344 } catch (Exception e) {
345 LOG.info("Inconsistent synchronisation structure: " + e.getMessage());
351 private InstanceList readPTPClockInstances() {
352 return GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL,
356 /*-----------------------------------------------------------------------------
357 * Problem/Fault related functions
361 * Read during startup all relevant structure and status parameters from device
364 public void initialReadFromNetworkElement() {
365 // optionalNe.getLtp().get(0).getLp();
366 LOG.debug("Get info about {}", mountPointNodeName);
368 int problems = microwaveEventListener.removeAllCurrentProblemsOfNode();
369 LOG.debug("Removed all {} problems from database at registration", problems);
371 // Step 2.1: access data broker within this mount point
372 LOG.debug("DBRead start");
374 // Step 2.2: read ne from data store
375 readNetworkElementAndInterfaces();
377 // Step 2.3: read the existing faults and add to DB
378 List<ProblemNotificationXml> resultList = readAllCurrentProblemsToDB();
380 microwaveEventListener.initCurrentProblem(resultList);
382 LOG.info("Found info at {} for device {} number of problems: {}", mountPointNodeName, getUuId(),
386 public InventoryInformation getInventoryInformation() {
387 return this.getInventoryInformation(null);
390 public @Nonnull InventoryInformation getInventoryInformation(String layerProtocolFilter) {
392 List<String> uuids = new ArrayList<String>();
393 String type=InventoryInformation.UNKNOWN;
394 String model=InventoryInformation.UNKNOWN;
395 String vendor=InventoryInformation.UNKNOWN;
396 String ipv4=InventoryInformation.UNKNOWN;
397 String ipv6=InventoryInformation.UNKNOWN;
398 LOG.debug("request inventory information. filter:"+layerProtocolFilter);
399 if (optionalNe != null) {
402 for(Lp lp : this.interfaceList)
404 if(layerProtocolFilter==null || layerProtocolFilter.isEmpty())
405 uuids.add(lp.getUuid().getValue());
406 else if(lp.getLayerProtocolName()!=null &&
407 lp.getLayerProtocolName().getValue()!=null &&
408 lp.getLayerProtocolName().getValue().equals(layerProtocolFilter))
409 uuids.add(lp.getUuid().getValue());
411 LOG.debug("uuids found: {}",uuids);
413 List<Extension> extensions = optionalNe.getExtension();
416 String topLevelEqUuid=null;
417 for(Extension e: extensions)
419 if(e.getValueName()!=null)
421 if(e.getValueName().equals("top-level-equipment") && e.getValue()!=null)
423 topLevelEqUuid=e.getValue();
424 LOG.debug("top level equipment found: "+topLevelEqUuid);
426 else if(e.getValueName().equals("neIpAddress") && e.getValue()!=null)
429 LOG.debug("ip information found: "+ipv4);
433 if(ipv4==InventoryInformation.UNKNOWN)
435 LOG.debug("no ip information found");
437 if(topLevelEqUuid!=null)
439 Equipment e = this.readEquipmentPac(topLevelEqUuid);
442 if( e.getManufacturedThing()!=null &&
443 e.getManufacturedThing().getEquipmentType()!=null &&
444 e.getManufacturedThing().getEquipmentType().getTypeName()!=null)
446 type = e.getManufacturedThing().getEquipmentType().getTypeName();
447 LOG.debug("equipment type found: "+type);
451 LOG.debug("no equipment type found");
453 if( e.getManufacturedThing()!=null &&
454 e.getManufacturedThing().getEquipmentType()!=null &&
455 e.getManufacturedThing().getEquipmentType().getModelIdentifier()!=null)
457 model=e.getManufacturedThing().getEquipmentType().getModelIdentifier();
458 LOG.debug("model identifier found:"+model);
462 LOG.debug("no model identifier found");
464 if(e.getManufacturedThing()!=null &&
465 e.getManufacturedThing().getManufacturerProperties()!=null &&
466 e.getManufacturedThing().getManufacturerProperties().getManufacturerIdentifier()!=null)
468 vendor = e.getManufacturedThing().getManufacturerProperties().getManufacturerIdentifier();
469 LOG.debug("manifacturer found: "+ vendor);
473 LOG.debug("no manifacturer found");
479 LOG.debug("no top level equipment found");
484 LOG.debug("extension list is null");
488 return new InventoryInformation(type, model, vendor, ipv4, ipv6, uuids);
495 * LOG the newly added problems of the interface pac
501 private void debugResultList(String uuid, List<ProblemNotificationXml> resultList, int idxStart) {
502 if (LOG.isDebugEnabled()) {
503 StringBuffer sb = new StringBuffer();
505 for (int t = idxStart; t < resultList.size(); t++) {
508 sb.append(resultList.get(t));
511 LOG.debug("Found problems {} {}", uuid, sb.toString());
516 * Read from NetworkElement and verify LTPs have changed. If the NE has changed,
517 * update to the new structure. From initial state it changes also.
519 private synchronized boolean readNetworkElementAndInterfaces() {
521 LOG.debug("Update mountpoint if changed {}", mountPointNodeName);
523 optionalNe = GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL,
526 synchronized (pmLock) {
527 boolean change = false;
529 if (optionalNe == null) {
530 LOG.debug("Unable to read NE data for mountpoint {}", mountPointNodeName);
531 if (!interfaceList.isEmpty()) {
532 interfaceList.clear();
533 interfaceListIterator = null;
538 LOG.debug("Mountpoint '{}' NE-Name '{}'", mountPointNodeName, optionalNe.getName().toString());
539 List<Lp> actualInterfaceList = getLtpList(optionalNe);
540 if (!interfaceList.equals(actualInterfaceList)) {
541 LOG.debug("Mountpoint '{}' Update LTP List. Elements {}", mountPointNodeName,
542 actualInterfaceList.size());
543 interfaceList.clear();
544 interfaceList.addAll(actualInterfaceList);
545 interfaceListIterator = null;
554 * Read current problems of AirInterfaces and EthernetContainer according to NE
557 * @return List with all problems
559 private List<ProblemNotificationXml> readAllCurrentProblemsToDB() {
561 // Step 2.3: read the existing faults and add to DB
562 List<ProblemNotificationXml> resultList = new ArrayList<>();
563 int idxStart; // Start index for debug messages
566 synchronized (pmLock) {
567 for (Lp ltp : interfaceList) {
569 idxStart = resultList.size();
570 uuid = ltp.getUuid();
571 Class<?> lpClass = getLpExtension(ltp);
573 ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(ltp.getLayerProtocolName());
576 readTheFaultsOfMwAirInterfacePac(uuid, resultList);
577 synchronized (dmLock) {
578 if (dmAirIfCurrentProblemsIID == null) {
579 dmAirIfCurrentProblemsIID = getMWAirInterfacePacIId(uuid);
584 case EthernetContainer12:
585 readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
589 readTheFaultsOfMwTdmContainerPac(uuid, resultList);
593 if (lpClass == MwHybridMwStructurePac.class) {
594 readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
596 } else if (lpClass == MwAirInterfaceDiversityPac.class) {
597 readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
599 } else if (lpClass == MwPureEthernetStructurePac.class) {
600 readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
603 LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
608 // No alarms supported
610 case EthernetContainer10:
612 LOG.warn("Unassigned or not expected lp in model {}", lpName);
615 debugResultList(uuid.getValue(), resultList, idxStart);
620 // Step 2.4: Read other problems from mountpoint
621 if (isNetworkElementCurrentProblemsSupporting10) {
622 idxStart = resultList.size();
623 readNetworkElementCurrentProblems10(resultList);
624 debugResultList("CurrentProblems10", resultList, idxStart);
627 // Step 2.5: Read other problems from mountpoint
628 if (isNetworkElementCurrentProblemsSupporting12) {
629 idxStart = resultList.size();
630 readNetworkElementCurrentProblems12(resultList);
631 debugResultList("CurrentProblems12", resultList, idxStart);
639 * Get uuid of Optional NE.
641 * @return Uuid or EMPTY String if optionNE is not available
643 private String getUuId() {
647 uuid = optionalNe != null ? optionalNe.getUuid() != null ? optionalNe.getUuid().getValue() : EMPTY : EMPTY;
648 } catch (NullPointerException e) {
649 // Unfortunately throws null pointer if not definied
655 * Read the NetworkElement part from database.
657 * @return Optional with NetworkElement or empty
660 private NetworkElement readNetworkElement() {
661 // Step 2.2: construct data and the relative iid
662 // The schema path to identify an instance is
663 // <i>CoreModel-CoreNetworkModule-ObjectClasses/NetworkElement</i>
665 * InstanceIdentifier<NetworkElement> networkElementIID = InstanceIdentifier
666 * .builder(NetworkElement.class) .build();
668 // Read to the config data store
669 return GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL,
674 * Get from LayProtocolExtensions the related generated ONF Interface PAC class
675 * which represents it.
678 * logical termination point
679 * @return Class of InterfacePac
682 private static Class<?> getLpExtension(@Nullable Lp ltp) {
684 String capability = EMPTY;
685 String revision = EMPTY;
686 String conditionalPackage = EMPTY;
690 for (Extension e : getExtensionList(ltp)) {
691 if (e.getValueName().contentEquals("capability")) {
692 capability = e.getValue();
693 int idx = capability.indexOf("?");
695 capability = capability.substring(0, idx);
698 if (e.getValueName().contentEquals("revision")) {
699 revision = e.getValue();
701 if (e.getValueName().contentEquals("conditional-package")) {
702 conditionalPackage = e.getValue();
707 // org.opendaylight.yangtools.yang.common.QName.create("urn:onf:params:xml:ns:yang:microwave-model",
708 // "2017-03-24", "mw-air-interface-pac").intern();
709 LOG.info("LpExtension capability={} revision={} conditionalPackage={}", capability, revision,
711 if (!capability.isEmpty() && !revision.isEmpty() && !conditionalPackage.isEmpty()) {
713 QName qName = QName.create(capability, revision, conditionalPackage);
715 if (qName.equals(MwAirInterfacePac.QNAME)) {
716 res = MwAirInterfacePac.class;
717 } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) {
718 res = MwAirInterfaceDiversityPac.class;
719 } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) {
720 res = MwPureEthernetStructurePac.class;
721 } else if (qName.equals(MwHybridMwStructurePac.QNAME)) {
722 res = MwHybridMwStructurePac.class;
723 } else if (qName.equals(MwEthernetContainerPac.QNAME)) {
724 res = MwEthernetContainerPac.class;
725 } else if (qName.equals(MwTdmContainerPac.QNAME)) {
726 res = MwTdmContainerPac.class;
727 } else if (qName.equals(EthernetPac.QNAME)) {
728 res = MwTdmContainerPac.class;
730 LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res));
731 } catch (IllegalArgumentException e) {
732 LOG.debug("Can not create QName from ({}{{}{{}): {}", capability, revision, conditionalPackage,
740 * Read element from class that could be not available
743 * layer termination point
744 * @return List with extension parameters or empty list
747 private static List<Extension> getExtensionList(@Nullable Lp ltp) {
748 if (ltp != null && ltp.getExtension() != null) {
749 return ltp.getExtension();
751 return EMPTYLTPEXTENSIONLIST;
756 * Get List of UUIDs for conditional packages from Networkelement<br>
757 * Possible interfaces are:<br>
758 * MWPS, LTP(MWPS-TTP), MWAirInterfacePac,
759 * MicrowaveModel-ObjectClasses-AirInterface<br>
760 * ETH-CTP,LTP(Client), MW_EthernetContainer_Pac<br>
761 * MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac,
762 * MicrowaveModel-ObjectClasses-AirInterfaceDiversity<br>
763 * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-HybridMwStructure<br>
764 * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-PureEthernetStructure<br>
768 * @return Id List, never null.
770 private static List<Lp> getLtpList(@Nullable NetworkElement ne) {
772 List<Lp> res = Collections.synchronizedList(new ArrayList<Lp>());
775 List<Ltp> ltpRefList = ne.getLtp();
776 if (ltpRefList == null) {
777 LOG.debug("DBRead NE-Interfaces: null");
779 for (Ltp ltRefListE : ltpRefList) {
780 List<Lp> lpList = ltRefListE.getLp();
781 if (lpList == null) {
782 LOG.debug("DBRead NE-Interfaces Reference List: null");
784 for (Lp ltp : lpList) {
785 //// LayerProtocolName layerProtocolName = lpListE.getLayerProtocolName();
786 // UniversalId uuId = lpListE.getUuid();
793 LOG.debug("DBRead NE: null");
797 if (LOG.isDebugEnabled()) {
798 StringBuffer strBuf = new StringBuffer();
800 if (strBuf.length() > 0) {
803 strBuf.append(ltp.getLayerProtocolName().getValue());
805 strBuf.append(ltp.getUuid().getValue());
807 LOG.debug("DBRead NE-Interfaces: {}", strBuf.toString());
814 /*-----------------------------------------------------------------------------
815 * Performance related data
819 * PM MwAirInterfacePac
824 private List<ExtendedAirInterfaceHistoricalPerformanceType12> readTheHistoricalPerformanceDataOfMwAirInterfacePac(
827 String uuId = lp.getUuid().getValue();
829 List<ExtendedAirInterfaceHistoricalPerformanceType12> resultList = new ArrayList<>();
830 LOG.debug("DBRead Get {} MWAirInterfacePac: {}", mountPointNodeName, uuId);
832 UniversalId mwAirInterfacePacuuId = new UniversalId(uuId);
833 // Step 2.1: construct data and the relative iid
834 InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
835 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
836 .child(AirInterfaceConfiguration.class).build();
837 AirInterfaceConfiguration airConfiguration = GenericTransactionUtils.readData(netconfNodeDataBroker,
838 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
840 if (airConfiguration == null) {
841 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
844 // Step 2.2: construct data and the relative iid
845 InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
846 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
847 .child(AirInterfaceHistoricalPerformances.class).build();
849 // Step 2.3: read to the config data store
850 AirInterfaceHistoricalPerformances airHistoricalPerformanceData = GenericTransactionUtils.readData(
851 netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
853 if (airHistoricalPerformanceData == null) {
854 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances",
855 mwAirInterfacePacuuId);
857 // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
858 List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData
859 .getHistoricalPerformanceDataList();
860 LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
861 airHistPMList.size());
862 if (airHistPMList != null) {
863 for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
864 .getHistoricalPerformanceDataList()) {
865 resultList.add(new ExtendedAirInterfaceHistoricalPerformanceType12(pmRecord, airConfiguration));
870 LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, resultList.size());
874 private List<ContainerHistoricalPerformanceTypeG> readTheHistoricalPerformanceDataOfEthernetContainer(Lp lp) {
876 final String myName = "MWEthernetContainerPac";
877 String uuId = lp.getUuid().getValue();
879 List<ContainerHistoricalPerformanceTypeG> resultList = new ArrayList<>();
880 LOG.debug("DBRead Get {} : {}", mountPointNodeName, myName, uuId);
882 UniversalId ethContainerPacuuId = new UniversalId(uuId);
883 // Step 2.2: construct data and the relative iid
884 InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
885 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId))
886 .child(EthernetContainerHistoricalPerformances.class).build();
888 // Step 2.3: read to the config data store
889 EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = GenericTransactionUtils
890 .readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL, ethContainerIID);
892 if (ethContainerHistoricalPerformanceData == null) {
893 LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
896 // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.ethernet.container.historical.performances.g.HistoricalPerformanceDataList
897 List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData
898 .getHistoricalPerformanceDataList();
899 LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
900 if (airHistPMList != null) {
901 for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
902 resultList.add(pmRecord);
906 LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, resultList.size());
911 private List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(Lp lp) {
912 ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(lp.getLayerProtocolName());
916 return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp);
918 case EthernetContainer12:
919 return readTheHistoricalPerformanceDataOfEthernetContainer(lp);
921 case EthernetContainer10:
922 case EthernetPhysical:
927 LOG.debug("Do not read HistoricalPM data for {} {}", lpName, lp.getUuid().getValue());
930 return new ArrayList<>();
934 public AllPm getHistoricalPM() {
936 synchronized (pmLock) {
938 LOG.debug("Enter query PM");
939 AllPm allPm = new AllPm();
942 List<? extends OtnHistoryDataG> resultList = readTheHistoricalPerformanceData(lp);
943 LOG.debug("Got records: {}", resultList.size());
944 // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType
945 GranularityPeriodType granularityPeriod;
946 for (OtnHistoryDataG perf : resultList) {
948 granularityPeriod = perf.getGranularityPeriod();
949 if (granularityPeriod == null) {
950 granularityPeriod = GranularityPeriodType.Unknown;
953 switch (granularityPeriod) {
955 EsHistoricalPerformance15Minutes pm = new EsHistoricalPerformance15Minutes(mountPointNodeName,
956 lp).setHistoricalRecord15Minutes(perf);
961 case Period24Hours: {
962 EsHistoricalPerformance24Hours pm = new EsHistoricalPerformance24Hours(mountPointNodeName, lp)
963 .setHistoricalRecord24Hours(perf);
964 LOG.debug("Write 24h write to DB");
970 LOG.warn("Unknown granularity {}", perf.getGranularityPeriod());
975 LOG.debug("Deliver normalized records: {}", allPm.size());
978 LOG.debug("Deliver empty, no LTP");
985 public void resetPMIterator() {
986 synchronized (pmLock) {
987 interfaceListIterator = interfaceList.iterator();
989 LOG.debug("PM reset iterator");
993 public boolean hasNext() {
995 synchronized (pmLock) {
996 res = interfaceListIterator != null ? interfaceListIterator.hasNext() : false;
998 LOG.debug("PM hasNext LTP {}", res);
1003 public void next() {
1004 synchronized (pmLock) {
1005 pmLp = interfaceListIterator != null ? interfaceListIterator.next() : null;
1007 LOG.debug("PM next LTP {}", pmLp.getLayerProtocolName().getValue());
1011 public String pmStatusToString() {
1012 StringBuffer res = new StringBuffer();
1013 synchronized (pmLock) {
1014 res.append(pmLp == null ? "no interface" : pmLp.getLayerProtocolName().getValue());
1015 for (Lp lp : interfaceList) {
1017 res.append(lp.getLayerProtocolName().getValue());
1021 return (res.toString());
1024 /*------------------------------------------------------------
1025 * private function to access database
1028 /*-----------------------------------------------------------------------------
1029 * Reading problems for the networkElement V1.0
1032 private List<ProblemNotificationXml> readNetworkElementCurrentProblems10(List<ProblemNotificationXml> resultList) {
1034 LOG.info("DBRead Get {} NetworkElementCurrentProblems", mountPointNodeName);
1036 InstanceIdentifier<org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.networkelement.currentproblemlist.rev161120.NetworkElementCurrentProblems> networkElementCurrentProblemsIID = InstanceIdentifier
1038 org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.networkelement.currentproblemlist.rev161120.NetworkElementCurrentProblems.class)
1041 // Step 2.3: read to the config data store
1042 org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.networkelement.currentproblemlist.rev161120.NetworkElementCurrentProblems problems;
1044 problems = GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL,
1045 networkElementCurrentProblemsIID);
1046 if (problems == null) {
1047 LOG.debug("DBRead no NetworkElementCurrentProblems");
1048 } else if (problems.getCurrentProblemList() == null) {
1049 LOG.debug("DBRead empty CurrentProblemList");
1051 for (org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.networkelement.currentproblemlist.rev161120.GenericCurrentProblemType problem : problems
1052 .getCurrentProblemList()) {
1053 resultList.add(new ProblemNotificationXml(mountPointNodeName, problem.getObjectIdRef(),
1054 problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
1055 problem.getSequenceNumber().toString(),
1056 InternalDateAndTime.valueOf(problem.getTimeStamp())));
1059 } catch (Exception e) {
1060 LOG.warn("DBRead {} NetworkElementCurrentProblems not supported. Message '{}' ", mountPointNodeName,
1066 /*-----------------------------------------------------------------------------
1067 * Reading problems for the networkElement V1.0
1070 private List<ProblemNotificationXml> readNetworkElementCurrentProblems12(List<ProblemNotificationXml> resultList) {
1072 LOG.info("DBRead Get {} NetworkElementCurrentProblems12", mountPointNodeName);
1074 InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac> networkElementCurrentProblemsIID = InstanceIdentifier
1076 org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac.class)
1079 // Step 2.3: read to the config data store
1080 NetworkElementPac problemPac;
1081 NetworkElementCurrentProblems problems;
1083 problemPac = GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL,
1084 networkElementCurrentProblemsIID);
1085 problems = problemPac.getNetworkElementCurrentProblems();
1086 if (problems == null) {
1087 LOG.debug("DBRead no NetworkElementCurrentProblems12");
1088 } else if (problems.getCurrentProblemList() == null) {
1089 LOG.debug("DBRead empty CurrentProblemList12");
1091 for (org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.current.problems.g.CurrentProblemList problem : problems
1092 .getCurrentProblemList()) {
1093 resultList.add(new ProblemNotificationXml(mountPointNodeName, problem.getObjectReference(),
1094 problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
1095 problem.getSequenceNumber().toString(),
1096 InternalDateAndTime.valueOf(problem.getTimeStamp())));
1099 } catch (Exception e) {
1100 LOG.warn("DBRead {} NetworkElementCurrentProblems12 not supported. Message '{}' ", mountPointNodeName,
1107 /*-----------------------------------------------------------------------------
1108 * Reading problems for specific interface pacs
1114 * @param interfacePacUuid
1116 * @return AirInterfaceCurrentProblemsIID
1118 private InstanceIdentifier<AirInterfaceCurrentProblems> getMWAirInterfacePacIId(UniversalId interfacePacUuid) {
1119 InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
1120 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
1121 .child(AirInterfaceCurrentProblems.class).build();
1122 return mwAirInterfaceIID;
1126 * Read problems of specific interfaces
1129 * Universal Id String of the interface
1130 * @return number of alarms
1132 private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid,
1133 List<ProblemNotificationXml> resultList) {
1135 final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
1136 // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class;
1137 // final Class<AirInterfaceCurrentProblems> clazzProblems =
1138 // AirInterfaceCurrentProblems.class;
1139 // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem =
1140 // AirInterfaceCurrentProblemTypeG.class;
1142 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
1143 mountPointNodeName, interfacePacUuid.getValue());
1145 // Step 2.2: construct data and the relative iid
1146 InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
1147 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
1148 .child(AirInterfaceCurrentProblems.class).build();
1150 // Step 2.3: read to the config data store
1151 AirInterfaceCurrentProblems problems = GenericTransactionUtils.readData(netconfNodeDataBroker,
1152 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
1154 if (problems == null) {
1155 LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
1156 } else if (problems.getCurrentProblemList() == null) {
1157 LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
1159 for (AirInterfaceCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
1160 resultList.add(new ProblemNotificationXml(mountPointNodeName, interfacePacUuid.getValue(),
1161 problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
1162 problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
1169 * Read problems of specific interfaces
1172 * Universal index of Interfacepac
1173 * @return number of alarms
1175 private List<ProblemNotificationXml> readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid,
1176 List<ProblemNotificationXml> resultList) {
1178 final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
1179 // final Class<MwEthernetContainerPacKey> clazzPacKey =
1180 // MwEthernetContainerPacKey.class;
1181 // final Class<EthernetContainerCurrentProblems> clazzProblems =
1182 // EthernetContainerCurrentProblems.class;
1183 // final Class<ContainerCurrentProblemTypeG> clazzProblem =
1184 // ContainerCurrentProblemTypeG.class;
1186 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
1187 mountPointNodeName, interfacePacUuid.getValue());
1189 InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
1190 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid))
1191 .child(EthernetContainerCurrentProblems.class).build();
1193 EthernetContainerCurrentProblems problems = GenericTransactionUtils.readData(netconfNodeDataBroker,
1194 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
1195 if (problems == null) {
1196 LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid);
1197 } else if (problems.getCurrentProblemList() == null) {
1198 LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
1200 for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
1201 resultList.add(new ProblemNotificationXml(mountPointNodeName, interfacePacUuid.getValue(),
1202 problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
1203 problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
1210 * Read problems of specific interfaces
1213 * Universal index of Interfacepac
1214 * @return number of alarms
1216 private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid,
1217 List<ProblemNotificationXml> resultList) {
1219 final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
1220 // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey =
1221 // MwAirInterfaceDiversityPacKey.class;
1222 final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
1223 // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem =
1224 // AirInterfaceDiversityCurrentProblemTypeG.class;
1226 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
1227 mountPointNodeName, interfacePacUuid.getValue());
1229 InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
1230 .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build();
1232 AirInterfaceDiversityCurrentProblems problems = GenericTransactionUtils.readData(netconfNodeDataBroker,
1233 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
1234 if (problems == null) {
1235 LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid);
1236 } else if (problems.getCurrentProblemList() == null) {
1237 LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
1239 for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
1240 resultList.add(new ProblemNotificationXml(mountPointNodeName, interfacePacUuid.getValue(),
1241 problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
1242 problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
1249 * Read problems of specific interfaces
1252 * Universal index of Interfacepac
1253 * @return number of alarms
1255 private List<ProblemNotificationXml> readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid,
1256 List<ProblemNotificationXml> resultList) {
1258 final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
1259 // final Class<MwPureEthernetStructurePacKey> clazzPacKey =
1260 // MwPureEthernetStructurePacKey.class;
1261 final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
1262 // final Class<StructureCurrentProblemTypeG> clazzProblem =
1263 // StructureCurrentProblemTypeG.class;
1265 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
1266 mountPointNodeName, interfacePacUuid.getValue());
1268 InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
1269 .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
1271 PureEthernetStructureCurrentProblems problems = GenericTransactionUtils.readData(netconfNodeDataBroker,
1272 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
1273 if (problems == null) {
1274 LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid);
1275 } else if (problems.getCurrentProblemList() == null) {
1276 LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
1278 for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
1279 resultList.add(new ProblemNotificationXml(mountPointNodeName, interfacePacUuid.getValue(),
1280 problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
1281 problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
1288 * Read problems of specific interfaces
1291 * Universal index of Interfacepac
1292 * @return number of alarms
1294 private List<ProblemNotificationXml> readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid,
1295 List<ProblemNotificationXml> resultList) {
1297 final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
1298 // final Class<MwHybridMwStructurePacKey> clazzPacKey =
1299 // MwHybridMwStructurePacKey.class;
1300 final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
1301 // final Class<HybridMwStructureCurrentProblemsG> clazzProblem =
1302 // HybridMwStructureCurrentProblemsG.class;
1304 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
1305 mountPointNodeName, interfacePacUuid.getValue());
1307 InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
1308 .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
1310 HybridMwStructureCurrentProblems problems = GenericTransactionUtils.readData(netconfNodeDataBroker,
1311 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
1312 if (problems == null) {
1313 LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid);
1314 } else if (problems.getCurrentProblemList() == null) {
1315 LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
1317 for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
1318 resultList.add(new ProblemNotificationXml(mountPointNodeName, interfacePacUuid.getValue(),
1319 problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
1320 problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
1327 * Read problems of specific interfaces. TODO Goal for future implementation
1328 * without usage of explicit new. Key is generated by newInstance() function
1329 * here to verify this approach.
1332 * Universal index of Interfacepac
1333 * @return number of alarms
1334 * @throws SecurityException
1335 * @throws NoSuchMethodException
1336 * @throws InvocationTargetException
1337 * @throws IllegalArgumentException
1338 * @throws IllegalAccessException
1339 * @throws InstantiationException
1341 private List<ProblemNotificationXml> readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid,
1342 List<ProblemNotificationXml> resultList) {
1344 final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
1345 final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
1346 final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
1347 // final Class<ContainerCurrentProblemTypeG> clazzProblem =
1348 // ContainerCurrentProblemTypeG.class;
1350 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
1351 mountPointNodeName, interfacePacUuid.getValue());
1354 // -- Specific part 1
1355 Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
1356 InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
1357 .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
1359 // -- Specific part 2
1360 TdmContainerCurrentProblems problems = GenericTransactionUtils.readData(netconfNodeDataBroker,
1361 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
1362 if (problems == null) {
1363 LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid);
1364 } else if (problems.getCurrentProblemList() == null) {
1365 LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
1367 // -- Specific part 3
1368 for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
1369 resultList.add(new ProblemNotificationXml(mountPointNodeName, interfacePacUuid.getValue(),
1370 problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
1371 problem.getSequenceNumber().toString(),
1372 InternalDateAndTime.valueOf(problem.getTimeStamp())));
1375 } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
1376 | IllegalArgumentException | InvocationTargetException e) {
1377 LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
1382 private @Nullable Equipment readEquipmentPac(String interfacePacUuid) {
1384 return this.readEquipmentPac(new UniversalId(interfacePacUuid));
1388 * Read problems of specific interfaces
1390 * @param interfacePacUuid
1391 * Universal index of Equipmentpac
1392 * @return Equipment or null
1394 private @Nullable Equipment readEquipmentPac(UniversalId interfacePacUuid) {
1396 final Class<Equipment> clazzPac = Equipment.class;
1398 LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
1399 mountPointNodeName, interfacePacUuid.getValue());
1401 InstanceIdentifier<Equipment> equipmentIID = InstanceIdentifier
1402 .builder(Equipment.class, new EquipmentKey(interfacePacUuid)).build();
1404 Equipment res = GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL,
1411 * Remove all entries from list
1414 public int removeAllCurrentProblemsOfNode() {
1415 return microwaveEventListener.removeAllCurrentProblemsOfNode();
1419 * Register the listener
1422 public void doRegisterMicrowaveEventListener(MountPoint mountPoint) {
1423 LOG.info("End registration listener for Mountpoint {}", mountPoint.getIdentifier().toString());
1424 final Optional<NotificationService> optionalNotificationService = mountPoint
1425 .getService(NotificationService.class);
1426 final NotificationService notificationService = optionalNotificationService.get();
1427 // notificationService.registerNotificationListener(microwaveEventListener);
1428 listenerRegistrationresult = notificationService.registerNotificationListener(microwaveEventListener);
1429 LOG.info("End registration listener for Mountpoint {} Listener: {} Result: {}",
1430 mountPoint.getIdentifier().toString(), optionalNotificationService, listenerRegistrationresult);