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