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