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.util.ArrayList;
12 import java.util.Collections;
13 import java.util.Iterator;
14 import java.util.List;
15 import java.util.concurrent.CopyOnWriteArrayList;
17 import javax.annotation.Nonnull;
18 import javax.annotation.Nullable;
20 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
21 import org.opendaylight.controller.md.sal.binding.api.MountPoint;
22 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
23 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
24 import org.opendaylight.mwtn.base.internalTypes.InternalDateAndTime;
25 import org.opendaylight.mwtn.base.internalTypes.InternalSeverity;
26 import org.opendaylight.mwtn.base.internalTypes.InventoryInformation;
27 import org.opendaylight.mwtn.devicemanager.impl.ProviderClient;
28 import org.opendaylight.mwtn.devicemanager.impl.database.service.HtDatabaseEventsService;
29 import org.opendaylight.mwtn.devicemanager.impl.listener.MicrowaveEventListener;
30 import org.opendaylight.mwtn.devicemanager.impl.xml.ProblemNotificationXml;
31 import org.opendaylight.mwtn.devicemanager.impl.xml.WebSocketServiceClient;
32 import org.opendaylight.mwtn.performancemanager.impl.database.types.EsHistoricalPerformance15Minutes;
33 import org.opendaylight.mwtn.performancemanager.impl.database.types.EsHistoricalPerformance24Hours;
34 import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corefoundationmodule.superclassesandcommonpackages.rev160710.UniversalId;
35 import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corefoundationmodule.superclassesandcommonpackages.rev160710.extension.ExtensionList;
36 import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160811.NetworkElement;
37 import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160811.logicalterminationpoint.LpList;
38 import org.opendaylight.yang.gen.v1.uri.onf.coremodel.corenetworkmodule.objectclasses.rev160811.networkelement.LtpRefList;
39 import org.opendaylight.yang.gen.v1.uri.onf.g_874_1_model.object_classes.rev160710.OTNHistoryData;
40 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.networkelement.currentproblemlist.rev161120.GenericCurrentProblemType;
41 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.networkelement.currentproblemlist.rev161120.NetworkElementCurrentProblems;
42 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.networkelement.currentproblemlist.rev161120.networkelementcurrentproblems.CurrentProblemList;
43 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.objectclasses.airinterface.rev160901.MWAirInterfacePac;
44 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.objectclasses.airinterface.rev160901.MWAirInterfacePacKey;
45 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.objectclasses.airinterface.rev160901.mw_airinterface_pac.AirInterfaceConfiguration;
46 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.objectclasses.airinterface.rev160901.mw_airinterface_pac.AirInterfaceCurrentProblems;
47 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.objectclasses.airinterface.rev160901.mw_airinterface_pac.AirInterfaceHistoricalPerformances;
48 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.objectclasses.ethernetcontainer.rev160902.MWEthernetContainerPac;
49 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.objectclasses.ethernetcontainer.rev160902.MWEthernetContainerPacKey;
50 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.objectclasses.ethernetcontainer.rev160902.mw_ethernetcontainer_pac.EthernetContainerCurrentProblems;
51 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.objectclasses.ethernetcontainer.rev160902.mw_ethernetcontainer_pac.EthernetContainerHistoricalPerformances;
52 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.typedefinitions.rev160902.AirInterfaceCurrentProblemType;
53 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.typedefinitions.rev160902.ContainerCurrentProblemType;
54 import org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.typedefinitions.rev160902.ContainerHistoricalPerformanceType;
55 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
56 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory;
59 import com.google.common.base.Optional;
62 * Get information over NETCONF device according to ONF Coremodel. Read networkelement and conditional packages.
64 * Get conditional packages from Networkelement
65 * Possible interfaces are:
66 * MWPS, LTP(MWPS-TTP), MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface
67 * ETH-CTP,LTP(Client), MW_EthernetContainer_Pac
68 * MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac, MicrowaveModel-ObjectClasses-AirInterfaceDiversity
69 * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-HybridMwStructure
70 * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-PureEthernetStructure
75 public class ONFCoreNetworkElement10 extends ONFCoreNetworkElementBase {
77 private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElementRepresentation.class);
79 private static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier
80 .builder(NetworkElement.class)
83 /*-----------------------------------------------------------------------------
87 // Non specific part. Used by all functions.
88 /** interfaceList is used by performance monitoring (pm) task and should be synchronized */
89 private final @Nonnull List<LpList> interfaceList = Collections.synchronizedList(new CopyOnWriteArrayList<>());
90 private final @Nonnull MicrowaveEventListener microwaveEventListener;
91 private @Nullable NetworkElement optionalNe = null;
93 // Performance monitoring specific part
94 /** Lock for the PM access specific elements that could be null */
95 private final @Nonnull Object pmLock = new Object();
96 private @Nullable Iterator<LpList> interfaceListIterator = null;
97 /** Actual pmLp used during iteration over interfaces */
98 private @Nullable LpList pmLp = null;
100 // Device monitoring specific part
101 /** Lock for the DM access specific elements that could be null */
102 private final @Nonnull Object dmLock = new Object();
103 /** Interface used for device monitoring (dm). If not null it contains the interface that is used for monitoring calls */
104 private @Nullable InstanceIdentifier<AirInterfaceCurrentProblems> dmAirIfCurrentProblemsIID = null;
106 /*------------------------------------------------------------------------
110 public ONFCoreNetworkElement10(String mountPointNodeName, Capabilities capabilities,
111 DataBroker netconfNodeDataBroker, WebSocketServiceClient webSocketService,
112 HtDatabaseEventsService databaseService, ProviderClient dcaeProvider ,@Nullable ProviderClient aotsmClient) {
114 super(mountPointNodeName, netconfNodeDataBroker, capabilities );
116 //Create MicrowaveService here
117 this.microwaveEventListener = new MicrowaveEventListener(mountPointNodeName, webSocketService, databaseService, dcaeProvider,aotsmClient);
119 LOG.info("Create NE instance {}", ONFCoreNetworkElement10.class.getSimpleName());
122 public static boolean checkType(Capabilities capabilities) {
123 return capabilities.isSupportingNamespace(NetworkElement.QNAME);
126 public static ONFCoreNetworkElement10 build(String mountPointNodeName, Capabilities capabilities,
127 DataBroker netconfNodeDataBroker, WebSocketServiceClient webSocketService,
128 HtDatabaseEventsService databaseService, ProviderClient dcaeProvider ,@Nullable ProviderClient aotsmClient) {
130 return checkType(capabilities) ? new ONFCoreNetworkElement10(mountPointNodeName, capabilities, netconfNodeDataBroker, webSocketService, databaseService, dcaeProvider ,aotsmClient) : null;
135 /*------------------------------------------------------------------------
140 * Have this as a separate function to avoid that representation is not created because of exceptions are thrown.
143 public void initialReadFromNetworkElement() {
144 LOG.debug("Get info about {}", mountPointNodeName);
146 int problems = microwaveEventListener.removeAllCurrentProblemsOfNode();
147 LOG.debug("Removed all {} problems from database at registration",problems);
150 //Step 2.1: access data broker within this mount point
151 LOG.debug("DBRead start");
152 //Step 2.2: read NEtworkElement from data store and initialize class variables
153 readNetworkElementAndInterfaces();
155 //Step 2.3: read the existing faults and add to DB
156 int problemsFound = readAllCurrentProblemsToDB();
158 LOG.info("Found info at {} for device {} number of problems: {}", mountPointNodeName, getUuId(), problemsFound);
162 /*------------------------------------------------------------
163 * private function to access database
167 * Read from NetworkElement and verify LTPs have changed.
168 * If the NE has changed, update to the new structure.
169 * From initial state it changes also.
171 private synchronized boolean readNetworkElementAndInterfaces() {
173 LOG.debug("Update mountpoint if changed {}", mountPointNodeName);
176 synchronized (pmLock) {
177 boolean change = false;
179 optionalNe = GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID);
180 if (optionalNe == null) {
181 LOG.debug("Unable to read NE data for mountpoint {}", mountPointNodeName);
182 if (! interfaceList.isEmpty()) {
183 interfaceList.clear();
184 interfaceListIterator = null;
188 LOG.debug("Mountpoint '{}' NE-Name '{}'", mountPointNodeName, optionalNe.getNameList().toString());
189 List<LpList> actualInterfaceList = getLtpList(optionalNe);
190 if (! interfaceList.equals(actualInterfaceList) ) {
191 LOG.debug("Mountpoint '{}' Update LTP List. Elements {}", mountPointNodeName, actualInterfaceList.size() );
192 interfaceList.clear();
193 interfaceList.addAll(actualInterfaceList);
194 interfaceListIterator = null;
203 * Get UUID as string from networkelemen
204 * @return UUID or EMPTY
206 private String getUuId() {
210 uuid = optionalNe != null ? optionalNe.getUuid() != null ? optionalNe.getUuid().getValue() : EMPTY : EMPTY;
211 } catch (NullPointerException e) {
212 //Unfortunately throws null pointer if not definied
218 * Read current problems of AirInterfaces and EthernetContainer
219 * according to NE status into DB
220 * @return Number of problems
222 private int readAllCurrentProblemsToDB() {
224 int problemsFound = 0;
226 synchronized (pmLock) {
227 for (LpList lp : interfaceList) {
228 if (ONFLayerProtocolName.MWAirInterface.is(lp.getLayerProtocolName())) {
229 //if (ltp.getLayerProtocolName().getValue().contains("MWPS")) {
230 problemsFound += readTheFaultsOfMWAirInterfacePac(lp.getUuid());
231 synchronized (dmLock) {
232 if (dmAirIfCurrentProblemsIID == null) {
233 dmAirIfCurrentProblemsIID = getMWAirInterfacePacIId(lp.getUuid());
237 if (ONFLayerProtocolName.EthernetContainer10.is(lp.getLayerProtocolName())) {
238 //if (ltp.getLayerProtocolName().getValue().contains("ETH")) {
239 problemsFound += readTheFaultsOfMWEthernetContainerPac(lp.getUuid());
244 //Step 2.4: Read other problems from Mountpoint
245 if (isNetworkElementCurrentProblemsSupporting10) {
246 problemsFound += readNetworkElementCurrentProblems();
249 return problemsFound;
253 * Read currentProblems of network elemement
254 * @return number of listed problems<br>
256 * <br>EXAMPLE from log:<br>
257 * karaf.log:2016-12-05 16:36:15,764 | INFO | dispatcher-25390 | EventManagerImpl | 346 - org.opendaylight.mwtn.eventmanager-impl - 0.3.0.SNAPSHOT | DBRead
258 * Currentproblems: NetworkElementCurrentProblems{getCurrentProblemList=[
259 * CurrentProblemList{
260 * getProblemName=powerLoss, getProblemSeverity=Critical, getSequenceNumber=1,
261 * getTimeStamp=DateAndTime [_value=20160822133005.0Z], augmentations={}},
262 * CurrentProblemList{
263 * getProblemName=powerLoss,
264 * getProblemSeverity=Minor,
265 * getSequenceNumber=2,
266 * getTimeStamp=DateAndTime [_value=20160822143005.0Z], augmentations={}}], augmentations={}}
269 * powerLoss[CurrentProblemList{getProblemName=powerLoss, getProblemSeverity=Critical, getSequenceNumber=1, getTimeStamp=DateAndTime [_value=20160822133005.0Z], augmentations={}}],
270 * powerLoss[CurrentProblemList{getProblemName=powerLoss, getProblemSeverity=Minor, getSequenceNumber=2, getTimeStamp=DateAndTime [_value=20160822143005.0Z], augmentations={}}]
273 private int readNetworkElementCurrentProblems() {
275 int problemsFound = 0;
276 LOG.info("DBRead Get {} NetworkElementCurrentProblems", mountPointNodeName);
278 InstanceIdentifier<NetworkElementCurrentProblems> networkElementCurrentProblemsIID = InstanceIdentifier
279 .builder(NetworkElementCurrentProblems.class)
282 //Step 2.3: read to the config data store
283 NetworkElementCurrentProblems problems;
285 problems = GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL, networkElementCurrentProblemsIID);
286 if (problems == null) {
287 LOG.debug("DBRead NetworkElementCurrentProblems no CurrentProblemsList");
289 List<CurrentProblemList> cpl = problems.getCurrentProblemList();
290 LOG.debug("DBRead NetworkElementCurrentProblems input: {}", cpl);
293 List<ProblemNotificationXml> resultList = new ArrayList<>();
294 for(GenericCurrentProblemType problem : cpl) {
295 resultList.add(new ProblemNotificationXml(mountPointNodeName, problem.getObjectIdRef(),
296 problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
297 problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
300 microwaveEventListener.initCurrentProblem(resultList);
301 LOG.debug("DBRead NetworkElementCurrentProblems result: {}",resultList);
302 problemsFound = resultList.size();
305 } catch (Exception e) {
306 LOG.warn( "DBRead {} NetworkElementCurrentProblems not supported. Message '{}' ", mountPointNodeName, e.getMessage() );
308 return problemsFound;
314 * Read the NetworkElement part from database.
315 * @return NetworkElement or null
317 private NetworkElement readNetworkElement() {
318 //Step 2.2: construct data and the relative iid
319 // The schema path to identify an instance is
320 // <i>CoreModel-CoreNetworkModule-ObjectClasses/NetworkElement</i>
322 //InstanceIdentifier<NetworkElement> networkElementIID = InstanceIdentifier
323 // .builder(NetworkElement.class)
326 //Step 2.3: read to the config data store
327 return GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID);
331 * Prepare check by updating NE state and reading all interfaces.
332 * @see org.opendaylight.mwtn.deviceMonitor.impl.DeviceMonitorSupport#prepareCheck()
335 public void prepareCheck() {
336 synchronized (dmLock) {
337 boolean change = readNetworkElementAndInterfaces();
339 int problems = microwaveEventListener.removeAllCurrentProblemsOfNode();
340 int problemsFound = readAllCurrentProblemsToDB();
341 LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", mountPointNodeName, getUuId(), problems, problemsFound);
348 * @see org.opendaylight.mwtn.deviceMonitor.impl.DeviceMonitorSupport#checkAndConnectionToMediatorIsOk()
351 public boolean checkAndConnectionToMediatorIsOk() {
352 synchronized (dmLock) {
353 return optionalNe != null;
358 * New implementation to interpret status with empty LTP List as notConnected => false
359 * @see org.opendaylight.mwtn.deviceMonitor.impl.DeviceMonitorSupport#checkAndConnectionToNeIsOk()
362 public boolean checkAndConnectionToNeIsOk() {
363 synchronized (dmLock) {
364 return optionalNe != null && !interfaceList.isEmpty();
369 /* OLD:public boolean checkAndConnectionToNeIsOk() {
370 synchronized (dmLock) {
371 if (dmAirIfCurrentProblemsIID != null) {
372 //Read to the config data store
373 AtomicBoolean noErrorIndicator = new AtomicBoolean();
374 AtomicReference<String> status = new AtomicReference<>();
376 GenericTransactionUtils.readDataOptionalWithStatus(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL, dmAirIfCurrentProblemsIID, noErrorIndicator, status);
377 LOG.debug("Status noErrorIndicator: {} statusTxt:{}",noErrorIndicator.get(), status.get());
378 return noErrorIndicator.get();
387 * Get List of UUIDs for conditional packages from Networkelement<br>
388 * Possible interfaces are:<br>
389 * MWPS, LTP(MWPS-TTP), MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface<br>
390 * ETH-CTP,LTP(Client), MW_EthernetContainer_Pac<br>
391 * MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac, MicrowaveModel-ObjectClasses-AirInterfaceDiversity<br>
392 * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-HybridMwStructure<br>
393 * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-PureEthernetStructure<br>
394 * @param ne Networkelement
395 * @return Id List, never null.
397 private static List<LpList> getLtpList( @Nullable NetworkElement ne ) {
399 List<LpList> res = new ArrayList<>();
402 List<LtpRefList> ltpRefList = ne.getLtpRefList();
403 if (ltpRefList == null) {
404 LOG.debug("DBRead NE-Interfaces: null");
406 for (LtpRefList ltRefListE : ltpRefList ) {
407 List<LpList> lpList = ltRefListE.getLpList();
408 if (lpList == null) {
409 LOG.debug("DBRead NE-Interfaces Reference List: null");
411 for (LpList lp : lpList) {
412 ////LayerProtocolName layerProtocolName = lpListE.getLayerProtocolName();
413 //UniversalId uuId = lpListE.getUuid();
420 LOG.debug("DBRead NE: null");
424 if (LOG.isDebugEnabled()) {
425 StringBuffer strBuf = new StringBuffer();
426 for (LpList ltp : res) {
427 if (strBuf.length() > 0) {
430 strBuf.append(ltp.getLayerProtocolName().getValue());
432 strBuf.append(ltp.getUuid().getValue());
434 LOG.debug("DBRead NE-Interfaces: {}", strBuf.toString());
441 private int readTheFaultsOfMWEthernetContainerPac(UniversalId interfacePacUuid) {
443 int problemsFound = 0;
444 LOG.info("DBRead Get {} MWEthernetContainerPac: {}", mountPointNodeName, interfacePacUuid.getValue());
446 //Step 2.2: construct data and the relative iid
447 InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
448 .builder(MWEthernetContainerPac.class, new MWEthernetContainerPacKey(interfacePacUuid))
449 .child(EthernetContainerCurrentProblems.class)
452 //Step 2.3: read to the config data store
453 EthernetContainerCurrentProblems ethProblems = GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
454 if (ethProblems == null) {
455 LOG.debug("DBRead EthProblems Id {} no EthernetContainerCurrentProblems", interfacePacUuid.getValue());
456 } else if (ethProblems.getCurrentProblemList() == null) {
457 LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid.getValue());
459 List<ProblemNotificationXml> resultList = new ArrayList<>();
460 for ( ContainerCurrentProblemType problem : ethProblems.getCurrentProblemList()) {
461 resultList.add(new ProblemNotificationXml(mountPointNodeName, interfacePacUuid.getValue(),
462 problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
463 problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
466 microwaveEventListener.initCurrentProblem(resultList);
467 LOG.debug("DBRead EthProblems result: {}",resultList);
468 problemsFound = resultList.size();
470 return problemsFound;
474 * Deliver for specific AirInterfacePac with key the related IId
475 * @param interfacePacUuid as UniversalId
476 * @return related InstanceIdentifier
478 private InstanceIdentifier<AirInterfaceCurrentProblems> getMWAirInterfacePacIId(UniversalId interfacePacUuid) {
479 InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
480 .builder(MWAirInterfacePac.class, new MWAirInterfacePacKey(interfacePacUuid))
481 .child(AirInterfaceCurrentProblems.class)
483 return mwAirInterfaceIID;
486 private int readTheFaultsOfMWAirInterfacePac(UniversalId interfacePacUuid) {
488 int problemsFound = 0;
489 LOG.info("DBRead Get {} MWAirInterfacePac: {}", mountPointNodeName, interfacePacUuid.getValue());
491 //Step 2.2: construct data and the relative iid
493 InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = getMWAirInterfacePacIId(interfacePacUuid);
495 //Step 2.3: read to the config data store
496 AirInterfaceCurrentProblems airProblems = GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
498 if (airProblems == null) {
499 LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
500 } else if (airProblems.getCurrentProblemList() == null) {
501 LOG.debug("DBRead Id {} no CurrentProblemList", interfacePacUuid);
503 List<ProblemNotificationXml> resultList = new ArrayList<>();
504 for ( AirInterfaceCurrentProblemType problem : airProblems.getCurrentProblemList()) {
505 resultList.add(new ProblemNotificationXml(mountPointNodeName, interfacePacUuid.getValue(),
506 problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
507 problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
510 microwaveEventListener.initCurrentProblem(resultList);
511 LOG.debug("DBRead AirProblems result: {}",resultList);
512 problemsFound = resultList.size();
514 return problemsFound;
517 public List<ExtendedAirInterfaceHistoricalPerformanceType> readTheHistoricalPerformanceDataOfMWAirInterfacePac(LpList lp) {
519 String uuId = lp.getUuid().getValue();
521 List<ExtendedAirInterfaceHistoricalPerformanceType> resultList = new ArrayList<>();
522 LOG.debug("DBRead Get {} MWAirInterfacePac: {}", mountPointNodeName, uuId);
524 UniversalId mwAirInterfacePacuuId = new UniversalId(uuId);
525 //Step 2.1: construct data and the relative iid
526 InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
527 .builder(MWAirInterfacePac.class, new MWAirInterfacePacKey(mwAirInterfacePacuuId))
528 .child(AirInterfaceConfiguration.class)
530 AirInterfaceConfiguration airConfiguration = GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
532 if (airConfiguration == null) {
533 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
537 //Step 2.2: construct data and the relative iid
538 InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
539 .builder(MWAirInterfacePac.class, new MWAirInterfacePacKey(mwAirInterfacePacuuId))
540 .child(AirInterfaceHistoricalPerformances.class)
543 //Step 2.3: read to the config data store
544 AirInterfaceHistoricalPerformances airHistoricalPerformanceData = GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
546 if (airHistoricalPerformanceData == null) {
547 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances", mwAirInterfacePacuuId);
550 List<org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.objectclasses.airinterface.rev160901.airinterfacehistoricalperformances.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData.getHistoricalPerformanceDataList();
551 LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}",mwAirInterfacePacuuId, airHistPMList.size());
552 if (airHistPMList != null) {
553 for ( org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.typedefinitions.rev160902.AirInterfaceHistoricalPerformanceType pmRecord : airHistPMList) {
554 resultList.add(new ExtendedAirInterfaceHistoricalPerformanceType(pmRecord, airConfiguration));
559 LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}",mwAirInterfacePacuuId, resultList.size());
563 public List<ContainerHistoricalPerformanceType> readTheHistoricalPerformanceDataOfEthernetContainer(LpList lp) {
565 final String myName = "MWEthernetContainerPac";
566 String uuId = lp.getUuid().getValue();
568 List<ContainerHistoricalPerformanceType> resultList = new ArrayList<>();
569 LOG.debug("DBRead Get {} : {}", mountPointNodeName, myName,uuId);
571 UniversalId ethContainerPacuuId = new UniversalId(uuId);
572 //Step 2.2: construct data and the relative iid
573 InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
574 .builder(MWEthernetContainerPac.class, new MWEthernetContainerPacKey(ethContainerPacuuId))
575 .child(EthernetContainerHistoricalPerformances.class)
578 //Step 2.3: read to the config data store
579 EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL, ethContainerIID);
581 if (ethContainerHistoricalPerformanceData == null) {
582 LOG.debug("DBRead {} Id {} no EthernetContainerHistoricalPerformances", myName, ethContainerPacuuId);
584 List<org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.objectclasses.ethernetcontainer.rev160902.ethernetcontainerhistoricalperformances.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData.getHistoricalPerformanceDataList();
585 LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
586 if (airHistPMList != null) {
587 for ( org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.typedefinitions.rev160902.ContainerHistoricalPerformanceType pmRecord : airHistPMList) {
588 resultList.add(pmRecord);
592 LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, resultList.size());
596 private List<? extends OTNHistoryData> readTheHistoricalPerformanceData(LpList lp) {
597 ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(lp.getLayerProtocolName());
601 return readTheHistoricalPerformanceDataOfMWAirInterfacePac(lp);
603 case EthernetContainer10:
604 return readTheHistoricalPerformanceDataOfEthernetContainer(lp);
606 case EthernetContainer12:
607 case EthernetPhysical:
612 LOG.debug("Do not read HistoricalPM data for", lpName);
615 return new ArrayList<>();
619 public AllPm getHistoricalPM() {
620 synchronized ( pmLock ) {
622 AllPm allPm = new AllPm();
625 List<? extends OTNHistoryData> resultList = readTheHistoricalPerformanceData(lp);
627 for (OTNHistoryData perf : resultList) {
629 switch(perf.getGranularityPeriod()) {
631 EsHistoricalPerformance15Minutes pm = new EsHistoricalPerformance15Minutes(mountPointNodeName, lp)
632 .setHistoricalRecord15Minutes(perf);
637 case PERIOD24HOURS: {
638 LOG.debug("Write 24h create");
639 EsHistoricalPerformance24Hours pm = new EsHistoricalPerformance24Hours(mountPointNodeName, lp)
640 .setHistoricalRecord24Hours(perf);
641 LOG.debug("Write 24h write to DB");
647 LOG.warn("Unknown granularity {}",perf.getGranularityPeriod());
660 public void resetPMIterator() {
661 synchronized ( pmLock ) {
662 interfaceListIterator = interfaceList.iterator();
664 LOG.debug("PM reset iterator");
668 public boolean hasNext() {
670 synchronized ( pmLock ) {
671 res = interfaceListIterator != null ? interfaceListIterator.hasNext(): false;
673 LOG.debug("PM hasNext LTP {}", res);
679 synchronized ( pmLock ) {
680 pmLp = interfaceListIterator != null ? interfaceListIterator.next() : null;
682 LOG.debug("PM next LTP {}", pmLp.getUuid().toString());
686 public String pmStatusToString() {
687 StringBuffer res = new StringBuffer();
688 synchronized ( pmLock ) {
689 res.append(pmLp == null ? "no interface" : pmLp.getLayerProtocolName().getValue());
690 for (LpList lp : interfaceList ) {
692 res.append(lp.getLayerProtocolName().getValue());
696 return(res.toString());
700 public int removeAllCurrentProblemsOfNode() {
701 return microwaveEventListener.removeAllCurrentProblemsOfNode();
705 public void doRegisterMicrowaveEventListener(MountPoint mountPoint) {
706 final Optional<NotificationService> optionalNotificationService = mountPoint.getService(NotificationService.class);
707 final NotificationService notificationService = optionalNotificationService.get();
708 notificationService.registerNotificationListener(microwaveEventListener);
712 public @Nonnull InventoryInformation getInventoryInformation() {
713 return this.getInventoryInformation(null);
717 public @Nonnull InventoryInformation getInventoryInformation(String layerProtocolFilter) {
719 String type=InventoryInformation.UNKNOWN;
720 String model=InventoryInformation.UNKNOWN;
721 String vendor=InventoryInformation.UNKNOWN;
722 String ipv4=InventoryInformation.UNKNOWN;
723 String ipv6=InventoryInformation.UNKNOWN;
724 List<String> uuids = new ArrayList<String>();
725 LOG.debug("request inventory information. filter:"+layerProtocolFilter);
727 if (optionalNe != null) {
730 for(LpList lp : this.interfaceList)
732 if(layerProtocolFilter==null || layerProtocolFilter.isEmpty())
733 uuids.add(lp.getUuid().getValue());
734 else if(lp.getLayerProtocolName()!=null &&
735 lp.getLayerProtocolName().getValue()!=null &&
736 lp.getLayerProtocolName().getValue().equals(layerProtocolFilter))
737 uuids.add(lp.getUuid().getValue());
740 List<ExtensionList> extensions = optionalNe.getExtensionList();
743 for(ExtensionList e: extensions)
745 if(e.getValueName()!=null)
747 if(e.getValueName().equals("neIpAddress"))
750 LOG.debug("ip information found: "+ipv4);
754 if(ipv4==InventoryInformation.UNKNOWN)
756 LOG.debug("no ip information found");
761 LOG.debug("extension list is null");
766 return new InventoryInformation(type, model, vendor, ipv4, ipv6, uuids);