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 com.google.common.collect.Sets;
25 import java.util.Arrays;
26 import java.util.Collection;
27 import java.util.List;
28 import java.util.Optional;
29 import org.eclipse.jdt.annotation.NonNull;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces.TechnologySpecificPacKeys;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.pm.PerformanceDataAirInterface;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.qnames.Onf14DevicemanagerQNames;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Debug;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility;
36 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
37 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp;
38 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
39 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
40 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
41 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
42 import org.opendaylight.yangtools.yang.common.QNameModule;
43 import org.opendaylight.yangtools.yang.common.Revision;
44 import org.opendaylight.yangtools.yang.common.XMLNamespace;
45 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
46 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
47 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder;
48 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
49 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
50 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
51 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
52 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
53 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
54 import org.slf4j.Logger;
55 import org.slf4j.LoggerFactory;
57 public class AirInterface20 extends YangModule {
59 private static final Logger LOG = LoggerFactory.getLogger(AirInterface20.class);
61 private static String NAMESPACE = "urn:onf:yang:air-interface-2-0";
62 private static final List<QNameModule> MODULES =
63 Arrays.asList(QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2020-01-21")),
64 QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2022-07-29")));
66 private final CoreModel14 coreModel14;
68 private AirInterface20(NetconfDomAccessor netconfDomAccessor, QNameModule module, CoreModel14 coreModel14) {
69 super(netconfDomAccessor, module);
70 this.coreModel14 = coreModel14;
73 public FaultData readAllCurrentProblems(FaultData resultList,
74 List<TechnologySpecificPacKeys> airInterfaceList) {
76 int idxStart; // Start index for debug messages
78 for (TechnologySpecificPacKeys key : airInterfaceList) {
79 idxStart = resultList.size();
80 readAirInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList);
81 Debug.debugResultList(key.getLtpUuid(), resultList, idxStart);
87 * Get specific module for device, depending on capabilities
89 public static Optional<AirInterface20> getModule(NetconfDomAccessor netconfDomAccessor, CoreModel14 coreModel14) {
91 Capabilities capabilities = netconfDomAccessor.getCapabilites();
92 for (QNameModule module : MODULES) {
94 if (capabilities.isSupportingNamespaceAndRevision(module)) {
95 return Optional.of(new AirInterface20(netconfDomAccessor, module, coreModel14));
98 return Optional.empty();
101 private FaultData readAirInterfaceCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) {
103 LOG.debug("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}",
104 getQNameModule(), netconfDomAccessor.getNodeId().getValue(), ltpUuid, localId);
106 // constructing the IID needs the augmentation exposed by the air-interface-2-0
109 YangInstanceIdentifier layerProtocolIID = coreModel14.getLayerProtocolIId(ltpUuid, localId);
112 AugmentationIdentifier airInterfacePacIID =
113 YangInstanceIdentifier.AugmentationIdentifier.create(Sets.newHashSet(getQName("air-interface-pac")));
115 InstanceIdentifierBuilder augmentedAirInterfacePacIID =
116 YangInstanceIdentifier.builder(layerProtocolIID).node(airInterfacePacIID);
118 // reading all the current-problems list for this specific LTP and LP
119 Optional<NormalizedNode> airInterfacePacDataOpt =
120 netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedAirInterfacePacIID.build());
122 if (airInterfacePacDataOpt.isPresent()) {
123 AugmentationNode airInterfacePacData = (AugmentationNode) airInterfacePacDataOpt.get();
124 MapNode airInterfaceCurrentProblemsList =
125 (MapNode) airInterfacePacData.childByArg(new NodeIdentifier(getQName("current-problem-list")));
126 if (airInterfaceCurrentProblemsList != null) {
127 Collection<MapEntryNode> airInterfaceProblemsCollection = airInterfaceCurrentProblemsList.body();
128 for (MapEntryNode airInterfaceProblem : airInterfaceProblemsCollection) {
129 resultList.add(netconfDomAccessor.getNodeId(),
131 Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, getQName("sequence-number"))),
132 new DateAndTime(Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, getQName("timestamp"))),
133 ltpUuid, Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, getQName("problem-name")),
134 InternalDataModelSeverity.mapSeverity(
135 Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, getQName("problem-severity"))));
138 LOG.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);
144 public PerformanceDataLtp readAirInterfaceHistoricalPerformanceData(String ltpUuid, String localId,
145 PerformanceDataLtp res) {
146 LOG.debug("Get historical performance data for class {} from mountpoint {} for LTP uuid {} and local-id {}",
147 Onf14DevicemanagerQNames.AIR_INTERFACE_2_0_MODULE, netconfDomAccessor.getNodeId().getValue(), ltpUuid,
150 // constructing the IID needs the augmentation exposed by the air-interface-2-0
153 YangInstanceIdentifier layerProtocolIID = coreModel14.getLayerProtocolIId(ltpUuid, localId);
156 AugmentationIdentifier airInterfacePacIID = YangInstanceIdentifier.AugmentationIdentifier
157 .create(Sets.newHashSet(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC));
159 InstanceIdentifierBuilder augmentedAirInterfacePacIID =
160 YangInstanceIdentifier.builder(layerProtocolIID).node(airInterfacePacIID);
162 // reading historical performance list for this specific LTP and LP
163 Optional<NormalizedNode> airInterfacePacDataOpt =
164 netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedAirInterfacePacIID.build());
165 LOG.debug("Performance Data = {}", airInterfacePacDataOpt.get().body());
166 if (airInterfacePacDataOpt.isPresent()) {
167 AugmentationNode airInterfacePacData = (AugmentationNode) airInterfacePacDataOpt.get();
168 ContainerNode cn = (ContainerNode) airInterfacePacData
169 .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC));
171 ContainerNode airIntfHistPerf = (ContainerNode) cn
172 .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_HISTORICAL_PERFORMANCES));
173 if (airIntfHistPerf != null) {
174 MapNode airInterfaceHistoricalPerformanceList = (MapNode) airIntfHistPerf.childByArg(
175 new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_HISTORICAL_PERFORMANCES_LIST));
176 if (airInterfaceHistoricalPerformanceList != null) {
177 Collection<MapEntryNode> airInterfaceHistoricalPerfCollection =
178 airInterfaceHistoricalPerformanceList.body();
179 for (MapEntryNode airInterfaceHistPerf : airInterfaceHistoricalPerfCollection) {
180 res.add(new PerformanceDataAirInterface(netconfDomAccessor.getNodeId(), ltpUuid, localId,
181 airInterfaceHistPerf));
185 LOG.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);