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