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