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