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.impl.interfaces;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.List;
28 import java.util.Objects;
29 import org.eclipse.jdt.annotation.NonNull;
30 import org.eclipse.jdt.annotation.Nullable;
31 import org.onap.ccsdk.features.sdnr.wt.common.YangHelper;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.equipment.Onf14DomEquipmentManager;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.util.Debug;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
37 import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LAYERPROTOCOLNAMETYPEAIRLAYER;
38 import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LayerProtocol1;
39 import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.air._interface.lp.spec.AirInterfacePac;
40 import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.air._interface.pac.AirInterfaceCurrentProblems;
41 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ControlConstruct;
42 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.LAYERPROTOCOLNAMETYPE;
43 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId;
44 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.LogicalTerminationPoint;
45 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.LogicalTerminationPointKey;
46 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.logical.termination.point.LayerProtocol;
47 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.logical.termination.point.LayerProtocolKey;
48 import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.LAYERPROTOCOLNAMETYPEETHERNETCONTAINERLAYER;
49 import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.LAYERPROTOCOLNAMETYPEWIRELAYER;
50 import org.opendaylight.yangtools.concepts.ListenerRegistration;
51 import org.opendaylight.yangtools.yang.binding.NotificationListener;
52 import org.slf4j.Logger;
53 import org.slf4j.LoggerFactory;
55 public class Onf14DomInterfacePacManager {
58 private static final Logger log = LoggerFactory.getLogger(Onf14DomEquipmentManager.class);
62 private final NetconfDomAccessor netconfDomAccessor;
63 private final @NonNull DeviceManagerServiceProvider serviceProvider;
65 // air interface related members
66 private final List<TechnologySpecificPacKeys> airInterfaceList = new ArrayList<TechnologySpecificPacKeys>();
67 @SuppressWarnings("unused")
68 private ListenerRegistration<NotificationListener> airInterfaceNotificationListenerHandler;
69 private @NonNull final Onf14AirInterfaceNotificationListener airInterfaceNotificationListener;
71 // ethernet container related members
72 private final List<TechnologySpecificPacKeys> ethernetContainerList = new ArrayList<TechnologySpecificPacKeys>();
73 @SuppressWarnings("unused")
74 private ListenerRegistration<NotificationListener> etherneContainerNotificationListenerHandler;
75 private @NonNull final Onf14EthernetContainerNotificationListener ethernetContainerNotificationListener;
77 // wire interface related members
78 private final List<TechnologySpecificPacKeys> wireInterfaceList = new ArrayList<TechnologySpecificPacKeys>();
79 @SuppressWarnings("unused")
80 private ListenerRegistration<NotificationListener> wireInterfaceNotificationListenerHandler;
81 private @NonNull final Onf14WireInterfaceNotificationListener wireInterfaceNotificationListener;
85 public Onf14DomInterfacePacManager(@NonNull NetconfDomAccessor netconfDomAccessor,
86 @NonNull DeviceManagerServiceProvider serviceProvider) {
88 this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor);
89 this.serviceProvider = Objects.requireNonNull(serviceProvider);
91 this.airInterfaceNotificationListenerHandler = null;
92 this.airInterfaceNotificationListener =
93 new Onf14AirInterfaceNotificationListener(netconfDomAccessor, serviceProvider);
94 this.etherneContainerNotificationListenerHandler = null;
95 ethernetContainerNotificationListener =
96 new Onf14EthernetContainerNotificationListener(netconfDomAccessor, serviceProvider);
97 this.wireInterfaceNotificationListenerHandler = null;
98 wireInterfaceNotificationListener =
99 new Onf14WireInterfaceNotificationListener(netconfDomAccessor, serviceProvider);
101 // end of constructors
103 // getters and setters
104 // end of getters and setters
107 // end of private methods
110 public void readAllAirInterfaceCurrentProblems(NetconfDomAccessor netconfDomAccessor,
111 ControlConstruct controlConstruct, FaultData resultList) {
113 int idxStart; // Start index for debug messages
115 for (TechnologySpecificPacKeys key : airInterfaceList) {
116 idxStart = resultList.size();
118 readAirInterfaceCurrentProblemForLtp(netconfDomAccessor, controlConstruct, key.getLtpUuid(),
119 key.getLocalId(), resultList);
120 Debug.debugResultList(key.getLtpUuid().getValue(), resultList, idxStart);
125 public void readAllEhernetContainerCurrentProblems(FaultData resultList) {
127 int idxStart; // Start index for debug messages
129 for (TechnologySpecificPacKeys key : ethernetContainerList) {
130 idxStart = resultList.size();
132 readEthernetConainerCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList);
133 debugResultList(key.getLtpUuid().getValue(), resultList, idxStart);
137 public void readAllWireInterfaceCurrentProblems(FaultData resultList) {
139 int idxStart; // Start index for debug messages
141 for (TechnologySpecificPacKeys key : wireInterfaceList) {
142 idxStart = resultList.size();
144 readWireInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList);
145 debugResultList(key.getLtpUuid().getValue(), resultList, idxStart);
148 public void readKeys(ControlConstruct controlConstruct) {
151 Collection<LogicalTerminationPoint> ltpList =
152 YangHelper.getCollection(controlConstruct.nonnullLogicalTerminationPoint());
153 log.debug("Iterating the LTP list for node {}", netconfDomAccessor.getNodeId().getValue());
155 // iterating all the Logical Termination Point list
156 for (LogicalTerminationPoint ltp : ltpList) {
158 List<LayerProtocol> lpList = YangHelper.getList(ltp.nonnullLayerProtocol());
159 // the Layer Protocol list should contain only one item, since we have an 1:1 relationship between the LTP and the LP
160 if (lpList.size() != 1) {
161 log.debug("Layer protocol has no 1:1 relationship with the LTP.");
164 // accessing the LP, which should be only 1
165 LayerProtocol lp = lpList.get(0);
167 Class<? extends LAYERPROTOCOLNAMETYPE> layerProtocolName = lp.getLayerProtocolName();
168 if (layerProtocolName != null) {
169 // if the LTP has an airInterface technology extension, the layer protocol name is air-layer
170 if (layerProtocolName.getTypeName() == LAYERPROTOCOLNAMETYPEAIRLAYER.class.getName()) {
171 TechnologySpecificPacKeys airInterfaceKey =
172 new TechnologySpecificPacKeys(ltp.getUuid(), lp.getLocalId());
173 airInterfaceList.add(airInterfaceKey);
174 log.debug("Adding Ltp with uuid {} and local-id {} to the air-interface list",
175 ltp.getUuid().getValue(), lp.getLocalId());
177 // if the LTP has an ethernetContainier technology extension, the layer protocol name is ethernet-container-layer
178 else if (layerProtocolName.getTypeName() == LAYERPROTOCOLNAMETYPEETHERNETCONTAINERLAYER.class
180 TechnologySpecificPacKeys ethernetContainerKey =
181 new TechnologySpecificPacKeys(ltp.getUuid(), lp.getLocalId());
182 ethernetContainerList.add(ethernetContainerKey);
183 log.debug("Adding Ltp with uuid {} and local-id {} to the ethernet-contatinier list",
184 ltp.getUuid().getValue(), lp.getLocalId());
185 } else if (layerProtocolName.getTypeName() == LAYERPROTOCOLNAMETYPEWIRELAYER.class.getName()) {
186 TechnologySpecificPacKeys wireInterfaceKey =
187 new TechnologySpecificPacKeys(ltp.getUuid(), lp.getLocalId());
188 wireInterfaceList.add(wireInterfaceKey);
189 log.debug("Adding Ltp with uuid {} and local-id {} to the wire-interface list",
190 ltp.getUuid().getValue(), lp.getLocalId());
196 private static void readAirInterfaceCurrentProblemForLtp(NetconfDomAccessor netconfDomAccessor,
197 ControlConstruct controlConstruct, UniversalId ltpUuid, String localId, FaultData resultList) {
199 final Class<AirInterfacePac> clazzPac = AirInterfacePac.class;
201 log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}",
202 clazzPac.getSimpleName(), netconfDomAccessor.getNodeId().getValue(), ltpUuid.getValue(), localId);
204 // constructing the IID needs the augmentation exposed byy the air-interface-2-0 model
205 // InstanceIdentifier<AirInterfaceCurrentProblems> airInterfaceCurrentProblem_IID = InstanceIdentifier
206 // .builder(ControlConstruct.class)
207 // .child(LogicalTerminationPoint.class, new LogicalTerminationPointKey(ltpUuid))
208 // .child(LayerProtocol.class, new LayerProtocolKey(localId))
210 // org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LayerProtocol1.class)
211 // .child(AirInterfacePac.class)
212 // .child(AirInterfaceCurrentProblems.class).build();
214 final YangInstanceIdentifier airInterfaceCurrentProblem_IID =
215 YangInstanceIdentifier.builder().node(ControlConstruct.QNAME)
216 .nodeWithKey(LogicalTerminationPoint.QNAME,
217 QName.create(LogicalTerminationPoint.QNAME, "logical-termination-point-key").intern(),
219 .nodeWithKey(LayerProtocol.QNAME,
220 QName.create(LayerProtocol.QNAME, "layer-protocol-key").intern(), localId)
221 //.node(org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LayerProtocol1.QNAME)
222 .node(AirInterfacePac.QNAME).node(AirInterfaceCurrentProblems.QNAME).build();
224 // reading all the current-problems list for this specific LTP and LP
225 AirInterfaceCurrentProblems problems =
226 netconfDomAccessor.readData(LogicalDatastoreType.OPERATIONAL, airInterfaceCurrentProblem_IID);
230 Map<LogicalTerminationPointKey, LogicalTerminationPoint> ltpMap =
231 controlConstruct.nonnullLogicalTerminationPoint();
232 LogicalTerminationPoint ltp = ltpMap.get(new LogicalTerminationPointKey(ltpUuid));
235 Map<LayerProtocolKey, LayerProtocol> lpMap = ltp.nonnullLayerProtocol();
236 LayerProtocol lp = lpMap.get(new LayerProtocolKey(localId));
238 LayerProtocol1 lp1 = lp.augmentation(
239 org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LayerProtocol1.class);
242 AirInterfacePac airInterfacePack = lp1.getAirInterfacePac();
243 if (airInterfacePack != null) {
245 AirInterfaceCurrentProblems cp = airInterfacePack.getAirInterfaceCurrentProblems();
247 log.debug("DBRead Id {} no AirInterfaceCurrentProblems", ltpUuid);
249 for (org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.air._interface.current.problems.CurrentProblemList problem : YangHelper
250 .getCollection(cp.nonnullCurrentProblemList())) {
251 resultList.add(netconfDomAccessor.getNodeId(), (int) problem.getSequenceNumber(),
252 problem.getTimestamp(), ltpUuid.getValue(), problem.getProblemName(),
253 Onf14AirInterface.mapSeverity(problem.getProblemSeverity()));
262 private void readEthernetConainerCurrentProblemForLtp(UniversalId ltpUuid, String localId, FaultData resultList) {
264 final Class<EthernetContainerPac> clazzPac = EthernetContainerPac.class;
266 log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}",
267 clazzPac.getSimpleName(), netconfDomAccessor.getNodeId().getValue(), ltpUuid.getValue(), localId);
269 // constructing the IID needs the augmentation exposed by the ethernet-container-2-0 model
270 // InstanceIdentifier<EthernetContainerCurrentProblems> etherneContainerCurrentProblem_IID = InstanceIdentifier
271 // .builder(ControlConstruct.class)
272 // .child(LogicalTerminationPoint.class, new LogicalTerminationPointKey(ltpUuid))
273 // .child(LayerProtocol.class, new LayerProtocolKey(localId))
275 // org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.LayerProtocol1.class)
276 // .child(EthernetContainerPac.class).child(EthernetContainerCurrentProblems.class).build();
277 final YangInstanceIdentifier etherneContainerCurrentProblem_IID =
278 YangInstanceIdentifier.builder().node(ControlConstruct.QNAME)
279 .nodeWithKey(LogicalTerminationPoint.QNAME,
280 QName.create(LogicalTerminationPoint.QNAME, "logical-termination-point-key").intern(),
282 .nodeWithKey(LayerProtocol.QNAME,
283 QName.create(LayerProtocol.QNAME, "layer-protocol-key").intern(), localId)
284 //.node(org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.LayerProtocol1.QNAME)
285 .node(EthernetContainerPac.QNAME).node(EthernetContainerCurrentProblems.QNAME).build();
287 // reading all the current-problems list for this specific LTP and LP
288 EthernetContainerCurrentProblems problems =
289 netconfDomAccessor.readData(LogicalDatastoreType.OPERATIONAL, etherneContainerCurrentProblem_IID);
291 if (problems == null) {
292 log.debug("DBRead Id {} no EthernetContainerCurrentProblems", ltpUuid);
293 } else if (problems.getCurrentProblemList() == null) {
294 log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);
296 for (org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ethernet.container.current.problems.CurrentProblemList problem : YangHelper
297 .getCollection(problems.nonnullCurrentProblemList())) {
298 resultList.add(netconfDomAccessor.getNodeId(), (int) problem.getSequenceNumber(),
299 problem.getTimestamp(), ltpUuid.getValue(), problem.getProblemName(),
300 Onf14EthernetContainer.mapSeverity(problem.getProblemSeverity()));
305 private void readWireInterfaceCurrentProblemForLtp(UniversalId ltpUuid, String localId, FaultData resultList) {
307 final Class<WireInterfacePac> clazzPac = WireInterfacePac.class;
309 log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}",
310 clazzPac.getSimpleName(), netconfDomAccessor.getNodeId().getValue(), ltpUuid.getValue(), localId);
312 // constructing the IID needs the augmentation exposed by the wire-interface-2-0 model
313 // InstanceIdentifier<WireInterfaceCurrentProblems> wireInterfaceCurrentProblem_IID = InstanceIdentifier
314 // .builder(ControlConstruct.class)
315 // .child(LogicalTerminationPoint.class, new LogicalTerminationPointKey(ltpUuid))
316 // .child(LayerProtocol.class, new LayerProtocolKey(localId))
318 // org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.LayerProtocol1.class)
319 // .child(WireInterfacePac.class).child(WireInterfaceCurrentProblems.class).build();
320 final YangInstanceIdentifier wireInterfaceCurrentProblem_IID =
321 YangInstanceIdentifier.builder().node(ControlConstruct.QNAME)
322 .nodeWithKey(LogicalTerminationPoint.QNAME,
323 QName.create(LogicalTerminationPoint.QNAME, "logical-termination-point-key").intern(),
325 .nodeWithKey(LayerProtocol.QNAME,
326 QName.create(LayerProtocol.QNAME, "layer-protocol-key").intern(), localId)
327 //.node(org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.LayerProtocol1.QNAME)
328 .node(WireInterfacePac.QNAME).node(WireInterfaceCurrentProblems.QNAME).build();
330 // reading all the current-problems list for this specific LTP and LP
331 WireInterfaceCurrentProblems problems =
332 netconfDomAccessor.readData(LogicalDatastoreType.OPERATIONAL, wireInterfaceCurrentProblem_IID);
334 if (problems == null) {
335 log.debug("DBRead Id {} no WireInterfaceCurrentProblems", ltpUuid);
336 } else if (problems.getCurrentProblemList() == null) {
337 log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);
339 for (org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.wire._interface.current.problems.CurrentProblemList problem : YangHelper
340 .getCollection(problems.nonnullCurrentProblemList())) {
341 resultList.add(netconfDomAccessor.getNodeId(), (int) problem.getSequenceNumber(),
342 problem.getTimestamp(), ltpUuid.getValue(), problem.getProblemName(),
343 Onf14WireInterface.mapSeverity(problem.getProblemSeverity()));
349 // end of public methods
352 // end of static methods
355 // end of private classes