2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs;
24 import java.util.Arrays;
25 import java.util.Collection;
26 import java.util.List;
27 import java.util.Optional;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces.TechnologySpecificPacKeys;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.pm.PerformanceDataAirInterface;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.qnames.Onf14DevicemanagerQNames;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Debug;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp;
36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
37 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
38 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
39 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
40 import org.opendaylight.yangtools.yang.common.QNameModule;
41 import org.opendaylight.yangtools.yang.common.Revision;
42 import org.opendaylight.yangtools.yang.common.XMLNamespace;
43 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
44 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder;
45 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
46 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
47 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
48 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
49 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
50 import org.slf4j.Logger;
51 import org.slf4j.LoggerFactory;
53 public class AirInterface20 extends YangModule {
55 private static final Logger LOG = LoggerFactory.getLogger(AirInterface20.class);
57 private static String NAMESPACE = "urn:onf:yang:air-interface-2-0";
58 private static final List<QNameModule> MODULES =
59 Arrays.asList(QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2020-01-21")),
60 QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2022-07-29")));
62 private final CoreModel14 coreModel14;
64 private AirInterface20(NetconfDomAccessor netconfDomAccessor, QNameModule module, CoreModel14 coreModel14) {
65 super(netconfDomAccessor, module);
66 this.coreModel14 = coreModel14;
69 public FaultData readAllCurrentProblems(FaultData resultList, List<TechnologySpecificPacKeys> airInterfaceList) {
71 int idxStart; // Start index for debug messages
73 for (TechnologySpecificPacKeys key : airInterfaceList) {
74 idxStart = resultList.size();
75 readAirInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList);
76 Debug.debugResultList(key.getLtpUuid(), resultList, idxStart);
82 * Get specific module for device, depending on capabilities
84 public static Optional<AirInterface20> getModule(NetconfDomAccessor netconfDomAccessor, CoreModel14 coreModel14) {
86 Capabilities capabilities = netconfDomAccessor.getCapabilites();
87 for (QNameModule module : MODULES) {
89 if (capabilities.isSupportingNamespaceAndRevision(module)) {
90 return Optional.of(new AirInterface20(netconfDomAccessor, module, coreModel14));
93 return Optional.empty();
96 private FaultData readAirInterfaceCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) {
98 LOG.debug("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}",
99 getQNameModule(), netconfDomAccessor.getNodeId().getValue(), ltpUuid, localId);
101 // constructing the IID needs the augmentation exposed by the air-interface-2-0
104 YangInstanceIdentifier layerProtocolIID = coreModel14.getLayerProtocolIId(ltpUuid, localId);
105 InstanceIdentifierBuilder airInterfacePacIID =
106 YangInstanceIdentifier.builder(layerProtocolIID).node(getQName("air-interface-pac"));
109 // AugmentationIdentifier airInterfacePacIID =
110 // YangInstanceIdentifier.AugmentationIdentifier.create(Sets.newHashSet(getQName("air-interface-pac")));
112 // InstanceIdentifierBuilder augmentedAirInterfacePacIID =
113 // YangInstanceIdentifier.builder(layerProtocolIID).node(airInterfacePacIID);
115 // reading all the current-problems list for this specific LTP and LP
116 Optional<NormalizedNode> airInterfacePacDataOpt =
117 netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, airInterfacePacIID.build());
118 if (airInterfacePacDataOpt.isPresent()) {
119 LOG.info("Air Interface = {}", airInterfacePacDataOpt.get().prettyTree());
121 if (airInterfacePacDataOpt.isPresent()) {
122 ContainerNode airInterfacePacData = (ContainerNode) airInterfacePacDataOpt.get();
123 MapNode airInterfaceCurrentProblemsList =
124 (MapNode) airInterfacePacData.childByArg(new NodeIdentifier(getQName("current-problem-list")));
125 if (airInterfaceCurrentProblemsList != null) {
126 Collection<MapEntryNode> airInterfaceProblemsCollection = airInterfaceCurrentProblemsList.body();
127 for (MapEntryNode airInterfaceProblem : airInterfaceProblemsCollection) {
128 resultList.add(netconfDomAccessor.getNodeId(),
130 Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, getQName("sequence-number"))),
131 new DateAndTime(Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, getQName("timestamp"))),
132 ltpUuid, Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, getQName("problem-name")),
133 InternalDataModelSeverity.mapSeverity(
134 Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, getQName("problem-severity"))));
137 LOG.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);
143 public PerformanceDataLtp readAirInterfaceHistoricalPerformanceData(String ltpUuid, String localId,
144 PerformanceDataLtp res) {
145 LOG.debug("Get historical performance data for class {} from mountpoint {} for LTP uuid {} and local-id {}",
146 Onf14DevicemanagerQNames.AIR_INTERFACE_2_0_MODULE, netconfDomAccessor.getNodeId().getValue(), ltpUuid,
149 // constructing the IID needs the augmentation exposed by the air-interface-2-0
152 YangInstanceIdentifier layerProtocolIID = coreModel14.getLayerProtocolIId(ltpUuid, localId);
153 InstanceIdentifierBuilder airInterfacePacIID =
154 YangInstanceIdentifier.builder(layerProtocolIID).node(getQName("air-interface-pac"));
157 // AugmentationIdentifier airInterfacePacIID = YangInstanceIdentifier.AugmentationIdentifier
158 // .create(Sets.newHashSet(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC));
160 // InstanceIdentifierBuilder augmentedAirInterfacePacIID =
161 // YangInstanceIdentifier.builder(layerProtocolIID).node(airInterfacePacIID);
163 // // reading historical performance list for this specific LTP and LP
164 Optional<NormalizedNode> airInterfacePacDataOpt =
165 netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, airInterfacePacIID.build());
166 LOG.debug("Performance Data = {}", airInterfacePacDataOpt.get().body());
167 if (airInterfacePacDataOpt.isPresent()) {
168 ContainerNode airInterfacePacData = (ContainerNode) airInterfacePacDataOpt.get();
169 ContainerNode cn = (ContainerNode) airInterfacePacData
170 .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC));
172 ContainerNode airIntfHistPerf = (ContainerNode) cn
173 .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_HISTORICAL_PERFORMANCES));
174 if (airIntfHistPerf != null) {
175 MapNode airInterfaceHistoricalPerformanceList = (MapNode) airIntfHistPerf.childByArg(
176 new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_HISTORICAL_PERFORMANCES_LIST));
177 if (airInterfaceHistoricalPerformanceList != null) {
178 Collection<MapEntryNode> airInterfaceHistoricalPerfCollection =
179 airInterfaceHistoricalPerformanceList.body();
180 for (MapEntryNode airInterfaceHistPerf : airInterfaceHistoricalPerfCollection) {
181 res.add(new PerformanceDataAirInterface(netconfDomAccessor.getNodeId(), ltpUuid, localId,
182 airInterfaceHistPerf));
186 LOG.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);