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.util.Debug;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
33 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
35 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
37 import org.opendaylight.yangtools.yang.common.QNameModule;
38 import org.opendaylight.yangtools.yang.common.Revision;
39 import org.opendaylight.yangtools.yang.common.XMLNamespace;
40 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
41 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder;
42 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
43 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
44 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
45 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
46 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
47 import org.slf4j.Logger;
48 import org.slf4j.LoggerFactory;
50 public class EthernetContainer20 extends YangModule {
52 private static final Logger LOG = LoggerFactory.getLogger(EthernetContainer20.class);
54 private static String NAMESPACE = "urn:onf:yang:ethernet-container-2-0";
55 private static final List<QNameModule> MODULES =
56 Arrays.asList(QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2020-01-21")));
58 private final CoreModel14 coreModel14;
60 public EthernetContainer20(NetconfDomAccessor netconfDomAccessor, QNameModule module, CoreModel14 coreModel14) {
61 super(netconfDomAccessor, module);
62 this.coreModel14 = coreModel14;
65 private FaultData readEthernetContainerCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) {
68 "DBRead Get current problems for Ethernet Container from mountpoint {} for LTP uuid {} and local-id {}",
69 netconfDomAccessor.getNodeId().getValue(), ltpUuid, localId);
71 // constructing the IID needs the augmentation exposed by the
72 // ethernet-container-2-0 model
73 YangInstanceIdentifier layerProtocolIID = coreModel14.getLayerProtocolIId(ltpUuid, localId);
74 InstanceIdentifierBuilder ethernetContainerIID = YangInstanceIdentifier.builder(layerProtocolIID).node(getQName("ethernet-container-pac"));
76 // AugmentationIdentifier ethernetContainerIID = YangInstanceIdentifier.AugmentationIdentifier
77 // .create(Sets.newHashSet(getQName("ethernet-container-pac")));
79 // InstanceIdentifierBuilder augmentedEthernetContainerConfigurationIID =
80 // YangInstanceIdentifier.builder(layerProtocolIID).node(ethernetContainerIID);
82 // // reading all the current-problems list for this specific LTP and LP
83 Optional<NormalizedNode> etherntContainerConfigurationOpt = netconfDomAccessor
84 .readDataNode(LogicalDatastoreType.OPERATIONAL, ethernetContainerIID.build());
86 if (etherntContainerConfigurationOpt.isPresent()) {
87 ContainerNode etherntContainerConfiguration = (ContainerNode) etherntContainerConfigurationOpt.get();
88 MapNode ethernetContainerCurrentProblemsList = (MapNode) etherntContainerConfiguration
89 .childByArg(new NodeIdentifier(getQName("current-problem-list")));
90 if (ethernetContainerCurrentProblemsList != null) {
91 Collection<MapEntryNode> ethernetContainerProblemsCollection =
92 ethernetContainerCurrentProblemsList.body();
93 for (MapEntryNode ethernetContainerProblem : ethernetContainerProblemsCollection) {
94 resultList.add(netconfDomAccessor.getNodeId(),
95 Integer.parseInt(Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem,
96 getQName("sequence-number"))),
98 Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem, getQName("timestamp"))),
99 ltpUuid, Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem, getQName("problem-name")),
100 InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility
101 .getLeafValue(ethernetContainerProblem, getQName("problem-severity"))));
104 LOG.debug("DBRead Id {} empty CurrentProblemList", ltpUuid);
110 public FaultData readAllCurrentProblems(FaultData resultList,
111 List<TechnologySpecificPacKeys> ethernetContainerList) {
113 int idxStart; // Start index for debug messages
115 for (TechnologySpecificPacKeys key : ethernetContainerList) {
116 idxStart = resultList.size();
118 resultList = readEthernetContainerCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList);
119 Debug.debugResultList(key.getLtpUuid(), resultList, idxStart);
127 * Get specific module for device, depending on capabilities
129 public static Optional<EthernetContainer20> getModule(NetconfDomAccessor netconfDomAccessor,
130 CoreModel14 coreModel14) {
132 Capabilities capabilities = netconfDomAccessor.getCapabilites();
133 for (QNameModule module : MODULES) {
135 if (capabilities.isSupportingNamespaceAndRevision(module)) {
136 return Optional.of(new EthernetContainer20(netconfDomAccessor, module, coreModel14));
139 return Optional.empty();