b629401091729ffd77d3e710cdf3dbfe5b9aea30
[ccsdk/features.git] /
1 /*******************************************************************************
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
9  * 
10  * http://www.apache.org/licenses/LICENSE-2.0
11  * 
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc;
19
20
21
22 import java.lang.reflect.Constructor;
23 import java.lang.reflect.InvocationTargetException;
24 import java.util.ArrayList;
25 import java.util.List;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElement12;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType12;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
36 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
37 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
38 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
39 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
40 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceCurrentProblemTypeG;
42 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceDiversityCurrentProblemTypeG;
43 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceHistoricalPerformanceTypeG;
44 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AttributeValueChangedNotification;
45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerCurrentProblemTypeG;
46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerHistoricalPerformanceTypeG;
47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MicrowaveModelListener;
48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPac;
49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPacKey;
50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePac;
51 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePacKey;
52 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPac;
53 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPacKey;
54 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePac;
55 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePacKey;
56 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePac;
57 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePacKey;
58 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPac;
59 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPacKey;
60 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ObjectCreationNotification;
61 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ObjectDeletionNotification;
62 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ProblemNotification;
63 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.StructureCurrentProblemTypeG;
64 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems;
65 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceConfiguration;
66 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceCurrentProblems;
67 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceHistoricalPerformances;
68 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerCurrentProblems;
69 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances;
70 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems;
71 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems;
72 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.tdm.container.pac.TdmContainerCurrentProblems;
73 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
74 import org.opendaylight.yangtools.yang.binding.NotificationListener;
75 import org.opendaylight.yangtools.yang.common.QName;
76 import org.slf4j.Logger;
77 import org.slf4j.LoggerFactory;
78
79
80 public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, MicrowaveModelListener {
81
82     private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12.class);
83
84     public static final QName QNAME = MwAirInterfacePac.QNAME;
85
86
87     private ONFCOreNetworkElementCoreData coreData;
88     private OnfMicrowaveModelNotification microwaveModelListener;
89
90     /*-----------------------------------------------------------------------------
91      * Setter/Getter
92      */
93
94     public void setCoreData(ONFCOreNetworkElementCoreData coreData) {
95                 this.coreData = coreData;
96         }
97
98         public ONFCOreNetworkElementCoreData getCoreData() {
99                 return coreData;
100         }
101
102         @Override
103         public void setOnfMicrowaveModelListener(OnfMicrowaveModelNotification microwaveModelListener) {
104                 this.microwaveModelListener = microwaveModelListener;
105         }
106
107         @SuppressWarnings("unchecked")
108         @Override
109         public <T extends NotificationListener> T getNotificationListener() {
110                 return (T)this;
111         }
112
113     /*-----------------------------------------------------------------------------
114      * Interfacefunctions
115      */
116
117     public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid,
118                 List<ProblemNotificationXml> resultList) {
119
120         switch (lpName) {
121         case MWAirInterface:
122                 readTheFaultsOfMwAirInterfacePac(uuid, resultList);
123                 break;
124
125         case EthernetContainer12:
126                 readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
127                 break;
128
129         case TDMContainer:
130                 readTheFaultsOfMwTdmContainerPac(uuid, resultList);
131                 break;
132
133         case Structure:
134                 if (lpClass == MwHybridMwStructurePac.class) {
135                         readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
136
137                 } else if (lpClass == MwAirInterfaceDiversityPac.class) {
138                         readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
139
140                 } else if (lpClass == MwPureEthernetStructurePac.class) {
141                         readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
142
143                 } else {
144                         LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
145                 }
146                 break;
147         case Ethernet:
148             // No alarms supported
149             break;
150         case EthernetContainer10:
151         default:
152             LOG.warn("Unassigned or not expected lp in model {}", lpName);
153         }
154     }
155
156         public List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp) {
157         switch (lpName) {
158         case MWAirInterface:
159                 return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp);
160
161         case EthernetContainer12:
162                 return readTheHistoricalPerformanceDataOfEthernetContainer(lp);
163
164         case EthernetContainer10:
165         case EthernetPhysical:
166         case Ethernet:
167         case TDMContainer:
168         case Structure:
169         case Unknown:
170                 LOG.debug("Do not read HistoricalPM data for {} {}", lpName, lp.getUuid().getValue());
171                 break;
172         }
173         return new ArrayList<>();
174     }
175
176         public Class<?> getClassForLtpExtension(QName qName) {
177         Class<?> res = null;
178         if (qName.equals(MwAirInterfacePac.QNAME)) {
179             res = MwAirInterfacePac.class;
180         } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) {
181             res = MwAirInterfaceDiversityPac.class;
182         } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) {
183             res = MwPureEthernetStructurePac.class;
184         } else if (qName.equals(MwHybridMwStructurePac.QNAME)) {
185             res = MwHybridMwStructurePac.class;
186         } else if (qName.equals(MwEthernetContainerPac.QNAME)) {
187             res = MwEthernetContainerPac.class;
188         } else if (qName.equals(MwTdmContainerPac.QNAME)) {
189             res = MwTdmContainerPac.class;
190         }
191         LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res));
192                 return res;
193         }
194
195     /*-----------------------------------------------------------------------------
196      * Reading problems for specific interface pacs
197      */
198
199     /**
200      * Read problems of specific interfaces
201      *
202      * @param uuId Universal Id String of the interface
203      * @return number of alarms
204      */
205     private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid,
206             List<ProblemNotificationXml> resultList) {
207
208         final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
209         // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class;
210         // final Class<AirInterfaceCurrentProblems> clazzProblems =
211         // AirInterfaceCurrentProblems.class;
212         // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem =
213         // AirInterfaceCurrentProblemTypeG.class;
214
215         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
216                         coreData.getMountpoint(), interfacePacUuid.getValue());
217
218         // Step 2.2: construct data and the relative iid
219         InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
220                 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
221                 .child(AirInterfaceCurrentProblems.class).build();
222
223         // Step 2.3: read to the config data store
224         AirInterfaceCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
225                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
226
227         if (problems == null) {
228             LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
229         } else if (problems.getCurrentProblemList() == null) {
230             LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
231         } else {
232             for (AirInterfaceCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
233                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
234                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
235                         problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
236             }
237         }
238         return resultList;
239     }
240
241     /**
242      * Read problems of specific interfaces
243      *
244      * @param uuId Universal index of Interfacepac
245      * @return number of alarms
246      */
247     private List<ProblemNotificationXml> readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid,
248             List<ProblemNotificationXml> resultList) {
249
250         final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
251         // final Class<MwEthernetContainerPacKey> clazzPacKey =
252         // MwEthernetContainerPacKey.class;
253         // final Class<EthernetContainerCurrentProblems> clazzProblems =
254         // EthernetContainerCurrentProblems.class;
255         // final Class<ContainerCurrentProblemTypeG> clazzProblem =
256         // ContainerCurrentProblemTypeG.class;
257
258         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
259                 coreData.getMountpoint(), interfacePacUuid.getValue());
260
261         InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
262                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid))
263                 .child(EthernetContainerCurrentProblems.class).build();
264
265         EthernetContainerCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
266                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
267         if (problems == null) {
268             LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid);
269         } else if (problems.getCurrentProblemList() == null) {
270             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
271         } else {
272             for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
273                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
274                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
275                         problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
276             }
277         }
278         return resultList;
279     }
280
281     /**
282      * Read problems of specific interfaces
283      *
284      * @param uuId Universal index of Interfacepac
285      * @return number of alarms
286      */
287     private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid,
288             List<ProblemNotificationXml> resultList) {
289
290         final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
291         // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey =
292         // MwAirInterfaceDiversityPacKey.class;
293         final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
294         // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem =
295         // AirInterfaceDiversityCurrentProblemTypeG.class;
296
297         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
298                 coreData.getMountpoint(), interfacePacUuid.getValue());
299
300         InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
301                 .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build();
302
303         AirInterfaceDiversityCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
304                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
305         if (problems == null) {
306             LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid);
307         } else if (problems.getCurrentProblemList() == null) {
308             LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
309         } else {
310             for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
311                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
312                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
313                         problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
314             }
315         }
316         return resultList;
317     }
318
319     /**
320      * Read problems of specific interfaces
321      *
322      * @param uuId Universal index of Interfacepac
323      * @return number of alarms
324      */
325     private List<ProblemNotificationXml> readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid,
326             List<ProblemNotificationXml> resultList) {
327
328         final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
329         // final Class<MwPureEthernetStructurePacKey> clazzPacKey =
330         // MwPureEthernetStructurePacKey.class;
331         final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
332         // final Class<StructureCurrentProblemTypeG> clazzProblem =
333         // StructureCurrentProblemTypeG.class;
334
335         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
336                 coreData.getMountpoint(), interfacePacUuid.getValue());
337
338         InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
339                 .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
340
341         PureEthernetStructureCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
342                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
343         if (problems == null) {
344             LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid);
345         } else if (problems.getCurrentProblemList() == null) {
346             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
347         } else {
348             for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
349                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
350                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
351                         problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
352             }
353         }
354         return resultList;
355     }
356
357     /**
358      * Read problems of specific interfaces
359      *
360      * @param uuId Universal index of Interfacepac
361      * @return number of alarms
362      */
363     private List<ProblemNotificationXml> readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid,
364             List<ProblemNotificationXml> resultList) {
365
366         final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
367         // final Class<MwHybridMwStructurePacKey> clazzPacKey =
368         // MwHybridMwStructurePacKey.class;
369         final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
370         // final Class<HybridMwStructureCurrentProblemsG> clazzProblem =
371         // HybridMwStructureCurrentProblemsG.class;
372
373         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
374                 coreData.getMountpoint(), interfacePacUuid.getValue());
375
376         InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
377                 .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
378
379         HybridMwStructureCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
380                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
381         if (problems == null) {
382             LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid);
383         } else if (problems.getCurrentProblemList() == null) {
384             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
385         } else {
386             for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
387                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
388                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
389                         problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
390             }
391         }
392         return resultList;
393     }
394
395     /**
396      * Read problems of specific interfaces. TODO Goal for future implementation
397      * without usage of explicit new. Key is generated by newInstance() function
398      * here to verify this approach.
399      *
400      * @param uuId Universal index of Interfacepac
401      * @return number of alarms
402      * @throws SecurityException
403      * @throws NoSuchMethodException
404      * @throws InvocationTargetException
405      * @throws IllegalArgumentException
406      * @throws IllegalAccessException
407      * @throws InstantiationException
408      */
409     private List<ProblemNotificationXml> readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid,
410             List<ProblemNotificationXml> resultList) {
411
412         final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
413         final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
414         final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
415         // final Class<ContainerCurrentProblemTypeG> clazzProblem =
416         // ContainerCurrentProblemTypeG.class;
417
418         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
419                 coreData.getMountpoint(), interfacePacUuid.getValue());
420
421         try {
422             // -- Specific part 1
423             Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
424             InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
425                     .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
426
427             // -- Specific part 2
428             TdmContainerCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
429                     LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
430             if (problems == null) {
431                 LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid);
432             } else if (problems.getCurrentProblemList() == null) {
433                 LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
434             } else {
435                 // -- Specific part 3
436                 for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
437                     resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
438                             problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
439                             problem.getSequenceNumber().toString(),
440                             InternalDateAndTime.valueOf(problem.getTimeStamp())));
441                 }
442             }
443         } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
444                 | IllegalArgumentException | InvocationTargetException e) {
445             LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
446         }
447         return resultList;
448     }
449
450     /*-----------------------------------------------------------------------------
451      * Performance related data
452      */
453
454     /**
455      * PM MwAirInterfacePac
456      *
457      * @param lp
458      * @return
459      */
460     private List<ExtendedAirInterfaceHistoricalPerformanceType12> readTheHistoricalPerformanceDataOfMwAirInterfacePac(
461             Lp lp) {
462
463         String uuId = lp.getUuid().getValue();
464
465         List<ExtendedAirInterfaceHistoricalPerformanceType12> resultList = new ArrayList<>();
466         LOG.debug("DBRead Get {} MWAirInterfacePac: {}", coreData.getMountpoint(), uuId);
467         // ----
468         UniversalId mwAirInterfacePacuuId = new UniversalId(uuId);
469         // Step 2.1: construct data and the relative iid
470         InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
471                 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
472                 .child(AirInterfaceConfiguration.class).build();
473         AirInterfaceConfiguration airConfiguration = GenericTransactionUtils.readData(coreData.getDataBroker(),
474                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
475
476         if (airConfiguration == null) {
477             LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
478
479         } else {
480             // Step 2.2: construct data and the relative iid
481             InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
482                     .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
483                     .child(AirInterfaceHistoricalPerformances.class).build();
484
485             // Step 2.3: read to the config data store
486             AirInterfaceHistoricalPerformances airHistoricalPerformanceData = GenericTransactionUtils.readData(
487                         coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
488
489             if (airHistoricalPerformanceData == null) {
490                 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances",
491                         mwAirInterfacePacuuId);
492             } else {
493                 // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
494                 List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData
495                         .getHistoricalPerformanceDataList();
496                 LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
497                         airHistPMList.size());
498                 if (airHistPMList != null) {
499                     for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
500                             .getHistoricalPerformanceDataList()) {
501                         resultList.add(new ExtendedAirInterfaceHistoricalPerformanceType12(pmRecord, airConfiguration));
502                     }
503                 }
504             }
505         }
506         LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, resultList.size());
507         return resultList;
508     }
509
510     private List<ContainerHistoricalPerformanceTypeG> readTheHistoricalPerformanceDataOfEthernetContainer(Lp lp) {
511
512         final String myName = "MWEthernetContainerPac";
513         String uuId = lp.getUuid().getValue();
514
515         List<ContainerHistoricalPerformanceTypeG> resultList = new ArrayList<>();
516         LOG.debug("DBRead Get {} : {}", coreData.getMountpoint(), myName, uuId);
517         // ----
518         UniversalId ethContainerPacuuId = new UniversalId(uuId);
519         // Step 2.2: construct data and the relative iid
520         InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
521                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId))
522                 .child(EthernetContainerHistoricalPerformances.class).build();
523
524         // Step 2.3: read to the config data store
525         EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = GenericTransactionUtils
526                 .readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID);
527
528         if (ethContainerHistoricalPerformanceData == null) {
529             LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
530         } else {
531             // import
532             // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.ethernet.container.historical.performances.g.HistoricalPerformanceDataList
533                 // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList
534             List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData
535                     .getHistoricalPerformanceDataList();
536             LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
537             if (airHistPMList != null) {
538                 for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
539                     resultList.add(pmRecord);
540                 }
541             }
542         }
543         LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, resultList.size());
544         return resultList;
545     }
546
547     @Override
548     public void onObjectCreationNotification(ObjectCreationNotification notification) {
549         LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName());
550
551         ObjectCreationNotificationXml notificationXml = new ObjectCreationNotificationXml(coreData.getMountpoint(),
552                 notification.getCounter().toString(),
553                 InternalDateAndTime.valueOf(notification.getTimeStamp()),
554                 notification.getObjectIdRef().getValue());
555         microwaveModelListener.onObjectCreationNotification(notificationXml);
556         }
557
558     @Override
559     public void onObjectDeletionNotification(ObjectDeletionNotification notification) {
560         LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
561
562         ObjectDeletionNotificationXml notificationXml = new ObjectDeletionNotificationXml(coreData.getMountpoint(),
563                 notification.getCounter().toString(),
564                 InternalDateAndTime.valueOf(notification.getTimeStamp()),
565                 notification.getObjectIdRef().getValue()
566                 );
567         microwaveModelListener.onObjectDeletionNotification(notificationXml);
568         }
569
570     public void onProblemNotification(ProblemNotification notification) {
571
572         LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
573
574         ProblemNotificationXml notificationXml = new ProblemNotificationXml(coreData.getMountpoint(), notification.getObjectIdRef().getValue(),
575                 notification.getProblem(), InternalSeverity.valueOf(notification.getSeverity()),
576                 notification.getCounter().toString(), InternalDateAndTime.valueOf(notification.getTimeStamp()));
577
578         microwaveModelListener.onProblemNotification(notificationXml);
579         }
580
581     @Override
582     public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) {
583         LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName());
584
585         AttributeValueChangedNotificationXml notificationXml = new AttributeValueChangedNotificationXml(coreData.getMountpoint(),
586                 String.valueOf(notification.getCounter()), InternalDateAndTime.valueOf(notification.getTimeStamp()),
587                 notification.getObjectIdRef().getValue(), notification.getAttributeName(), notification.getNewValue());
588
589         microwaveModelListener.onAttributeValueChangedNotification(notificationXml);
590         }
591
592
593 }