diff options
Diffstat (limited to 'sdnr/wt/devicemanager-onap/onf14/provider/src/main')
21 files changed, 1421 insertions, 471 deletions
diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElement.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElement.java index 6ff43bd69..4431865e2 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElement.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElement.java @@ -30,7 +30,8 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.equipment.Onf14DomEquipmentManager; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces.Onf14DomInterfacePacManager; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces.TechnologySpecificPacKeys; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.qnames.Onf14DevicemanagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs.CoreModel14; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService; @@ -45,7 +46,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.r import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,10 +58,6 @@ public class Onf14DomNetworkElement implements NetworkElement, PerformanceDataPr private static final Logger log = LoggerFactory.getLogger(Onf14DomNetworkElement.class); - protected static final YangInstanceIdentifier TOPLEVELEQUIPMENT_IID = - YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) - .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_TOP_LEVEL_EQPT).build(); - private final @NonNull Object pmLock = new Object(); protected @Nullable TechnologySpecificPacKeys pmLp = null; protected @Nullable Iterator<TechnologySpecificPacKeys> interfaceListIterator = null; @@ -75,21 +71,20 @@ public class Onf14DomNetworkElement implements NetworkElement, PerformanceDataPr private final @NonNull Onf14DomEquipmentManager equipmentManager; private final @NonNull Onf14DomInterfacePacManager interfacePacManager; - private final @NonNull String namespaceRevision; + private final @NonNull CoreModel14 onf14CoreModelQNames; public Onf14DomNetworkElement(NetconfDomAccessor netconfDomAccessor, DeviceManagerServiceProvider serviceProvider, - String namespaceRevision) { + CoreModel14 onf14CoreModelQNames) { log.info("Create {}", Onf14DomNetworkElement.class.getSimpleName()); this.netconfDomAccessor = netconfDomAccessor; + this.onf14CoreModelQNames = onf14CoreModelQNames; this.databaseService = serviceProvider.getDataProvider(); this.notificationService = serviceProvider.getNotificationService(); this.faultService = serviceProvider.getFaultService(); this.performanceManager = serviceProvider.getPerformanceManagerService(); - this.namespaceRevision = namespaceRevision; this.onf14Mapper = new Onf14DomToInternalDataModel(); - this.equipmentManager = new Onf14DomEquipmentManager(netconfDomAccessor, databaseService, onf14Mapper); - this.interfacePacManager = new Onf14DomInterfacePacManager(netconfDomAccessor, serviceProvider); - + this.equipmentManager = new Onf14DomEquipmentManager(netconfDomAccessor, databaseService, onf14Mapper, onf14CoreModelQNames); + this.interfacePacManager = new Onf14DomInterfacePacManager(netconfDomAccessor, serviceProvider, onf14CoreModelQNames); } /** @@ -113,7 +108,7 @@ public class Onf14DomNetworkElement implements NetworkElement, PerformanceDataPr */ public void setCoreModel() { NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); - eb.setCoreModelCapability(namespaceRevision); + eb.setCoreModelCapability(onf14CoreModelQNames.getRevision()); databaseService.updateNetworkConnection22(eb.build(), netconfDomAccessor.getNodeId().getValue()); } @@ -173,7 +168,8 @@ public class Onf14DomNetworkElement implements NetworkElement, PerformanceDataPr } private Optional<NormalizedNode> readTopLevelEquipment(NetconfDomAccessor netconfDomAccessor) { - return netconfDomAccessor.readDataNode(LogicalDatastoreType.CONFIGURATION, TOPLEVELEQUIPMENT_IID); + log.debug("Reading Top level equipment data"); + return netconfDomAccessor.readDataNode(LogicalDatastoreType.CONFIGURATION, onf14CoreModelQNames.getTopLevelEquipment_IId()); } public Object getPmLock() { diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElementFactory.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElementFactory.java index 0c84cdf1b..eaef478d6 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElementFactory.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElementFactory.java @@ -21,9 +21,8 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl; import java.util.Optional; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs.CoreModel14; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; import org.slf4j.Logger; @@ -31,24 +30,21 @@ import org.slf4j.LoggerFactory; public class Onf14DomNetworkElementFactory implements NetworkElementFactory { - private static final Logger log = LoggerFactory.getLogger(Onf14DomNetworkElementFactory.class); + private static final Logger LOG = LoggerFactory.getLogger(Onf14DomNetworkElementFactory.class); @Override public Optional<NetworkElement> create(NetconfAccessor accessor, DeviceManagerServiceProvider serviceProvider) { Optional<NetworkElement> ne = Optional.empty(); - Capabilities capabilities = accessor.getCapabilites(); - if (capabilities.isSupportingNamespace(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER)) { - String namespaceRevision = capabilities - .getRevisionForNamespace(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER); - - Optional<NetconfDomAccessor> domAccessor = accessor.getNetconfDomAccessor(); - if (domAccessor.isPresent()) { - ne = Optional.of(new Onf14DomNetworkElement(domAccessor.get(), serviceProvider, namespaceRevision)); + Optional<NetconfDomAccessor> domAccessor = accessor.getNetconfDomAccessor(); + if (domAccessor.isPresent()) { + Optional<CoreModel14> onf14CoreModelQnames = CoreModel14.getModule(domAccessor.get()); + if (onf14CoreModelQnames.isPresent()) { + ne = Optional + .of(new Onf14DomNetworkElement(domAccessor.get(), serviceProvider, onf14CoreModelQnames.get())); } - - log.info("Create device:{}", ne.isPresent() ? ne.get().getClass().getSimpleName() : "not"); - } + } + LOG.info("Create device:{}", ne.isPresent() ? ne.get().getClass().getSimpleName() : "not"); return ne; } diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/Onf14DomToInternalDataModel.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/Onf14DomToInternalDataModel.java index af817fe18..ed7f7276e 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/Onf14DomToInternalDataModel.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/Onf14DomToInternalDataModel.java @@ -5,7 +5,7 @@ import java.util.HashSet; import java.util.Objects; import java.util.Set; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs.CoreModel14; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.InventoryBuilder; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; @@ -20,29 +20,29 @@ import org.slf4j.LoggerFactory; public class Onf14DomToInternalDataModel { private static final Logger LOG = LoggerFactory.getLogger(Onf14DomToInternalDataModel.class); - public Inventory getInternalEquipment(NodeId nodeId, MapEntryNode currentEq, MapEntryNode parentEq, - long treeLevel) { + public Inventory getInternalEquipment(NodeId nodeId, MapEntryNode currentEq, MapEntryNode parentEq, long treeLevel, + CoreModel14 qNames) { Objects.requireNonNull(nodeId); Objects.requireNonNull(currentEq); InventoryBuilder inventoryBuilder = new InventoryBuilder(); - String parentUuid = parentEq != null ? Onf14DMDOMUtility.getUuidFromEquipment(parentEq) : "None"; + String parentUuid = + parentEq != null ? Onf14DMDOMUtility.getUuidFromEquipment(parentEq, qNames.getQName("uuid")) : "None"; // General inventoryBuilder.setNodeId(nodeId.getValue()); inventoryBuilder.setTreeLevel(Uint32.valueOf(treeLevel)); - inventoryBuilder.setUuid(Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + inventoryBuilder.setUuid(Onf14DMDOMUtility.getUuidFromEquipment(currentEq, qNames.getQName("uuid"))); inventoryBuilder.setParentUuid(parentUuid); Set<String> containedHolderKeyList = new HashSet<>(); - MapNode containedHolderMap = (MapNode) currentEq - .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_CONTAINED_HOLDER)); + MapNode containedHolderMap = + (MapNode) currentEq.childByArg(new NodeIdentifier(qNames.getQName("contained-holder"))); if (containedHolderMap != null) { Collection<MapEntryNode> containedHolderCollection = containedHolderMap.body(); for (MapEntryNode holder : containedHolderCollection) { - String occupyingFru = Onf14DMDOMUtility.getLeafValue(holder, - Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_OCCUPYING_FRU); + String occupyingFru = Onf14DMDOMUtility.getLeafValue(holder, qNames.getQName("occupying-fru")); if (occupyingFru != null) { containedHolderKeyList.add(occupyingFru); @@ -52,73 +52,73 @@ public class Onf14DomToInternalDataModel { inventoryBuilder.setContainedHolder(containedHolderKeyList); // actual-equipment - ContainerNode actualEquipment = (ContainerNode) currentEq - .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQUIPMENT)); + ContainerNode actualEquipment = + (ContainerNode) currentEq.childByArg(new NodeIdentifier(qNames.getQName("actual-equipment"))); if (actualEquipment != null) { ContainerNode manThing = (ContainerNode) actualEquipment - .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_MANUFACTURED_THING)); + .childByArg(new NodeIdentifier(qNames.getQName("manufactured-thing"))); if (manThing != null) { // Manufacturer properties ContainerNode props = (ContainerNode) manThing - .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_MANUFACTURER_PROPS)); + .childByArg(new NodeIdentifier(qNames.getQName("manufacturer-properties"))); if (props != null) { - inventoryBuilder.setManufacturerName(Onf14DMDOMUtility.getLeafValue(props, - Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_MANUFACTURER_NAME)); + inventoryBuilder.setManufacturerName( + Onf14DMDOMUtility.getLeafValue(props, qNames.getQName("manufacturer-name"))); - inventoryBuilder.setManufacturerIdentifier(Onf14DMDOMUtility.getLeafValue(props, - Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_MANUFACTURER_ID)); + inventoryBuilder.setManufacturerIdentifier( + Onf14DMDOMUtility.getLeafValue(props, qNames.getQName("manufacturer-identifier"))); } else { LOG.debug("manufacturer-properties is not present in Equipment with uuid={}", - Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + Onf14DMDOMUtility.getUuidFromEquipment(currentEq, qNames.getQName("uuid"))); } // Equipment instance - ContainerNode equipmentInstance = (ContainerNode) manThing.childByArg( - new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_INSTANCE)); + ContainerNode equipmentInstance = + (ContainerNode) manThing.childByArg(new NodeIdentifier(qNames.getQName("equipment-instance"))); if (equipmentInstance != null) { - inventoryBuilder.setSerial(Onf14DMDOMUtility.getLeafValue(equipmentInstance, - Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_INSTANCE_SERIAL_NUM)); + inventoryBuilder.setSerial( + Onf14DMDOMUtility.getLeafValue(equipmentInstance, qNames.getQName("serial-number"))); - inventoryBuilder.setDate(Onf14DMDOMUtility.getLeafValue(equipmentInstance, - Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_INSTANCE_MANUFACTURED_DATE)); + inventoryBuilder.setDate( + Onf14DMDOMUtility.getLeafValue(equipmentInstance, qNames.getQName("manufactured-date"))); } else { LOG.debug("equipment-instance is not present in Equipment with uuid={}", - Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + Onf14DMDOMUtility.getUuidFromEquipment(currentEq, qNames.getQName("uuid"))); } // Equipment type - ContainerNode equipmentType = (ContainerNode) manThing.childByArg( - new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE)); + ContainerNode equipmentType = + (ContainerNode) manThing.childByArg(new NodeIdentifier(qNames.getQName("equipment-type"))); if (equipmentType != null) { - inventoryBuilder.setVersion(Onf14DMDOMUtility.getLeafValue(equipmentType, - Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_VERSION)); + inventoryBuilder + .setVersion(Onf14DMDOMUtility.getLeafValue(equipmentType, qNames.getQName("version"))); - inventoryBuilder.setDescription(Onf14DMDOMUtility.getLeafValue(equipmentType, - Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_DESCRIPTION)); + inventoryBuilder.setDescription( + Onf14DMDOMUtility.getLeafValue(equipmentType, qNames.getQName("description"))); - inventoryBuilder.setPartTypeId(Onf14DMDOMUtility.getLeafValue(equipmentType, - Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_PART_TYPE_ID)); + inventoryBuilder.setPartTypeId( + Onf14DMDOMUtility.getLeafValue(equipmentType, qNames.getQName("part-type-identifier"))); inventoryBuilder.setModelIdentifier(Onf14DMDOMUtility.getLeafValue(equipmentType, - Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_MODEL_ID)); + qNames.getQName("model-identifier"))); - inventoryBuilder.setTypeName(Onf14DMDOMUtility.getLeafValue(equipmentType, - Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_TYPE_NAME)); + inventoryBuilder + .setTypeName(Onf14DMDOMUtility.getLeafValue(equipmentType, qNames.getQName("type-name"))); } else { LOG.debug("equipment-type is not present in Equipment with uuid={}", - Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + Onf14DMDOMUtility.getUuidFromEquipment(currentEq, qNames.getQName("uuid"))); } } else { LOG.debug("manufactured-thing is not present in Equipment with uuid={}", - Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + Onf14DMDOMUtility.getUuidFromEquipment(currentEq, qNames.getQName("uuid"))); } } else { LOG.debug("actual-equipment is not present in Equipment with uuid={}", - Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + Onf14DMDOMUtility.getUuidFromEquipment(currentEq, qNames.getQName("uuid"))); } return inventoryBuilder.build(); diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/equipment/Onf14DomEquipmentManager.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/equipment/Onf14DomEquipmentManager.java index 5c7101199..6f7b24a19 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/equipment/Onf14DomEquipmentManager.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/equipment/Onf14DomEquipmentManager.java @@ -30,7 +30,7 @@ import java.util.Optional; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.Onf14DomToInternalDataModel; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs.CoreModel14; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; @@ -54,14 +54,15 @@ public class Onf14DomEquipmentManager { private final DataProvider databaseService; private final Onf14DomToInternalDataModel onf14Mapper; private final List<String> equipmentUuidList; + private final CoreModel14 qNames; public Onf14DomEquipmentManager(NetconfDomAccessor netconfDomAccessor, DataProvider databaseService, - Onf14DomToInternalDataModel onf14Mapper) { + Onf14DomToInternalDataModel onf14Mapper, CoreModel14 qNames) { super(); this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor); this.databaseService = Objects.requireNonNull(databaseService); this.onf14Mapper = Objects.requireNonNull(onf14Mapper); - + this.qNames = qNames; this.equipmentUuidList = new ArrayList<>(); } @@ -114,11 +115,10 @@ public class Onf14DomEquipmentManager { log.debug("DBRead Get equipment from mountpoint {} for uuid {}", accessData.getNodeId().getValue(), equipmentUuid); - InstanceIdentifierBuilder equipmentIIDBuilder = YangInstanceIdentifier.builder() - .node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) - .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT) - .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT, - QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT, "uuid").intern(), equipmentUuid); + InstanceIdentifierBuilder equipmentIIDBuilder = + YangInstanceIdentifier.builder().node(qNames.getQName("control-construct")) + .node(qNames.getQName("equipment")).nodeWithKey(qNames.getQName("equipment"), + QName.create(qNames.getQName("equipment"), "uuid").intern(), equipmentUuid); return accessData.readDataNode(LogicalDatastoreType.CONFIGURATION, equipmentIIDBuilder.build()); } @@ -128,32 +128,33 @@ public class Onf14DomEquipmentManager { // if the Equipment UUID is already in the list, it was already processed // needed for solving possible circular dependencies - if (equipmentUuidList.contains(Onf14DMDOMUtility.getUuidFromEquipment(currentEq))) { + if (equipmentUuidList.contains(Onf14DMDOMUtility.getUuidFromEquipment(currentEq, qNames.getQName("uuid")))) { log.debug("Not adding equipment with uuid {} because it was aleady added...", - Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + Onf14DMDOMUtility.getUuidFromEquipment(currentEq, qNames.getQName("uuid"))); return list; } // we add this to our internal list, such that we avoid circular dependencies - equipmentUuidList.add(Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + equipmentUuidList.add(Onf14DMDOMUtility.getUuidFromEquipment(currentEq, qNames.getQName("uuid"))); log.debug("Adding equipment with uuid {} to the database...", - Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + Onf14DMDOMUtility.getUuidFromEquipment(currentEq, qNames.getQName("uuid"))); // we add our current equipment to the database - list.add(onf14Mapper.getInternalEquipment(netconfDomAccessor.getNodeId(), currentEq, parentEq, treeLevel)); + list.add(onf14Mapper.getInternalEquipment(netconfDomAccessor.getNodeId(), currentEq, parentEq, treeLevel, + qNames)); // we iterate the kids of our current equipment and add them to the database // recursively // the actual reference is here: // /core-model:control-construct/equipment/contained-holder/occupying-fru - MapNode containedHolderMap = (MapNode) currentEq - .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_CONTAINED_HOLDER)); + MapNode containedHolderMap = + (MapNode) currentEq.childByArg(new NodeIdentifier(qNames.getQName("contained-holder"))); if (containedHolderMap != null) { Collection<MapEntryNode> containedHolderCollection = containedHolderMap.body(); for (MapEntryNode holder : containedHolderCollection) { String occupyingFru = Onf14DMDOMUtility.getLeafValue(holder, - Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_OCCUPYING_FRU); + qNames.getQName("occupying-fru")/*Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_OCCUPYING_FRU*/); if (occupyingFru != null) { Optional<NormalizedNode> childEq = readEquipmentInstance(netconfDomAccessor, occupyingFru); diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/Onf14DomInterfacePacManager.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/Onf14DomInterfacePacManager.java index 71f94dc26..d1914342f 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/Onf14DomInterfacePacManager.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/Onf14DomInterfacePacManager.java @@ -21,35 +21,32 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces; -import com.google.common.collect.Sets; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.Optional; import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.pm.PerformanceDataAirInterface; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Debug; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.notifications.Onf14DomAirInterfaceNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.notifications.Onf14DomAlarmsNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.notifications.Onf14DomEthernetContainerNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.notifications.Onf14DomWireInterfaceNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.qnames.Onf14DevicemanagerQNames; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.notifications.Onf14DomAirInterfaceNotificationListener; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.notifications.Onf14DomEthernetContainerNotificationListener; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.notifications.Onf14DomWireInterfaceNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs.AirInterface20; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs.Alarms10; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs.CoreModel14; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs.EthernetContainer20; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs.WireInterface20; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; @@ -84,11 +81,11 @@ import org.slf4j.LoggerFactory; public class Onf14DomInterfacePacManager { - private static final Logger log = LoggerFactory.getLogger(Onf14DomInterfacePacManager.class); + private static final Logger LOG = LoggerFactory.getLogger(Onf14DomInterfacePacManager.class); - private static final YangInstanceIdentifier LTP_IID = - YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) - .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP).build(); + // private static final YangInstanceIdentifier LTP_IID = + // YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) + // .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP).build(); private final NetconfDomAccessor netconfDomAccessor; private final @NonNull DeviceManagerServiceProvider serviceProvider; @@ -108,15 +105,40 @@ public class Onf14DomInterfacePacManager { @NonNull private final Onf14DomWireInterfaceNotificationListener wireInterfaceNotificationListener; + // alarm-1-0 related alarms + private final Onf14DomAlarmsNotificationListener alarmNotifListener; + + // Services and models private final @NonNull FaultService faultService; + private final @NonNull CoreModel14 coreModel14; + + private final Optional<Alarms10> alarms10; + private final Optional<AirInterface20> airInterface20; + private final Optional<EthernetContainer20> ethernetInterface20; + private final Optional<WireInterface20> wireInterface20; + + private final Onf14Interfaces interfaces; public Onf14DomInterfacePacManager(@NonNull NetconfDomAccessor netconfDomAccessor, - @NonNull DeviceManagerServiceProvider serviceProvider) { + @NonNull DeviceManagerServiceProvider serviceProvider, CoreModel14 coreModel14) { this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor); this.serviceProvider = Objects.requireNonNull(serviceProvider); this.faultService = Objects.requireNonNull(serviceProvider.getFaultService()); - + this.interfaces = new Onf14Interfaces(); + + this.coreModel14 = coreModel14; + this.alarms10 = Alarms10.getModule(netconfDomAccessor, coreModel14); + this.airInterface20 = AirInterface20.getModule(netconfDomAccessor, coreModel14); + this.ethernetInterface20 = EthernetContainer20.getModule(netconfDomAccessor, coreModel14); + this.wireInterface20 = WireInterface20.getModule(netconfDomAccessor, coreModel14); + + if (alarms10.isPresent()) { + this.alarmNotifListener = + new Onf14DomAlarmsNotificationListener(netconfDomAccessor, serviceProvider, alarms10.get()); + } else { + this.alarmNotifListener = null; + } this.airInterfaceNotificationListener = new Onf14DomAirInterfaceNotificationListener(netconfDomAccessor, serviceProvider); this.ethernetContainerNotificationListener = @@ -128,8 +150,9 @@ public class Onf14DomInterfacePacManager { public void register() { // storing all the LTP UUIDs internally, for later usage, for air-interface and // ethernet-container and wire-interface - readKeys(); + coreModel14.readKeys(interfaces); readAndWriteInterfaceCurrentProblems(); + readCurrentAlarms(); registerForNotifications(); } @@ -137,106 +160,64 @@ public class Onf14DomInterfacePacManager { return airInterfaceList; } - public PerformanceDataLtp readAirInterfaceHistoricalPerformanceData(String ltpUuid, String localId, - PerformanceDataLtp res) { - log.debug("Get historical performance data for class {} from mountpoint {} for LTP uuid {} and local-id {}", - Onf14DevicemanagerQNames.AIR_INTERFACE_2_0_MODULE, netconfDomAccessor.getNodeId().getValue(), ltpUuid, - localId); - - // constructing the IID needs the augmentation exposed by the air-interface-2-0 - // model - - InstanceIdentifierBuilder layerProtocolIID = - YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) - .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP) - .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, - QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, "uuid").intern(), ltpUuid) - .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL) - .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, QName - .create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, "local-id").intern(), - localId); - - @NonNull - AugmentationIdentifier airInterfacePacIID = YangInstanceIdentifier.AugmentationIdentifier - .create(Sets.newHashSet(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC)); - - InstanceIdentifierBuilder augmentedAirInterfacePacIID = - YangInstanceIdentifier.builder(layerProtocolIID.build()).node(airInterfacePacIID); - - // reading historical performance list for this specific LTP and LP - Optional<NormalizedNode> airInterfacePacDataOpt = - netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedAirInterfacePacIID.build()); - log.debug("Performance Data = {}", airInterfacePacDataOpt.get().body()); - if (airInterfacePacDataOpt.isPresent()) { - AugmentationNode airInterfacePacData = (AugmentationNode) airInterfacePacDataOpt.get(); - ContainerNode cn = (ContainerNode) airInterfacePacData - .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC)); - if (cn != null) { - ContainerNode airIntfHistPerf = (ContainerNode) cn - .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_HISTORICAL_PERFORMANCES)); - if (airIntfHistPerf != null) { - MapNode airInterfaceHistoricalPerformanceList = (MapNode) airIntfHistPerf.childByArg( - new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_HISTORICAL_PERFORMANCES_LIST)); - if (airInterfaceHistoricalPerformanceList != null) { - Collection<MapEntryNode> airInterfaceHistoricalPerfCollection = - airInterfaceHistoricalPerformanceList.body(); - for (MapEntryNode airInterfaceHistPerf : airInterfaceHistoricalPerfCollection) { - res.add(new PerformanceDataAirInterface(netconfDomAccessor.getNodeId(), ltpUuid, localId, - airInterfaceHistPerf)); - } - return res; - } else { - log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); - } - } - } + private void readCurrentAlarms() { + if (alarms10.isPresent()) { + FaultData resultList = alarms10.get().getCurrentAlarms(); + LOG.debug("ResultList = {}", resultList.toString()); + faultService.initCurrentProblemStatus(netconfDomAccessor.getNodeId(), resultList); } - return null; } private void readAndWriteInterfaceCurrentProblems() { // Read all fault data FaultData resultList = new FaultData(); int problems = 0; - readAllAirInterfaceCurrentProblems(resultList); - problems = resultList.size(); - log.debug("NETCONF read air interface current problems completed. Got back {} problems.", problems); + if (airInterface20.isPresent()) { + resultList = airInterface20.get().readAllCurrentProblems(resultList, airInterfaceList); - readAllEthernetContainerCurrentProblems(resultList); - problems = resultList.size() - problems; - log.debug("NETCONF read current problems completed. Got back {} problems.", problems); + problems = resultList.size(); + LOG.debug("NETCONF read airinterface current problems completed. Got back {} problems.", problems); + } + if (ethernetInterface20.isPresent()) { + resultList = ethernetInterface20.get().readAllCurrentProblems(resultList, ethernetContainerList); - readAllWireInterfaceCurrentProblems(resultList); - problems = resultList.size(); - log.debug("NETCONF read wire interface current problems completed. Got back {} problems.", problems); + problems = resultList.size() - problems; + LOG.debug("NETCONF read ethernet interface current problems completed. Got back {} problems.", problems); + } + if (wireInterface20.isPresent()) { + resultList = wireInterface20.get().readAllCurrentProblems(resultList, wireInterfaceList); + problems = resultList.size() - problems; + LOG.debug("NETCONF read wire interface current problems completed. Got back {} problems.", problems); + } if (resultList.size() > 0) { faultService.initCurrentProblemStatus(netconfDomAccessor.getNodeId(), resultList); - log.debug("DB write current problems completed"); + LOG.debug("DB write current problems completed"); } } private void readKeys() { Optional<NormalizedNode> ltpData = readLtpData(netconfDomAccessor); - log.debug("LTP Data is - {}", ltpData); + LOG.debug("LTP Data is - {}", ltpData); if (ltpData.isPresent()) { + LOG.debug("In readKeys - ltpData = {}", ltpData.get()); MapNode ccLtp = (MapNode) ltpData.get(); if (ccLtp != null) { - log.debug("Iterating the LTP list for node {}", netconfDomAccessor.getNodeId().getValue()); + LOG.debug("Iterating the LTP list for node {}", netconfDomAccessor.getNodeId().getValue()); Collection<MapEntryNode> ltpList = ccLtp.body(); // iterating all the Logical Termination Point list for (MapEntryNode ltp : ltpList) { - MapNode lpList = (MapNode) ltp - .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL)); + MapNode lpList = + (MapNode) ltp.childByArg(new NodeIdentifier(coreModel14.getQName("layer-protocol"))); // the Layer Protocol list should contain only one item, since we have an 1:1 // relationship between the LTP and the LP if (lpList != null && lpList.size() != 1) { - log.debug("Layer protocol has no 1:1 relationship with the LTP."); + LOG.debug("Layer protocol has no 1:1 relationship with the LTP."); return; } // accessing the LP, which should be only 1 @@ -244,49 +225,37 @@ public class Onf14DomInterfacePacManager { for (MapEntryNode lpEntry : lp) { String layerProtocolName = Onf14DMDOMUtility.getLeafValue(lpEntry, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_NAME); + coreModel14.getQName("layer-protocol-name")); if (layerProtocolName != null) { // if the LTP has an airInterface technology extension, the layer protocol name // is air-layer if (layerProtocolName.contains("LAYER_PROTOCOL_NAME_TYPE_AIR_LAYER")) { TechnologySpecificPacKeys airInterfaceKey = new TechnologySpecificPacKeys( - Onf14DMDOMUtility.getLeafValue(ltp, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID), - Onf14DMDOMUtility.getLeafValue(lpEntry, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID)); + Onf14DMDOMUtility.getLeafValue(ltp, coreModel14.getQName("uuid")), + Onf14DMDOMUtility.getLeafValue(lpEntry, coreModel14.getQName("local-id"))); airInterfaceList.add(airInterfaceKey); - log.debug("Adding Ltp with uuid {} and local-id {} to the air-interface list", - Onf14DMDOMUtility.getLeafValue(ltp, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID), - Onf14DMDOMUtility.getLeafValue(lpEntry, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID)); + LOG.debug("Adding Ltp with uuid {} and local-id {} to the air-interface list", + Onf14DMDOMUtility.getLeafValue(ltp, coreModel14.getQName("uuid")), + Onf14DMDOMUtility.getLeafValue(lpEntry, coreModel14.getQName("local-id"))); } - // if the LTP has an ethernetContainer technology extension, the layer protocol + // if the LTP has an ethernetContainier technology extension, the layer protocol // name is ethernet-container-layer else if (layerProtocolName.contains("LAYER_PROTOCOL_NAME_TYPE_ETHERNET_CONTAINER_LAYER")) { TechnologySpecificPacKeys ethernetContainerKey = new TechnologySpecificPacKeys( - Onf14DMDOMUtility.getLeafValue(ltp, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID), - Onf14DMDOMUtility.getLeafValue(lpEntry, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID)); + Onf14DMDOMUtility.getLeafValue(ltp, coreModel14.getQName("uuid")), + Onf14DMDOMUtility.getLeafValue(lpEntry, coreModel14.getQName("local-id"))); ethernetContainerList.add(ethernetContainerKey); - log.debug("Adding Ltp with uuid {} and local-id {} to the ethernet-container list", - Onf14DMDOMUtility.getLeafValue(ltp, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID), - Onf14DMDOMUtility.getLeafValue(lpEntry, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID)); + LOG.debug("Adding Ltp with uuid {} and local-id {} to the ethernet-container list", + Onf14DMDOMUtility.getLeafValue(ltp, coreModel14.getQName("uuid")), + Onf14DMDOMUtility.getLeafValue(lpEntry, coreModel14.getQName("local-id"))); } else if (layerProtocolName.contains("LAYER_PROTOCOL_NAME_TYPE_WIRE_LAYER")) { TechnologySpecificPacKeys wireInterfaceKey = new TechnologySpecificPacKeys( - Onf14DMDOMUtility.getLeafValue(ltp, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID), - Onf14DMDOMUtility.getLeafValue(lpEntry, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID)); + Onf14DMDOMUtility.getLeafValue(ltp, coreModel14.getQName("uuid")), + Onf14DMDOMUtility.getLeafValue(lpEntry, coreModel14.getQName("local-id"))); wireInterfaceList.add(wireInterfaceKey); - log.debug("Adding Ltp with uuid {} and local-id {} to the wire-interface list", - Onf14DMDOMUtility.getLeafValue(ltp, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID), - Onf14DMDOMUtility.getLeafValue(lpEntry, - Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID)); + LOG.debug("Adding Ltp with uuid {} and local-id {} to the wire-interface list", + Onf14DMDOMUtility.getLeafValue(ltp, coreModel14.getQName("uuid")), + Onf14DMDOMUtility.getLeafValue(lpEntry, coreModel14.getQName("local-id"))); } } } @@ -295,207 +264,12 @@ public class Onf14DomInterfacePacManager { } } - private void readAllAirInterfaceCurrentProblems(FaultData resultList) { - - int idxStart; // Start index for debug messages - - for (TechnologySpecificPacKeys key : airInterfaceList) { - idxStart = resultList.size(); - - readAirInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); - Debug.debugResultList(key.getLtpUuid(), resultList, idxStart); - } - } - - private void readAllEthernetContainerCurrentProblems(FaultData resultList) { - - int idxStart; // Start index for debug messages - - for (TechnologySpecificPacKeys key : ethernetContainerList) { - idxStart = resultList.size(); - - readEthernetContainerCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); - Debug.debugResultList(key.getLtpUuid(), resultList, idxStart); - } - } - - private void readAllWireInterfaceCurrentProblems(FaultData resultList) { - - int idxStart; // Start index for debug messages - - for (TechnologySpecificPacKeys key : wireInterfaceList) { - idxStart = resultList.size(); - - readWireInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); - Debug.debugResultList(key.getLtpUuid(), resultList, idxStart); - } - } - - private void readAirInterfaceCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) { - - log.debug("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}", - Onf14DevicemanagerQNames.AIR_INTERFACE_2_0_MODULE, netconfDomAccessor.getNodeId().getValue(), ltpUuid, - localId); - - // constructing the IID needs the augmentation exposed by the air-interface-2-0 - // model - - InstanceIdentifierBuilder layerProtocolIID = - YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) - .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP) - .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, - QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, "uuid").intern(), ltpUuid) - .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL) - .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, QName - .create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, "local-id").intern(), - localId); - - @NonNull - AugmentationIdentifier airInterfacePacIID = YangInstanceIdentifier.AugmentationIdentifier - .create(Sets.newHashSet(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC)); - - InstanceIdentifierBuilder augmentedAirInterfacePacIID = - YangInstanceIdentifier.builder(layerProtocolIID.build()).node(airInterfacePacIID); - - // reading all the current-problems list for this specific LTP and LP - Optional<NormalizedNode> airInterfacePacDataOpt = - netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedAirInterfacePacIID.build()); - - if (airInterfacePacDataOpt.isPresent()) { - AugmentationNode airInterfacePacData = (AugmentationNode) airInterfacePacDataOpt.get(); - MapNode airInterfaceCurrentProblemsList = (MapNode) airInterfacePacData - .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_LIST)); - if (airInterfaceCurrentProblemsList != null) { - Collection<MapEntryNode> airInterfaceProblemsCollection = airInterfaceCurrentProblemsList.body(); - for (MapEntryNode airInterfaceProblem : airInterfaceProblemsCollection) { - resultList.add(netconfDomAccessor.getNodeId(), - Integer.parseInt(Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, - Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_SEQ_NO)), - new DateAndTime(Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, - Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_TIMESTAMP)), - ltpUuid, - Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, - Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_PROBLEM_NAME), - InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, - Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_PROBLEM_SEVERITY))); - } - } else { - log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); - } - } - } - - private void readEthernetContainerCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) { - - log.debug( - "DBRead Get current problems for Ethernet Container from mountpoint {} for LTP uuid {} and local-id {}", - netconfDomAccessor.getNodeId().getValue(), ltpUuid, localId); - - // constructing the IID needs the augmentation exposed by the - // ethernet-container-2-0 model - InstanceIdentifierBuilder layerProtocolIID = - YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) - .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP) - .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, - QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, "uuid").intern(), ltpUuid) - .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL) - .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, QName - .create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, "local-id").intern(), - localId); - - @NonNull - AugmentationIdentifier ethernetContainerIID = YangInstanceIdentifier.AugmentationIdentifier - .create(Sets.newHashSet(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_PAC)); - - InstanceIdentifierBuilder augmentedEthernetContainerConfigurationIID = - YangInstanceIdentifier.builder(layerProtocolIID.build()).node(ethernetContainerIID); - - // reading all the current-problems list for this specific LTP and LP - Optional<NormalizedNode> etherntContainerConfigurationOpt = netconfDomAccessor - .readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedEthernetContainerConfigurationIID.build()); - - if (etherntContainerConfigurationOpt.isPresent()) { - AugmentationNode etherntContainerConfiguration = (AugmentationNode) etherntContainerConfigurationOpt.get(); - MapNode ethernetContainerCurrentProblemsList = (MapNode) etherntContainerConfiguration - .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_LIST)); - if (ethernetContainerCurrentProblemsList != null) { - Collection<MapEntryNode> ethernetContainerProblemsCollection = - ethernetContainerCurrentProblemsList.body(); - for (MapEntryNode ethernetContainerProblem : ethernetContainerProblemsCollection) { - resultList.add(netconfDomAccessor.getNodeId(), - Integer.parseInt(Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem, - Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_SEQ_NO)), - new DateAndTime(Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem, - Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_TIMESTAMP)), - ltpUuid, - Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem, - Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_PROBLEM_NAME), - InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue( - ethernetContainerProblem, - Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_PROBLEM_SEVERITY))); - } - } else { - log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); - } - } - - } + private void registerForNotifications() { - private void readWireInterfaceCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) { - - log.debug("DBRead Get current problems for Wire Interface from mountpoint {} for LTP uuid {} and local-id {}", - netconfDomAccessor.getNodeId().getValue(), ltpUuid, localId); - - // constructing the IID needs the augmentation exposed by the wire-interface-2-0 - // model - InstanceIdentifierBuilder layerProtocolIID = - YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) - .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP) - .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, - QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, "uuid").intern(), ltpUuid) - .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL) - .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, QName - .create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, "local-id").intern(), - localId); - - @NonNull - AugmentationIdentifier wireInterfacePacIID = YangInstanceIdentifier.AugmentationIdentifier - .create(Sets.newHashSet(Onf14DevicemanagerQNames.WIRE_INTERFACE_PAC)); - - InstanceIdentifierBuilder augmentedWireInterfaceConfigurationIID = - YangInstanceIdentifier.builder(layerProtocolIID.build()).node(wireInterfacePacIID); - - // reading all the current-problems list for this specific LTP and LP - Optional<NormalizedNode> wireInterfaceConfigurationOpt = netconfDomAccessor - .readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedWireInterfaceConfigurationIID.build()); - - if (wireInterfaceConfigurationOpt.isPresent()) { - AugmentationNode wireInterfaceConfiguration = (AugmentationNode) wireInterfaceConfigurationOpt.get(); - MapNode wireInterfaceCurrentProblemsList = (MapNode) wireInterfaceConfiguration - .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_LIST)); - if (wireInterfaceCurrentProblemsList != null) { - Collection<MapEntryNode> wireInterfaceProblemsCollection = wireInterfaceCurrentProblemsList.body(); - for (MapEntryNode wireInterfaceProblem : wireInterfaceProblemsCollection) { - resultList.add(netconfDomAccessor.getNodeId(), - Integer.parseInt(Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem, - Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_SEQ_NO)), - new DateAndTime(Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem, - Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_TIMESTAMP)), - ltpUuid, - Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem, - Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_PROBLEM_NAME), - InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem, - Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_PROBLEM_SEVERITY))); - } - } else { - log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); - } + if (alarms10.isPresent()) { + alarms10.get().doRegisterNotificationListener(alarmNotifListener); } - } - - private void registerForNotifications() { - QName[] airInterfaceNotifications = {Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION, Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION, Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION, @@ -519,13 +293,22 @@ public class Onf14DomInterfacePacManager { } public Optional<NormalizedNode> readLtpData(NetconfDomAccessor netconfDomAccessor) { - log.info("Reading Logical Termination Point data"); - return netconfDomAccessor.readDataNode(LogicalDatastoreType.CONFIGURATION, LTP_IID); + LOG.info("Reading Logical Termination Point data"); + return netconfDomAccessor.readDataNode(LogicalDatastoreType.CONFIGURATION, getLtp_IID()); } public PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull TechnologySpecificPacKeys lp) { PerformanceDataLtp res = new PerformanceDataLtp(); - readAirInterfaceHistoricalPerformanceData(lp.getLtpUuid(), lp.getLocalId(), res); + if (airInterface20.isPresent()) { + airInterface20.get().readAirInterfaceHistoricalPerformanceData(lp.getLtpUuid(), lp.getLocalId(), res); + } else { + LOG.warn("Air Interface Module Unsupported. PM data not read"); + } return res; } + + private YangInstanceIdentifier getLtp_IID() { + return YangInstanceIdentifier.builder().node(coreModel14.getQName("control-construct")) + .node(coreModel14.getQName("logical-termination-point")).build(); + } } diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/Onf14Interfaces.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/Onf14Interfaces.java new file mode 100644 index 000000000..47e164677 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/Onf14Interfaces.java @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces; + +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; + +public class Onf14Interfaces { + + public enum Key { + AIRINTERFACE, + ETHERNETCONTAINER, + WIREINTERFACE + } + + private final Map<Key, List<TechnologySpecificPacKeys>> interfaces; + + public Onf14Interfaces() { + interfaces = new EnumMap<>(Key.class); + for (Key key : Key.values()) { + interfaces.put(key, new ArrayList<TechnologySpecificPacKeys>()); + } + } + + public void add(Key key, List<TechnologySpecificPacKeys> specificInterfaceKeyList) { + interfaces.get(key).addAll(specificInterfaceKeyList); + } +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/TechnologySpecific.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/TechnologySpecific.java new file mode 100644 index 000000000..2ad33aed8 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/TechnologySpecific.java @@ -0,0 +1,27 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces; + +public interface TechnologySpecific { + + +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/notifications/Onf14DomAirInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/notifications/Onf14DomAirInterfaceNotificationListener.java index e32ca0134..fbc2d77df 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/notifications/Onf14DomAirInterfaceNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/notifications/Onf14DomAirInterfaceNotificationListener.java @@ -19,12 +19,12 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.notifications; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.notifications; import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.qnames.Onf14DevicemanagerQNames; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; import org.opendaylight.mdsal.dom.api.DOMNotification; diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/notifications/Onf14DomAlarmsNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/notifications/Onf14DomAlarmsNotificationListener.java new file mode 100644 index 000000000..3243a0931 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/notifications/Onf14DomAlarmsNotificationListener.java @@ -0,0 +1,69 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.notifications; + +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs.Alarms10; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.mdsal.dom.api.DOMNotificationListener; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Onf14DomAlarmsNotificationListener implements DOMNotificationListener { + + private static final Logger log = LoggerFactory.getLogger(Onf14DomAlarmsNotificationListener.class); + + private final DeviceManagerServiceProvider serviceProvider; + private final Alarms10 alarms10; + + public Onf14DomAlarmsNotificationListener(NetconfDomAccessor netconfDomAccessor, + DeviceManagerServiceProvider serviceProvider, Alarms10 alarms10) { + this.serviceProvider = serviceProvider; + this.alarms10 = alarms10; + } + + @Override + public void onNotification(@NonNull DOMNotification domNotification) { + log.debug("In AlarmsNotificationListener - Got event of type :: {} {}", domNotification.getType(), + domNotification.getBody()); + if (alarms10.isAlarmEventNotification(domNotification)) { + onAlarmEventNotification(domNotification); + } else { + log.error("Unknown notification received - {}", domNotification.getType()); + } + } + + private void onAlarmEventNotification(@NonNull DOMNotification domNotification) { + ContainerNode cn = domNotification.getBody(); + + FaultlogEntity faultAlarm = alarms10.getFaultlogEntity(cn); + serviceProvider.getFaultService().faultNotification(faultAlarm); + alarms10.sendNotification(serviceProvider.getWebsocketService(), domNotification, cn); + log.debug("onAlarmEventNotification log entry written"); + + } + +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/notifications/Onf14DomEthernetContainerNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/notifications/Onf14DomEthernetContainerNotificationListener.java index 3f2b95e93..ec006f9b4 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/notifications/Onf14DomEthernetContainerNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/notifications/Onf14DomEthernetContainerNotificationListener.java @@ -1,9 +1,9 @@ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.notifications; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.notifications; import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.qnames.Onf14DevicemanagerQNames; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; import org.opendaylight.mdsal.dom.api.DOMNotification; diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/notifications/Onf14DomWireInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/notifications/Onf14DomWireInterfaceNotificationListener.java index 9e7b35bc2..bae9c30f2 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/notifications/Onf14DomWireInterfaceNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/notifications/Onf14DomWireInterfaceNotificationListener.java @@ -1,9 +1,9 @@ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.notifications; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.notifications; import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.qnames.Onf14DevicemanagerQNames; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; import org.opendaylight.mdsal.dom.api.DOMNotification; diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/pm/PerformanceDataAirInterface.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/pm/PerformanceDataAirInterface.java index 8abdb1e8f..d66f58fb9 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/pm/PerformanceDataAirInterface.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/pm/PerformanceDataAirInterface.java @@ -19,7 +19,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.pm; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.qnames.Onf14DevicemanagerQNames; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PmdataEntityBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.entity.PerformanceDataBuilder; diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/qnames/DevicemanagerQNames.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/qnames/DevicemanagerQNames.java new file mode 100644 index 000000000..4c90b24ad --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/qnames/DevicemanagerQNames.java @@ -0,0 +1,66 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.qnames; + +import java.util.List; +import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; + +public class DevicemanagerQNames { + + protected QNameModule qNameModule; + protected String revision; + + public DevicemanagerQNames(QNameModule qnm, String revision) { + this.qNameModule = qnm; + this.revision = revision; + } + + public QName getQName(String localName) { + return QName.create(qNameModule, localName); + } + + public String getNamespaceRevision() { + return revision; + } + + public QNameModule getQNameModule() { + return qNameModule; + } + + public static Optional<DevicemanagerQNames> getDevicemanagerQNames(Capabilities capabilities, + List<QNameModule> modules) { + + for (QNameModule module : modules) { + + if (capabilities.isSupportingNamespaceAndRevision(module.getNamespace().toString(), + module.getRevision().toString())) { + String namespaceRevision = module.getRevision().toString(); + return Optional.of(new DevicemanagerQNames(module, namespaceRevision)); + } + } + + return Optional.empty(); + } +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DevicemanagerQNames.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/qnames/Onf14DevicemanagerQNames.java index f4fd2118f..a5d663bb5 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DevicemanagerQNames.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/qnames/Onf14DevicemanagerQNames.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.qnames; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; @@ -27,53 +27,6 @@ import org.opendaylight.yangtools.yang.common.Revision; import org.opendaylight.yangtools.yang.common.XMLNamespace; public class Onf14DevicemanagerQNames { - public static final QNameModule CORE_MODEL_1_4_MODULE = - QNameModule.create(XMLNamespace.of("urn:onf:yang:core-model-1-4"), Revision.of("2019-11-27")); - public static final QName CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER = - QName.create(CORE_MODEL_1_4_MODULE, "control-construct"); - public static final QName CORE_MODEL_CC_TOP_LEVEL_EQPT = QName.create(CORE_MODEL_1_4_MODULE, "top-level-equipment"); - public static final QName CORE_MODEL_CC_EQPT = QName.create(CORE_MODEL_1_4_MODULE, "equipment"); - public static final QName CORE_MODEL_CC_EQPT_GLOBAL_CLASS_UUID = QName.create(CORE_MODEL_1_4_MODULE, "uuid"); - public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQUIPMENT = - QName.create(CORE_MODEL_1_4_MODULE, "actual-equipment"); - public static final QName CORE_MODEL_CC_EQPT_CONTAINED_HOLDER = - QName.create(CORE_MODEL_1_4_MODULE, "contained-holder"); - public static final QName CORE_MODEL_CC_EQPT_OCCUPYING_FRU = QName.create(CORE_MODEL_1_4_MODULE, "occupying-fru"); - public static final QName CORE_MODEL_CC_EQPT_MANUFACTURED_THING = - QName.create(CORE_MODEL_1_4_MODULE, "manufactured-thing"); - public static final QName CORE_MODEL_CC_EQPT_MANUFACTURER_PROPS = - QName.create(CORE_MODEL_1_4_MODULE, "manufacturer-properties"); - public static final QName CORE_MODEL_CC_EQPT_MANUFACTURER_NAME = - QName.create(CORE_MODEL_1_4_MODULE, "manufacturer-name"); - public static final QName CORE_MODEL_CC_EQPT_MANUFACTURER_ID = - QName.create(CORE_MODEL_1_4_MODULE, "manufacturer-identifier"); - public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_INSTANCE = - QName.create(CORE_MODEL_1_4_MODULE, "equipment-instance"); - public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_INSTANCE_SERIAL_NUM = - QName.create(CORE_MODEL_1_4_MODULE, "serial-number"); - public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_INSTANCE_MANUFACTURED_DATE = - QName.create(CORE_MODEL_1_4_MODULE, "manufactured-date"); - public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE = - QName.create(CORE_MODEL_1_4_MODULE, "equipment-type"); - public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_VERSION = - QName.create(CORE_MODEL_1_4_MODULE, "version"); - public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_DESCRIPTION = - QName.create(CORE_MODEL_1_4_MODULE, "description"); - public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_MODEL_ID = - QName.create(CORE_MODEL_1_4_MODULE, "model-identifier"); - public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_PART_TYPE_ID = - QName.create(CORE_MODEL_1_4_MODULE, "part-type-identifier"); - public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_TYPE_NAME = - QName.create(CORE_MODEL_1_4_MODULE, "type-name"); - - - public static final QName CORE_MODEL_CC_LTP = QName.create(CORE_MODEL_1_4_MODULE, "logical-termination-point"); - public static final QName CORE_MODEL_CC_LTP_LAYER_PROTOCOL = QName.create(CORE_MODEL_1_4_MODULE, "layer-protocol"); - public static final QName CORE_MODEL_CC_LTP_LAYER_PROTOCOL_NAME = - QName.create(CORE_MODEL_1_4_MODULE, "layer-protocol-name"); - public static final QName CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID = - QName.create(CORE_MODEL_1_4_MODULE, "local-id"); - public static final QName CORE_MODEL_CC_LTP_UUID = QName.create(CORE_MODEL_1_4_MODULE, "uuid"); //Interface Notifications - common fields private static String COUNTER = "counter"; @@ -350,4 +303,14 @@ public class Onf14DevicemanagerQNames { public static final QName WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_TIMESTAMP = QName.create(WIRE_INTERFACE_2_0_MODULE, TIMESTAMP); + + private final QNameModule coreModel14Module; + private final String namespaceRevision; //TODO generate out of coreModel14Module + + private Onf14DevicemanagerQNames(QNameModule coreModel14Module, String namespaceRevision) { + this.coreModel14Module = coreModel14Module; + this.namespaceRevision = namespaceRevision; + + } + } diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DMDOMUtility.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DMDOMUtility.java index ae1884dcb..dd20b5e6a 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DMDOMUtility.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DMDOMUtility.java @@ -27,8 +27,14 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity; import org.opendaylight.mdsal.dom.api.DOMEvent; import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; @@ -44,26 +50,93 @@ public class Onf14DMDOMUtility { public static final Logger LOG = LoggerFactory.getLogger(Onf14DMDOMUtility.class); + /* + * /(urn:onf:yang:core-model-1-4?revision=2019-11-27)control-construct/logical- + * termination-point/logical-termination-point[{(urn:onf:yang:core-model-1-4? + * revision=2019-11-27)uuid=10004041-0000-0001-0001-3c4cd0db3b20}] + */ + private static final Pattern ALARM_RESOURCE_PATTERN = + Pattern.compile(".*uuid=([0-9a-z]*-[0-9a-z]*-[0-9a-z]*-[0-9a-z]*-[0-9a-z]*).*", Pattern.MULTILINE); + private Onf14DMDOMUtility() {} - public static String getLeafValue(DataContainerNode componentEntry, QName leafQName) { + private static String getLeafValueX(DataContainerNode componentEntry, QName leafQName) { NodeIdentifier leafNodeIdentifier = new NodeIdentifier(leafQName); + LeafNode<?> optLeafNode = (LeafNode<?>) componentEntry.getChildByArg(leafNodeIdentifier); + if (optLeafNode.body() instanceof QName) { + LOG.debug("Leaf is of type QName"); // Ex: + // ImmutableLeafNode{identifier=(urn:onf:yang:air-interface-2-0?revision=2020-01-21)severity, + // body=(urn:onf:yang:air-interface-2-0?revision=2020-01-21)SEVERITY_TYPE_MAJOR} + String severity_ = optLeafNode.body().toString(); + return severity_.substring(severity_.indexOf(')') + 1); // Any other solution?? + } + return optLeafNode.body().toString(); + } + + /** + * Return value as String + * @param componentEntry Container node with data + * @param leafQName Leaf to be converted + * @return String or null + */ + public static String getLeafValue(DataContainerNode componentEntry, QName leafQName) { try { - LeafNode<?> optLeafNode = (LeafNode<?>) componentEntry.getChildByArg(leafNodeIdentifier); - if (optLeafNode.body() instanceof QName) { - LOG.debug("Leaf is of type QName"); // Ex: - // ImmutableLeafNode{identifier=(urn:onf:yang:air-interface-2-0?revision=2020-01-21)severity, - // body=(urn:onf:yang:air-interface-2-0?revision=2020-01-21)SEVERITY_TYPE_MAJOR} - String severity_ = optLeafNode.body().toString(); - return severity_.substring(severity_.indexOf(')') + 1); // Any other solution?? - } - return optLeafNode.body().toString(); + return getLeafValueX(componentEntry, leafQName); } catch (VerifyException ve) { LOG.debug("Leaf with QName {} not found", leafQName); return null; } } + /** + * Return value as Integer + * + * @param componentEntry Container node with data + * @param leafQName Leaf to be converted + * @return Integer with value + * @throws IllegalArgumentException, VerifyException + */ + public static Integer getLeafValueInt(DataContainerNode componentEntry, QName leafQName) { + String val = getLeafValueX(componentEntry, leafQName); + if (val == null || val.isEmpty()) + throw new IllegalArgumentException("Value should not be null or empty"); + return Integer.parseInt(val); + } + + /** + * Return value as DateAndTime + * + * @param componentEntry Container node with data + * @param leafQName Leaf to be converted + * @return DateAndTime value + * @throws IllegalArgumentException, VerifyException + */ + public static DateAndTime getLeafValueDateAndTime(DataContainerNode componentEntry, QName leafQName) { + return new DateAndTime(getLeafValueX(componentEntry, leafQName)); + } + + /** + * return string with Uuid + * @param componentEntry Container node with data + * @param resource Leaf to be converted + * @return Uuid + */ + public static @Nullable String getLeafValueUuid(DataContainerNode componentEntry, QName resource) { + return extractUuid(getLeafValue(componentEntry, resource)); + } + + /** + * return internal severity + * @param componentEntry Container node with data + * @param resource Leaf to be converted + * @return Internal SeverityType + */ + public static @Nullable SeverityType getLeafValueInternalSeverity(DataContainerNode componentEntry, QName resource) { + return InternalDataModelSeverity + .mapSeverity(Onf14DMDOMUtility.getLeafValue(componentEntry, resource)); + } + + public static List<String> getLeafListValue(DataContainerNode componentEntry, QName leafListQName) { List<String> containsChildList = new ArrayList<>(); try { @@ -80,14 +153,13 @@ public class Onf14DMDOMUtility { return containsChildList; } - public static String getUuidFromEquipment(MapEntryNode equipment) { + public static String getUuidFromEquipment(MapEntryNode equipment, QName qName) { LOG.debug("Equipment Identifier is {}", equipment.getIdentifier()); NodeIdentifierWithPredicates componentKey = equipment.getIdentifier(); // list key LOG.debug("Key Name is - {}", componentKey.keySet()); - LOG.debug("Key Value is - {}", - componentKey.getValue(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_GLOBAL_CLASS_UUID)); + LOG.debug("Key Value is - {}", componentKey.getValue(qName)); - return componentKey.getValue(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_GLOBAL_CLASS_UUID).toString(); + return componentKey.getValue(qName).toString(); } public static Instant getNotificationInstant(DOMNotification notification) { @@ -98,4 +170,16 @@ public class Onf14DMDOMUtility { } } + private static String extractUuid(String leafValue) { + String uuid; + + Matcher matcher = ALARM_RESOURCE_PATTERN.matcher(leafValue); + if (matcher.matches() && matcher.groupCount() == 1) { + uuid = matcher.group(1); + } else { + uuid = leafValue; + } + return uuid; + } + } diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/AirInterface20.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/AirInterface20.java new file mode 100644 index 000000000..19dab4be9 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/AirInterface20.java @@ -0,0 +1,193 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs; + +import com.google.common.collect.Sets; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces.TechnologySpecificPacKeys; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.pm.PerformanceDataAirInterface; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.qnames.Onf14DevicemanagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Debug; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.XMLNamespace; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AirInterface20 extends YangModule { + + private static final Logger LOG = LoggerFactory.getLogger(AirInterface20.class); + + private static String NAMESPACE = "urn:onf:yang:air-interface-2-0"; + private static final List<QNameModule> MODULES = + Arrays.asList(QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2020-01-21")), + QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2022-07-29"))); + + private final CoreModel14 coreModel14; + + private AirInterface20(NetconfDomAccessor netconfDomAccessor, QNameModule module, CoreModel14 coreModel14) { + super(netconfDomAccessor, module); + this.coreModel14 = coreModel14; + } + + public FaultData readAllCurrentProblems(FaultData resultList, + List<TechnologySpecificPacKeys> airInterfaceList) { + + int idxStart; // Start index for debug messages + + for (TechnologySpecificPacKeys key : airInterfaceList) { + idxStart = resultList.size(); + readAirInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); + Debug.debugResultList(key.getLtpUuid(), resultList, idxStart); + } + return resultList; + } + + /** + * Get specific module for device, depending on capabilities + */ + public static Optional<AirInterface20> getModule(NetconfDomAccessor netconfDomAccessor, CoreModel14 coreModel14) { + + Capabilities capabilities = netconfDomAccessor.getCapabilites(); + for (QNameModule module : MODULES) { + + if (capabilities.isSupportingNamespaceAndRevision(module)) { + return Optional.of(new AirInterface20(netconfDomAccessor, module, coreModel14)); + } + } + return Optional.empty(); + } + + private FaultData readAirInterfaceCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) { + + LOG.debug("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}", + getQNameModule(), netconfDomAccessor.getNodeId().getValue(), ltpUuid, localId); + + // constructing the IID needs the augmentation exposed by the air-interface-2-0 + // model + + YangInstanceIdentifier layerProtocolIID = coreModel14.getLayerProtocolIId(ltpUuid, localId); + + @NonNull + AugmentationIdentifier airInterfacePacIID = + YangInstanceIdentifier.AugmentationIdentifier.create(Sets.newHashSet(getQName("air-interface-pac"))); + + InstanceIdentifierBuilder augmentedAirInterfacePacIID = + YangInstanceIdentifier.builder(layerProtocolIID).node(airInterfacePacIID); + + // reading all the current-problems list for this specific LTP and LP + Optional<NormalizedNode> airInterfacePacDataOpt = + netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedAirInterfacePacIID.build()); + + if (airInterfacePacDataOpt.isPresent()) { + AugmentationNode airInterfacePacData = (AugmentationNode) airInterfacePacDataOpt.get(); + MapNode airInterfaceCurrentProblemsList = + (MapNode) airInterfacePacData.childByArg(new NodeIdentifier(getQName("current-problem-list"))); + if (airInterfaceCurrentProblemsList != null) { + Collection<MapEntryNode> airInterfaceProblemsCollection = airInterfaceCurrentProblemsList.body(); + for (MapEntryNode airInterfaceProblem : airInterfaceProblemsCollection) { + resultList.add(netconfDomAccessor.getNodeId(), + Integer.parseInt( + Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, getQName("sequence-number"))), + new DateAndTime(Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, getQName("timestamp"))), + ltpUuid, Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, getQName("problem-name")), + InternalDataModelSeverity.mapSeverity( + Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, getQName("problem-severity")))); + } + } else { + LOG.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); + } + } + return resultList; + } + + public PerformanceDataLtp readAirInterfaceHistoricalPerformanceData(String ltpUuid, String localId, + PerformanceDataLtp res) { + LOG.debug("Get historical performance data for class {} from mountpoint {} for LTP uuid {} and local-id {}", + Onf14DevicemanagerQNames.AIR_INTERFACE_2_0_MODULE, netconfDomAccessor.getNodeId().getValue(), ltpUuid, + localId); + + // constructing the IID needs the augmentation exposed by the air-interface-2-0 + // model + + YangInstanceIdentifier layerProtocolIID = coreModel14.getLayerProtocolIId(ltpUuid, localId); + + @NonNull + AugmentationIdentifier airInterfacePacIID = YangInstanceIdentifier.AugmentationIdentifier + .create(Sets.newHashSet(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC)); + + InstanceIdentifierBuilder augmentedAirInterfacePacIID = + YangInstanceIdentifier.builder(layerProtocolIID).node(airInterfacePacIID); + + // reading historical performance list for this specific LTP and LP + Optional<NormalizedNode> airInterfacePacDataOpt = + netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedAirInterfacePacIID.build()); + LOG.debug("Performance Data = {}", airInterfacePacDataOpt.get().body()); + if (airInterfacePacDataOpt.isPresent()) { + AugmentationNode airInterfacePacData = (AugmentationNode) airInterfacePacDataOpt.get(); + ContainerNode cn = (ContainerNode) airInterfacePacData + .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC)); + if (cn != null) { + ContainerNode airIntfHistPerf = (ContainerNode) cn + .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_HISTORICAL_PERFORMANCES)); + if (airIntfHistPerf != null) { + MapNode airInterfaceHistoricalPerformanceList = (MapNode) airIntfHistPerf.childByArg( + new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_HISTORICAL_PERFORMANCES_LIST)); + if (airInterfaceHistoricalPerformanceList != null) { + Collection<MapEntryNode> airInterfaceHistoricalPerfCollection = + airInterfaceHistoricalPerformanceList.body(); + for (MapEntryNode airInterfaceHistPerf : airInterfaceHistoricalPerfCollection) { + res.add(new PerformanceDataAirInterface(netconfDomAccessor.getNodeId(), ltpUuid, localId, + airInterfaceHistPerf)); + } + return res; + } else { + LOG.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); + } + } + } + } + return null; + + } +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/Alarms10.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/Alarms10.java new file mode 100644 index 000000000..3f92eb0ca --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/Alarms10.java @@ -0,0 +1,195 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs; + +import com.google.common.collect.Sets; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.mdsal.dom.api.DOMNotificationListener; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.XMLNamespace; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Alarms10 extends YangModule { + + private static final Logger LOG = LoggerFactory.getLogger(Alarms10.class); + + private static final String NAMESPACE = "urn:onf:yang:alarms-1-0"; + private static final List<QNameModule> MODULES = + Arrays.asList(QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2022-03-02")), + QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2022-07-29"))); + + private final QName ALARM_PAC; + private final QName CURRENT_ALARMS; + private final QName CURRENT_ALARM_LIST; + private final QName CURRENT_ALARM_IDENTIFIER; + private final QName ALARM_TYPE_ID; + private final QName ALARM_TYPE_QUALIFIER; + private final QName RESOURCE; + private final QName ALARM_SEVERITY; + private final QName ALARM_TIMESTAMP; + private final QName ALARM_EVENT_SEQUENCE_NUMBER; + private final QName PROBLEM_SEVERITY; + private final QName ALARM_AVC_NOTIFICATION; + private final QName ALARM_EVENT_NOTIFICATION; + + private final CoreModel14 coreModel14; + + private Alarms10(NetconfDomAccessor netconfDomAccessor, QNameModule module, CoreModel14 coreModel14) { + super(netconfDomAccessor, module); + this.coreModel14 = coreModel14; + + ALARM_PAC = QName.create(module, "alarm-pac"); + CURRENT_ALARMS = QName.create(module, "current-alarms"); + CURRENT_ALARM_LIST = QName.create(module, "current-alarm-list"); + CURRENT_ALARM_IDENTIFIER = QName.create(module, "current-alarm-identifier"); + ALARM_TYPE_ID = QName.create(module, "alarm-type-id"); + ALARM_TYPE_QUALIFIER = QName.create(module, "alarm-type-qualifier"); + RESOURCE = QName.create(module, "resource"); + ALARM_SEVERITY = QName.create(module, "alarm-severity"); + ALARM_TIMESTAMP = QName.create(module, "timestamp"); + ALARM_EVENT_SEQUENCE_NUMBER = QName.create(module, "alarm-event-sequence-number"); + PROBLEM_SEVERITY = QName.create(module, "problem-severity"); + ALARM_AVC_NOTIFICATION = QName.create(module, "attribute-value-changed-notification"); + ALARM_EVENT_NOTIFICATION = QName.create(module, "alarm-event-notification"); + } + + public QNameModule getModule() { + return module; + } + + public FaultlogEntity getFaultlogEntity(ContainerNode cn) { + return new FaultlogBuilder().setNodeId(getNodeId().getValue()).setSourceType(SourceType.Netconf) + .setObjectId(Onf14DMDOMUtility.getLeafValueUuid(cn, RESOURCE)) + .setProblem(Onf14DMDOMUtility.getLeafValue(cn, ALARM_TYPE_QUALIFIER)) + .setTimestamp(Onf14DMDOMUtility.getLeafValueDateAndTime(cn, ALARM_TIMESTAMP)) + .setSeverity(Onf14DMDOMUtility.getLeafValueInternalSeverity(cn, PROBLEM_SEVERITY)) + .setCounter(Onf14DMDOMUtility.getLeafValueInt(cn, ALARM_EVENT_SEQUENCE_NUMBER)).build(); + } + + public boolean isAlarmEventNotification(DOMNotification domNotification) { + return domNotification.getType().equals(Absolute.of(ALARM_EVENT_NOTIFICATION)); + } + + public void doRegisterNotificationListener(DOMNotificationListener alarmNotifListener) { + QName[] alarmNotifications = {ALARM_AVC_NOTIFICATION, ALARM_EVENT_NOTIFICATION}; + netconfDomAccessor.doRegisterNotificationListener(alarmNotifListener, alarmNotifications); + } + + public void sendNotification(@NonNull WebsocketManagerService websocketService, DOMNotification domNotification, + ContainerNode cn) { + websocketService.sendNotification(domNotification, getNodeId(), ALARM_TYPE_QUALIFIER, + Onf14DMDOMUtility.getLeafValueDateAndTime(cn, ALARM_TIMESTAMP)); + } + + public FaultData getCurrentAlarms() { + + YangInstanceIdentifier alarmsPacIID = + YangInstanceIdentifier.builder().node(coreModel14.getControlConstructQName()).build(); + + @NonNull + AugmentationIdentifier alarmsContainerIID = + YangInstanceIdentifier.AugmentationIdentifier.create(Sets.newHashSet(ALARM_PAC)); + + InstanceIdentifierBuilder augmentedAlarmsIID = + YangInstanceIdentifier.builder(alarmsPacIID).node(alarmsContainerIID); + + // reading all the alarms + Optional<NormalizedNode> alarms = + this.getNetconfDomAccessor().readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedAlarmsIID.build()); + + FaultData resultList = new FaultData(); + if (alarms.isPresent()) { + AugmentationNode alarmsDataNode = (AugmentationNode) alarms.get(); + ContainerNode alarmsContainer = (ContainerNode) alarmsDataNode.childByArg(new NodeIdentifier(ALARM_PAC)); + ContainerNode currentAlarmsContainer = + (ContainerNode) alarmsContainer.childByArg(new NodeIdentifier(CURRENT_ALARMS)); + MapNode currentAlarmsList = + (MapNode) currentAlarmsContainer.childByArg(new NodeIdentifier(CURRENT_ALARM_LIST)); + if (currentAlarmsList != null) { + Collection<MapEntryNode> currentAlarmsCollection = currentAlarmsList.body(); + for (MapEntryNode currentAlarm : currentAlarmsCollection) { + resultList.add(getNodeId(), + Onf14DMDOMUtility.getLeafValueInt(currentAlarm, CURRENT_ALARM_IDENTIFIER), + Onf14DMDOMUtility.getLeafValueDateAndTime(currentAlarm, ALARM_TIMESTAMP), + Onf14DMDOMUtility.getLeafValueUuid(currentAlarm, RESOURCE), + Onf14DMDOMUtility.getLeafValue(currentAlarm, ALARM_TYPE_QUALIFIER), + Onf14DMDOMUtility.getLeafValueInternalSeverity(currentAlarm, ALARM_SEVERITY)); + } + } else { + LOG.debug("DBRead empty CurrentProblemList"); + } + } + return resultList; + } + + public boolean isSupported(Capabilities capabilites) { + return netconfDomAccessor.getCapabilites().isSupportingNamespace(NAMESPACE); + } + + private NodeId getNodeId() { + return netconfDomAccessor.getNodeId(); + } + + /** + * Get specific instance, depending on capabilities + * + * @param capabilities + * @return + */ + public static Optional<Alarms10> getModule(NetconfDomAccessor netconfDomAccessor, CoreModel14 coreModel14) { + Capabilities capabilities = netconfDomAccessor.getCapabilites(); + for (QNameModule module : MODULES) { + if (capabilities.isSupportingNamespaceAndRevision(module)) { + return Optional.of(new Alarms10(netconfDomAccessor, module, coreModel14)); + } + } + return Optional.empty(); + } +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/CoreModel14.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/CoreModel14.java new file mode 100644 index 000000000..5a2b5772b --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/CoreModel14.java @@ -0,0 +1,190 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2022 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces.Onf14Interfaces; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces.TechnologySpecificPacKeys; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.XMLNamespace; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CoreModel14 extends YangModule { + + private static final Logger LOG = LoggerFactory.getLogger(CoreModel14.class); + + private static final String NAMESPACE = "urn:onf:yang:core-model-1-4"; + private static final List<QNameModule> MODULES = + Arrays.asList(QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2019-11-27"))); + + private final QName CONTROL_CONSTRUCT; + private final QName TOP_LEVEL_EQUIPMENT; + + private CoreModel14(NetconfDomAccessor netconfDomAccessor, QNameModule module) { + super(netconfDomAccessor, module); + + CONTROL_CONSTRUCT = QName.create(module, "control-construct"); + TOP_LEVEL_EQUIPMENT = QName.create(module, "top-level-equipment"); + } + + public String getRevision() { + return module.getRevision().get().toString(); + } + + @Override + public QName getQName(String localName) { + return QName.create(module, localName); + } + + public QName getControlConstructQName() { + return CONTROL_CONSTRUCT; + } + + public YangInstanceIdentifier getTopLevelEquipment_IId() { + return YangInstanceIdentifier.builder().node(getControlConstructQName()).node(TOP_LEVEL_EQUIPMENT).build(); + } + + private YangInstanceIdentifier getLtp_IID() { + return YangInstanceIdentifier.builder().node(getQName("control-construct")) + .node(getQName("logical-termination-point")).build(); + } + + public YangInstanceIdentifier getLayerProtocolIId(String ltpUuid, String localId) { + return YangInstanceIdentifier.builder().node(getQName("control-construct")) + .node(getQName("logical-termination-point")) + .nodeWithKey(getQName("logical-termination-point"), + QName.create(getQName("logical-termination-point"), "uuid").intern(), ltpUuid) + .node(getQName("layer-protocol")).nodeWithKey(getQName("layer-protocol"), + QName.create(getQName("layer-protocol"), "local-id").intern(), localId) + .build(); + } + + public Optional<NormalizedNode> readLtpData(NetconfDomAccessor netconfDomAccessor) { + LOG.info("Reading Logical Termination Point data"); + return netconfDomAccessor.readDataNode(LogicalDatastoreType.CONFIGURATION, getLtp_IID()); + } + + /** + * Get the LP list, which should contain only 1 entry. the Layer Protocol list should contain only one item, since + * we have an 1:1 relationship between the LTP and the LP + * + * @param ltp + * @return + */ + private Collection<MapEntryNode> getInterfaceKeyList(DataContainerNode ltp) { + MapNode lpList = (MapNode) ltp.childByArg(new NodeIdentifier(getQName("layer-protocol"))); + // the Layer Protocol list should contain only one item, since we have an 1:1 + // relationship between the LTP and the LP + if (lpList != null && lpList.size() != 1) { + LOG.debug("Layer protocol has no 1:1 relationship with the LTP."); + return Collections.emptyList(); + } + // accessing the LP, which should be only 1 + return lpList.body(); + } + + /** + * Search through the LayerProtocol list for specific layerProtocolNamesValues + * @param ltp + * @param lp + * @param layerProtocolNameValue + * @return + */ + private List<TechnologySpecificPacKeys> getTechnologySpecificPackKeys(DataContainerNode ltp, Collection<MapEntryNode> lp, + String layerProtocolNameValue) { + List<TechnologySpecificPacKeys> interfaceList = new ArrayList<>(); + for (MapEntryNode lpEntry : lp) { + String layerProtocolName = Onf14DMDOMUtility.getLeafValue(lpEntry, getQName("layer-protocol-name")); + if (layerProtocolName != null && layerProtocolName.contains(layerProtocolNameValue)) { + TechnologySpecificPacKeys interfaceKey = + new TechnologySpecificPacKeys(Onf14DMDOMUtility.getLeafValue(ltp, getQName("uuid")), + Onf14DMDOMUtility.getLeafValue(lpEntry, getQName("local-id"))); + interfaceList.add(interfaceKey); + LOG.debug("Adding Ltp with uuid {} and local-id {} to the {} list", interfaceKey.getLtpUuid(), + interfaceKey.getLocalId(), layerProtocolNameValue); + } + } + return interfaceList; + } + + public Onf14Interfaces readKeys(Onf14Interfaces interfaces) { + + Optional<NormalizedNode> ltpData = readLtpData(netconfDomAccessor); + LOG.debug("LTP Data is - {}", ltpData); + if (ltpData.isPresent()) { + LOG.debug("In readKeys - ltpData = {}", ltpData.get()); + + MapNode ccLtp = (MapNode) ltpData.get(); + if (ccLtp != null) { + LOG.debug("Iterating the LTP list for node {}", netconfDomAccessor.getNodeId().getValue()); + Collection<MapEntryNode> ltpList = ccLtp.body(); + + // iterating all the Logical Termination Point list + for (MapEntryNode ltp : ltpList) { + Collection<MapEntryNode> lp = getInterfaceKeyList(ltp); + + interfaces.add(Onf14Interfaces.Key.AIRINTERFACE, + getTechnologySpecificPackKeys(ltp, lp, "LAYER_PROTOCOL_NAME_TYPE_AIR_LAYER")); + interfaces.add(Onf14Interfaces.Key.ETHERNETCONTAINER, + getTechnologySpecificPackKeys(ltp, lp, "LAYER_PROTOCOL_NAME_TYPE_ETHERNET_CONTAINER_LAYER")); + interfaces.add(Onf14Interfaces.Key.WIREINTERFACE, + getTechnologySpecificPackKeys(ltp, lp, "LAYER_PROTOCOL_NAME_TYPE_WIRE_LAYER")); + } + } + } + return interfaces; + } + + /** + * Get specific module for device, depending on capabilities + */ + public static Optional<CoreModel14> getModule(NetconfDomAccessor netconfDomAccessor) { + + Capabilities capabilities = netconfDomAccessor.getCapabilites(); + for (QNameModule module : MODULES) { + + if (capabilities.isSupportingNamespaceAndRevision(module)) { + return Optional.of(new CoreModel14(netconfDomAccessor, module)); + } + } + return Optional.empty(); + } + +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/EthernetContainer20.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/EthernetContainer20.java new file mode 100644 index 000000000..81aec9dd0 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/EthernetContainer20.java @@ -0,0 +1,145 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs; + +import com.google.common.collect.Sets; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces.TechnologySpecificPacKeys; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Debug; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.XMLNamespace; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EthernetContainer20 extends YangModule { + + private static final Logger LOG = LoggerFactory.getLogger(EthernetContainer20.class); + + private static String NAMESPACE = "urn:onf:yang:ethernet-container-2-0"; + private static final List<QNameModule> MODULES = + Arrays.asList(QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2020-01-21"))); + + private final CoreModel14 coreModel14; + + public EthernetContainer20(NetconfDomAccessor netconfDomAccessor, QNameModule module, CoreModel14 coreModel14) { + super(netconfDomAccessor, module); + this.coreModel14 = coreModel14; + } + + private FaultData readEthernetContainerCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) { + + LOG.debug( + "DBRead Get current problems for Ethernet Container from mountpoint {} for LTP uuid {} and local-id {}", + netconfDomAccessor.getNodeId().getValue(), ltpUuid, localId); + + // constructing the IID needs the augmentation exposed by the + // ethernet-container-2-0 model + YangInstanceIdentifier layerProtocolIID = coreModel14.getLayerProtocolIId(ltpUuid, localId); + + @NonNull + AugmentationIdentifier ethernetContainerIID = YangInstanceIdentifier.AugmentationIdentifier + .create(Sets.newHashSet(getQName("ethernet-container-pac"))); + + InstanceIdentifierBuilder augmentedEthernetContainerConfigurationIID = + YangInstanceIdentifier.builder(layerProtocolIID).node(ethernetContainerIID); + + // reading all the current-problems list for this specific LTP and LP + Optional<NormalizedNode> etherntContainerConfigurationOpt = netconfDomAccessor + .readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedEthernetContainerConfigurationIID.build()); + + if (etherntContainerConfigurationOpt.isPresent()) { + AugmentationNode etherntContainerConfiguration = (AugmentationNode) etherntContainerConfigurationOpt.get(); + MapNode ethernetContainerCurrentProblemsList = (MapNode) etherntContainerConfiguration + .childByArg(new NodeIdentifier(getQName("current-problem-list"))); + if (ethernetContainerCurrentProblemsList != null) { + Collection<MapEntryNode> ethernetContainerProblemsCollection = + ethernetContainerCurrentProblemsList.body(); + for (MapEntryNode ethernetContainerProblem : ethernetContainerProblemsCollection) { + resultList.add(netconfDomAccessor.getNodeId(), + Integer.parseInt(Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem, + getQName("sequence-number"))), + new DateAndTime( + Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem, getQName("timestamp"))), + ltpUuid, Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem, getQName("problem-name")), + InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility + .getLeafValue(ethernetContainerProblem, getQName("problem-severity")))); + } + } else { + LOG.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); + } + } + return resultList; + } + + public FaultData readAllCurrentProblems(FaultData resultList, + List<TechnologySpecificPacKeys> ethernetContainerList) { + + int idxStart; // Start index for debug messages + + for (TechnologySpecificPacKeys key : ethernetContainerList) { + idxStart = resultList.size(); + + resultList = readEthernetContainerCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); + Debug.debugResultList(key.getLtpUuid(), resultList, idxStart); + } + return resultList; + } + + + + /** + * Get specific module for device, depending on capabilities + */ + public static Optional<EthernetContainer20> getModule(NetconfDomAccessor netconfDomAccessor, + CoreModel14 coreModel14) { + + Capabilities capabilities = netconfDomAccessor.getCapabilites(); + for (QNameModule module : MODULES) { + + if (capabilities.isSupportingNamespaceAndRevision(module)) { + return Optional.of(new EthernetContainer20(netconfDomAccessor, module, coreModel14)); + } + } + return Optional.empty(); + } + +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/WireInterface20.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/WireInterface20.java new file mode 100644 index 000000000..c97449d69 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/WireInterface20.java @@ -0,0 +1,142 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs; + +import com.google.common.collect.Sets; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces.TechnologySpecificPacKeys; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.qnames.Onf14DevicemanagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Debug; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.XMLNamespace; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class WireInterface20 extends YangModule { + + private static final Logger LOG = LoggerFactory.getLogger(WireInterface20.class); + + private static String NAMESPACE = "urn:onf:yang:wire-interface-2-0"; + private static final List<QNameModule> MODULES = + Arrays.asList(QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2020-01-23"))); + + private final CoreModel14 coreModel14; + + private WireInterface20(NetconfDomAccessor netconfDomAccessor, QNameModule module, CoreModel14 coreModel14) { + super(netconfDomAccessor, module); + this.coreModel14 = coreModel14; + } + + private FaultData readWireInterfaceCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) { + + LOG.debug("DBRead Get current problems for Wire Interface from mountpoint {} for LTP uuid {} and local-id {}", + netconfDomAccessor.getNodeId().getValue(), ltpUuid, localId); + + // constructing the IID needs the augmentation exposed by the wire-interface-2-0 + // model + YangInstanceIdentifier layerProtocolIID = coreModel14.getLayerProtocolIId(ltpUuid, localId); + + @NonNull + AugmentationIdentifier wireInterfacePacIID = YangInstanceIdentifier.AugmentationIdentifier + .create(Sets.newHashSet(Onf14DevicemanagerQNames.WIRE_INTERFACE_PAC)); + + InstanceIdentifierBuilder augmentedWireInterfaceConfigurationIID = + YangInstanceIdentifier.builder(layerProtocolIID).node(wireInterfacePacIID); + + // reading all the current-problems list for this specific LTP and LP + Optional<NormalizedNode> wireInterfaceConfigurationOpt = netconfDomAccessor + .readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedWireInterfaceConfigurationIID.build()); + + if (wireInterfaceConfigurationOpt.isPresent()) { + AugmentationNode wireInterfaceConfiguration = (AugmentationNode) wireInterfaceConfigurationOpt.get(); + MapNode wireInterfaceCurrentProblemsList = (MapNode) wireInterfaceConfiguration + .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_LIST)); + if (wireInterfaceCurrentProblemsList != null) { + Collection<MapEntryNode> wireInterfaceProblemsCollection = wireInterfaceCurrentProblemsList.body(); + for (MapEntryNode wireInterfaceProblem : wireInterfaceProblemsCollection) { + resultList.add(netconfDomAccessor.getNodeId(), + Integer.parseInt(Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem, + Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_SEQ_NO)), + new DateAndTime(Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem, + Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_TIMESTAMP)), + ltpUuid, + Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem, + Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_PROBLEM_NAME), + InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem, + Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_PROBLEM_SEVERITY))); + } + } else { + LOG.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); + } + } + return resultList; + } + + public FaultData readAllCurrentProblems(FaultData resultList, + List<TechnologySpecificPacKeys> wireInterfaceList) { + + int idxStart; // Start index for debug messages + + for (TechnologySpecificPacKeys key : wireInterfaceList) { + idxStart = resultList.size(); + + resultList = readWireInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); + Debug.debugResultList(key.getLtpUuid(), resultList, idxStart); + } + return resultList; + } + + /** + * Get specific module for device, depending on capabilities + */ + public static Optional<WireInterface20> getModule(NetconfDomAccessor netconfDomAccessor, CoreModel14 coreModel14) { + + Capabilities capabilities = netconfDomAccessor.getCapabilites(); + for (QNameModule module : MODULES) { + + if (capabilities.isSupportingNamespaceAndRevision(module)) { + return Optional.of(new WireInterface20(netconfDomAccessor, module, coreModel14)); + } + } + return Optional.empty(); + } +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/YangModule.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/YangModule.java new file mode 100644 index 000000000..915f2fa95 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/yangspecs/YangModule.java @@ -0,0 +1,51 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.yangspecs; + +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; + +public class YangModule { + + protected final NetconfDomAccessor netconfDomAccessor; + protected final QNameModule module; + + YangModule(NetconfDomAccessor netconfDomAccessor, QNameModule module) { + super(); + this.netconfDomAccessor = netconfDomAccessor; + this.module = module; + } + + NetconfDomAccessor getNetconfDomAccessor() { + return netconfDomAccessor; + } + + public QNameModule getQNameModule() { + return module; + } + + public QName getQName(String localName) { + return QName.create(module, localName); + } + +} |