diff options
author | herbert <herbert.eiselt@highstreet-technologies.com> | 2020-01-30 12:08:35 +0100 |
---|---|---|
committer | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2020-02-01 12:42:06 +0000 |
commit | 149a57edf72762c7e0eb4062851c06356e6a75ab (patch) | |
tree | 0f6bf0087a2a82c637bb249ab09561f58202b969 /sdnr/wt/devicemanager-onf/provider/src/main/java | |
parent | 8fb01420d6e5b5c3284da57292e28ce40874aaf4 (diff) |
SDN-R add updated devicemanager
add updated devicemanager and specific devicemanagers
Issue-ID: SDNC-1039
Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com>
Change-Id: I16f4c8d78da95ab12dbb50e50dfb561a85e8d6a2
Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager-onf/provider/src/main/java')
31 files changed, 5468 insertions, 0 deletions
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/NetworkElementCoreData.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/NetworkElementCoreData.java new file mode 100644 index 000000000..ddfeac227 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/NetworkElementCoreData.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf; + +import java.util.Optional; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType; + +public interface NetworkElementCoreData { + + public String getMountpoint(); + public DataBroker getDataBroker(); + public Optional<NetworkElement> getOptionalNetworkElement(); + public NetworkElementDeviceType getDeviceType(); + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ONFCoreNetworkElementCallback.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ONFCoreNetworkElementCallback.java new file mode 100644 index 000000000..55765d7c3 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ONFCoreNetworkElementCallback.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf; + +public interface ONFCoreNetworkElementCallback<T> { + + public void notificationFromNeListener(T notificationXml); + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ONFCoreNetworkElementRepresentation.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ONFCoreNetworkElementRepresentation.java new file mode 100644 index 000000000..163c4a4f1 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ONFCoreNetworkElementRepresentation.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf; + +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.DeviceMonitoredNe; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.InventoryProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.PerformanceDataProvider; +import org.opendaylight.mdsal.binding.api.MountPoint; + +public interface ONFCoreNetworkElementRepresentation + extends DeviceMonitoredNe, PerformanceDataProvider, NetworkElementCoreData, InventoryProvider, NetworkElement { + + /** + * Read during startup all relevant structure and status parameters from device. + * Remove all currentAlarms, read structure from networkElement with all + * interfacePacs, read current alarm status + */ + public void initialReadFromNetworkElement(); + + public String getMountPointNodeName(); + + public int removeAllCurrentProblemsOfNode(); + + public void doRegisterEventListener(MountPoint mountPoint); +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/OnfInterfacePac.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/OnfInterfacePac.java new file mode 100644 index 000000000..65b06a037 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/OnfInterfacePac.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac; + +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; + +public interface OnfInterfacePac { + + /** + * Read problems of specific interfaces. TODO Goal for future implementation + * without usage of explicit new. Key is generated by newInstance() function + * here to verify this approach. + * + * @param interfacePacUuid Universal index of Interfacepac + * @param resultList List to add fault. If null new list is created. + * @return list of alarms + */ + public FaultData readTheFaults(@NonNull UniversalId interfacePacUuid, @NonNull FaultData resultList); + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/WrapperPTPModelRev170208.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/WrapperPTPModelRev170208.java new file mode 100644 index 000000000..7df39c747 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/WrapperPTPModelRev170208.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac; + +import java.util.List; +import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentity; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Reading PTP specific information from networkelement and creating log-trace output. + * + * @author herbert + */ +public class WrapperPTPModelRev170208 { + + private static final Logger LOG = LoggerFactory.getLogger(WrapperPTPModelRev170208.class); + + protected static final InstanceIdentifier<InstanceList> PTPINSTANCES_IID = InstanceIdentifier + .builder(InstanceList.class, new InstanceListKey(1)).build(); + + /** + * Query synchronization information out of NE + */ + + public static void initSynchronizationExtension(NetconfAccessor acessor) { + + String mountPointNodeName = acessor.getNodeId().getValue(); + Capabilities capabilities = acessor.getCapabilites(); + try { + if (!capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)) { + LOG.debug("Mountpoint {} does not support PTP", mountPointNodeName); + } else { + StringBuffer sb = new StringBuffer(); + sb.append("NE "); + sb.append(mountPointNodeName); + sb.append(" does support synchronisation.\n"); + InstanceList ptpInstance = readPTPClockInstances(acessor); + if (ptpInstance != null) { + List<PortDsList> dsList = ptpInstance.getPortDsList(); + if (dsList != null) { + int t = 0; + for (PortDsList portDs : dsList) { + PortIdentity portId = portDs.getPortIdentity(); + if (portId != null) { + sb.append("Port["); + sb.append(portId.getPortNumber()); + sb.append("]{ ClockId: "); + sb.append(portId.getClockIdentity()); + sb.append(", Portstate: "); + sb.append(portDs.getPortState()); + sb.append("}, "); + } else { + sb.append("Incomplete port #" + t + ", "); + } + t++; + } + } else { + sb.append("dsList contains null"); + } + } else { + sb.append("ptpInstance equals null"); + } + LOG.trace(sb.toString()); + } + } catch (Exception e) { + LOG.info("Inconsistent synchronisation structure: " + e.getMessage()); + } + } + + @Nullable + private static InstanceList readPTPClockInstances(NetconfAccessor acessor) { + return acessor.getTransactionUtils().readData(acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + PTPINSTANCES_IID); + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java new file mode 100644 index 000000000..18e3c0b10 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.equipment; + +import java.util.ArrayList; +import java.util.List; + +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.Equipment; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ContainedHolder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ManufacturedThing; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentInstance; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.ManufacturerProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.InventoryBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Extend the eqipment type of core model with additional parameters + */ +public class ExtendedEquipment { + + private static final Logger LOG = LoggerFactory.getLogger(ExtendedEquipment.class); + + public static final String ESDATATYPENAME = "inventoryequipment"; + private final String parentUuid; + private final int treeLevel; + private final Equipment equipment; + private final String nodeId; + private final String path; + /** + * Equipment with additional information beside NETCONF equipment + * + * @param parentUuid of parent equipment + * @param equipment NETCONF Equipment + * @param treeLevel level of tree starting with root at 0 + */ + public ExtendedEquipment(String nodeId, String parentUuid, Equipment equipment, String path, int treeLevel) { + super(); + this.nodeId = nodeId; + this.parentUuid = parentUuid; + this.equipment = equipment; + this.path = path; + this.treeLevel = treeLevel; + } + + public String getParentUuid() { + return parentUuid; + } + + public Equipment getEquipment() { + return equipment; + } + + public int getTreeLevel() { + return treeLevel; + } + public String getNodeId() { + return nodeId; + } + + public Inventory getCreateInventoryInput() { + + InventoryBuilder inventoryBuilder = new InventoryBuilder(); + + // General + inventoryBuilder.setNodeId(getNodeId()); + inventoryBuilder.setParentUuid(getParentUuid()); + inventoryBuilder.setTreeLevel(new Long(getTreeLevel())); + + if (equipment != null) { + inventoryBuilder.setUuid(equipment.getUuid().getValue()); + // -- String list with ids of holders + List<String> containerHolderKeyList = new ArrayList<>(); + List<ContainedHolder> containerHolderList = equipment.getContainedHolder(); + if (containerHolderList != null) { + for (ContainedHolder containerHolder : containerHolderList) { + containerHolderKeyList.add(containerHolder.getUuid().getValue()); + } + } + inventoryBuilder.setContainedHolder(containerHolderKeyList); + + // -- Manufacturer related things + ManufacturedThing mThing = equipment.getManufacturedThing(); + if (mThing != null) { + ManufacturerProperties mProperties = mThing.getManufacturerProperties(); + if (mProperties != null) { + inventoryBuilder.setManufacturerName(mProperties.getManufacturerName()); + inventoryBuilder.setManufacturerIdentifier(mProperties.getManufacturerIdentifier()); + } + EquipmentType mType = mThing.getEquipmentType(); + if (mType != null) { + inventoryBuilder.setDescription(mType.getDescription()); + inventoryBuilder.setModelIdentifier(mType.getModelIdentifier()); + inventoryBuilder.setPartTypeId(mType.getPartTypeIdentifier()); + inventoryBuilder.setTypeName(mType.getTypeName()); + inventoryBuilder.setVersion(mType.getVersion()); + } + EquipmentInstance mInstance = mThing.getEquipmentInstance(); + if (mInstance != null) { + String manufacturedDateString = mInstance.getManufactureDate(); + if (manufacturedDateString != null && !manufacturedDateString.isEmpty()) { + try { + inventoryBuilder.setDate(mInstance.getManufactureDate()); + } catch (IllegalArgumentException e) { + LOG.debug("Format problem", e); + } + } + inventoryBuilder.setSerial(mInstance.getSerialNumber()); + } + } + } + + return inventoryBuilder.build(); + } + + @Override + public String toString() { + return "ExtendedEquipment [parentUuid=" + parentUuid + ", treeLevel=" + treeLevel + ", equipment=" + equipment + + ", nodeId=" + nodeId + ", path=" + path + "]"; + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ONFCoreNetworkElement12Equipment.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ONFCoreNetworkElement12Equipment.java new file mode 100644 index 000000000..b2d4404c8 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ONFCoreNetworkElement12Equipment.java @@ -0,0 +1,304 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.equipment; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.NetworkElementCoreData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.OnfInterfacePac; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.EquipmentData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationDcae; +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.TransactionUtils; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.Equipment; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.EquipmentKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ContainedHolder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ManufacturedThing; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.ManufacturerProperties; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Contains equipment related information of ONFCore Network Element + */ +public class ONFCoreNetworkElement12Equipment { + + private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Equipment.class); + + private static final UniversalId EQUIPMENTROOT = new UniversalId("network-element"); + private static final int EQUIPMENTROOTLEVEL = 0; + + private final NetworkElementCoreData coreData; + private final OnfInterfacePac equipmentPac; + private final NetconfAccessor acessor; + + private final ValueNameList extensionList; + private final List<UniversalId> topLevelEqUuidList; + private final @NonNull FaultData globalProblemList; + private final @NonNull List<ExtendedEquipment> globalEquipmentList; + + public ONFCoreNetworkElement12Equipment(NetconfAccessor acessor, NetworkElementCoreData coreData, Capabilities capabilities) { + LOG.debug("Initialize " + ONFCoreNetworkElement12Equipment.class.getName()); + this.acessor = acessor; + this.coreData = coreData; + if (capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)) { + this.equipmentPac = new WrapperEquipmentPacRev170402(acessor, coreData); + LOG.debug("Equipement pac supported {}", WrapperEquipmentPacRev170402.QNAME); + } else { + this.equipmentPac = null; + LOG.debug("Equipement pac not supported {}", WrapperEquipmentPacRev170402.QNAME); + } + + extensionList = new ValueNameList(); + topLevelEqUuidList = new ArrayList<>(); + globalEquipmentList = new ArrayList<>(); + globalProblemList = new FaultData(); + + initClassVars(); + } + + public void addProblemsofNode(FaultData resultList) { + resultList.addAll(globalProblemList); + } + + public FaultData addProblemsofNodeObject(String uuidString) { + FaultData res = new FaultData(); + + if (this.equipmentPac != null) { + this.equipmentPac.readTheFaults(new UniversalId(uuidString), res); + } + return res; + } + + public @NonNull InventoryInformationDcae getInventoryInformation(List<String> uuids) { + return getInventoryInformationDcae(this.extensionList, uuids); + } + + public void readNetworkElementEquipment() { + doSyncNetworkElementEquipmentToClassVars(); + } + + public String getMountpoint() { + return coreData.getMountpoint(); + } + + public OnfInterfacePac getEquipmentPac() { + return equipmentPac; + } + + public List<UniversalId> getTopLevelEqUuidList() { + return topLevelEqUuidList; + } + + public @NonNull EquipmentData getEquipmentData() { + EquipmentData res = new EquipmentData(); + globalEquipmentList.forEach(extEquipment -> res.add(extEquipment.getCreateInventoryInput())); + return res; + } + + public List<Equipment> getEquipmentAll() { + List<Equipment> equipmentListAll = new ArrayList<>(); + + Equipment equipment = readEquipmentAll(); + equipmentListAll.add(equipment); + + return equipmentListAll; + } + + TransactionUtils getGenericTransactionUtils() { + return acessor.getTransactionUtils(); + } + + /* + * --------------------------------------------------------------------------------- private + * functions + */ + + private void initClassVars() { + this.globalProblemList.clear(); + this.extensionList.clear(); + this.topLevelEqUuidList.clear(); + } + + private void doSyncNetworkElementEquipmentToClassVars() { + + Optional<NetworkElement> optionalNe = coreData.getOptionalNetworkElement(); + initClassVars(); + + if (optionalNe.isPresent()) { + + // extract Inventory + extensionList.put(optionalNe.get().getExtension()); + + if (!extensionList.isEmpty()) { + + /* + * Loop through network element extension to get "top-level-equipment" <extension> + * <value-name>top-level-equipment</value-name> <value>1.0.BKP,1.0.WCS</value> </extension> "ipv4" + * address + */ + extensionList.getAsUniversalIdList("top-level-equipment", topLevelEqUuidList); + + // If top-level-equipment exists get further information + if (topLevelEqUuidList.isEmpty()) { + LOG.debug("no top level equipment found"); + } else { + // Read equipment and problems + for (UniversalId uuid : topLevelEqUuidList) { + recurseReadEquipmentProblems(uuid, EQUIPMENTROOT, coreData.getMountpoint(), EQUIPMENTROOTLEVEL, + globalProblemList, globalEquipmentList); + } + } + } else { + LOG.debug("extension list is null"); + } + } + } + + private void recurseReadEquipmentProblems(UniversalId uuid, UniversalId parentUuid, String path, int treeLevel, + @NonNull FaultData problemList, @NonNull List<ExtendedEquipment> equipmentList) { + + if (uuid != null) { + + Equipment equipment = this.readEquipment(uuid); + + if (equipment != null) { + equipmentList.add(new ExtendedEquipment(this.getMountpoint(),parentUuid.getValue(), equipment, path, treeLevel)); + + if (this.equipmentPac != null) { + this.equipmentPac.readTheFaults(uuid, problemList); + + List<ContainedHolder> containedHolderListe = equipment.getContainedHolder(); + if (containedHolderListe != null) { + for (ContainedHolder containedHolder : containedHolderListe) { + recurseReadEquipmentProblems(containedHolder.getOccupyingFru(), uuid, path+"/"+uuid.getValue(), treeLevel + 1, + problemList, equipmentList); + } + } + } + } + } + } + + private @NonNull InventoryInformationDcae getInventoryInformationDcae(ValueNameList extensions, List<String> uuids) { + + InventoryInformationDcae inventoryInformation = new InventoryInformationDcae(); + + // uuids + inventoryInformation.setInterfaceUuidList(uuids); + + if (!extensions.isEmpty()) { + + inventoryInformation.setDeviceIpv4(extensions.getOrNull("neIpAddress")); + + // If top-level-equipment exists get further information + if (topLevelEqUuidList.isEmpty()) { + LOG.debug("no top level equipment found"); + } else { + if (!globalEquipmentList.isEmpty()) { + Equipment e = globalEquipmentList.get(0).getEquipment(); + if (e != null) { + ManufacturedThing manufacturedThing = e.getManufacturedThing(); + if (manufacturedThing != null) { + EquipmentType et; + if ((et = manufacturedThing.getEquipmentType()) != null) { + inventoryInformation.setType(et.getTypeName()); + inventoryInformation.setModel(et.getModelIdentifier()); + } + ManufacturerProperties em; + if ((em = manufacturedThing.getManufacturerProperties()) != null) { + inventoryInformation.setVendor(em.getManufacturerIdentifier()); + } + } + } + } + } + } else { + LOG.debug("extension list is null"); + } + + LOG.debug("Inventory: {}", inventoryInformation); + return inventoryInformation; + + } + + + /** + * Read equipment information + * + * @param interfacePacUuid uuid as key for Equipment. + * @return Equipment or null + */ + private @Nullable Equipment readEquipment(UniversalId interfacePacUuid) { + + final Class<?> clazzPac = Equipment.class; + + LOG.info("DBRead Get equipment for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + coreData.getMountpoint(), interfacePacUuid.getValue()); + + InstanceIdentifier<Equipment> equipmentIID = + InstanceIdentifier.builder(Equipment.class, new EquipmentKey(interfacePacUuid)).build(); + + Equipment res = getGenericTransactionUtils().readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + equipmentIID); + + return res; + } + + /** + * Read equipment information + * + * @param interfacePacUuid uuid as key for Equipment. + * @return Equipment or null + */ + private @Nullable Equipment readEquipmentAll() { + + final Class<?> clazzPac = Equipment.class; + + LOG.info("DBRead Get all equipment for class {} from mountpoint {}", clazzPac.getSimpleName(), + coreData.getMountpoint()); + + InstanceIdentifier<Equipment> equipmentIID = InstanceIdentifier.builder(Equipment.class).build(); + + Equipment res = getGenericTransactionUtils().readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + equipmentIID); + + return res; + } + + /** + * specific toString() + */ + @Override + public String toString() { + return "ONFCoreNetworkElement12Equipment [coreData=" + coreData + ", equipmentPac=" + equipmentPac + + ", extensions=" + extensionList + ", topLevelEqUuidList=" + topLevelEqUuidList + ", problemList=" + + globalProblemList + ", equipmentList=" + globalEquipmentList + "]"; + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ValueNameList.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ValueNameList.java new file mode 100644 index 000000000..a3361a0fe --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ValueNameList.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.equipment; + +import java.util.HashMap; +import java.util.List; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension; + +/** + * ValueNameList is an access Wrapper to NETCONF Extension lists + * Class is a specialized HashMap. + */ +public class ValueNameList extends HashMap<String, String> { + + private static final long serialVersionUID = 1L; + + /** + * Create ValueNameList for NETCONF extensions + * @param extensionList Parameters as received from device. Could be null. + */ + public void put(@Nullable List<Extension> extensionList) { + + if (extensionList != null) { + String name; + String value; + + for (Extension e : extensionList) { + name = e.getValueName(); + value = e.getValue(); + if (name != null && value != null) { + put(name, value); + } + } + } + } + + /** + * Return value or null + * @param name key for element + * @return value if key exists; if not nul + */ + public String getOrNull(String name) { + return containsKey(name) ? get(name) : null; + } + + /** + * Get element as id list + * @param name key of element + * @param topLevelEqUuidList as input to add elements + * @return List<UniversalId> + */ + public @NonNull List<UniversalId> getAsUniversalIdList(String name, List<UniversalId> topLevelEqUuidList) { + if (containsKey(name)) { + String[] result = get(name).split(",\\s*"); + if (result.length > 0) { + for (String e : result) { + topLevelEqUuidList.add(new UniversalId(e)); + } + } + } + return topLevelEqUuidList; + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/WrapperEquipmentPacRev170402.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/WrapperEquipmentPacRev170402.java new file mode 100644 index 000000000..6da673766 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/WrapperEquipmentPacRev170402.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.equipment; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.NetworkElementCoreData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.OnfInterfacePac; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev181010; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.CurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.EquipmentPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.EquipmentPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.equipment.pac.EquipmentCurrentProblems; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.QName; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class WrapperEquipmentPacRev170402 implements OnfInterfacePac { + + private static final Logger LOG = LoggerFactory.getLogger(WrapperEquipmentPacRev170402.class); + public static final QName QNAME = EquipmentPac.QNAME; + + private final NetconfAccessor acessor; + + + public WrapperEquipmentPacRev170402(NetconfAccessor acessor, NetworkElementCoreData coreData) { + this.acessor = acessor; + } + + private TransactionUtils getGenericTransactionUtils() { + return acessor.getTransactionUtils(); + } + + /** + * Read problems of specific interfaces. TODO Goal for future implementation without usage of + * explicit new. Key is generated by newInstance() function here to verify this approach. + * + * @param interfacePacUuid Universal index of onf interface-pac + * @param resultList list to add, or null for new list. + * @return list of alarms + */ + @Override + public @NonNull FaultData readTheFaults(@NonNull UniversalId interfacePacUuid, @NonNull FaultData resultList) { + + final Class<EquipmentPac> clazzPac = EquipmentPac.class; + final Class<EquipmentPacKey> clazzPacKey = EquipmentPacKey.class; + final Class<EquipmentCurrentProblems> clazzProblems = EquipmentCurrentProblems.class; + // final Class<ContainerCurrentProblemTypeG> clazzProblem = + // ContainerCurrentProblemTypeG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + acessor.getNodeId(), interfacePacUuid.getValue()); + + try { + // -- Specific part 1 + Constructor<EquipmentPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new() + InstanceIdentifier<EquipmentCurrentProblems> interfaceIID = InstanceIdentifier + .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build(); + + // -- Specific part 2 + EquipmentCurrentProblems problems = getGenericTransactionUtils().readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, interfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no {}", interfacePacUuid, clazzProblems, clazzProblems.getName()); + } else { + // -- Specific part 3 + for (CurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), + WrapperMicrowaveModelRev181010.mapSeverity(problem.getProblemSeverity())); + } + } + } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { + LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e); + } + return resultList; + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/Helper.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/Helper.java new file mode 100644 index 000000000..fc321a5e1 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/Helper.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.microwave; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LayerProtocolName; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType; + +/** + * @author herbert + * + */ +public class Helper { + + private static @NonNull UniversalId DEFAULT_UniversalId = new UniversalId("Default"); + private static @NonNull LayerProtocolName DEFAULT_LayerProtocolName = new LayerProtocolName("default"); + private static @NonNull GranularityPeriodType DEFAULT_GranularityPeriodType = GranularityPeriodType.Unknown; + private static @NonNull String DEFAULT_String = ""; + + public static @NonNull UniversalId nnGetUniversalId(@Nullable UniversalId x) { + return x == null ? DEFAULT_UniversalId : x; + } + + public static @NonNull LayerProtocolName nnGetLayerProtocolName(@Nullable LayerProtocolName x) { + return x == null ? DEFAULT_LayerProtocolName : x; + } + + public static @NonNull GranularityPeriodType nnGetGranularityPeriodType(@Nullable GranularityPeriodType x) { + return x == null ? DEFAULT_GranularityPeriodType : x; + } + + public static @NonNull String nnGetString(@Nullable String x) { + return x == null ? DEFAULT_String : x; + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/LinkIdentifyingObject.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/LinkIdentifyingObject.java new file mode 100644 index 000000000..4429473cf --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/LinkIdentifyingObject.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.microwave; + +public interface LinkIdentifyingObject { + + public String getSignalId(); + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/OnfMicrowaveModel.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/OnfMicrowaveModel.java new file mode 100644 index 000000000..c2ca542a2 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/OnfMicrowaveModel.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.microwave; + +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.notifications.NotificationWorker; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.yang.common.QName; + +public interface OnfMicrowaveModel { + + public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid, + FaultData resultList); + + public Class<?> getClassForLtpExtension(QName qName); + + public <T extends NotificationListener> T getNotificationListener(); + + // -- Frankfurt below + + /** Get performancedata from LTP + * + * @param lpName filter for layerprotocol + * @param lp to get pm from + * @return the pm data object + */ + @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp); + + /** Set notificationqueue worker for specific notification that needs to be forwarded **/ + void setNotificationQueue(NotificationWorker<EventlogEntity> notificationQueue); + + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java new file mode 100644 index 000000000..79124969c --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java @@ -0,0 +1,681 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.microwave; + + + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.pm.PerformanceDataAirInterface170324Builder; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.notifications.NotificationWorker; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName; +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; +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.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceCurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceDiversityCurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceHistoricalPerformanceTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AttributeValueChangedNotification; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerCurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerHistoricalPerformanceTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MicrowaveModelListener; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ObjectCreationNotification; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ObjectDeletionNotification; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ProblemNotification; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.SeverityType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.StructureCurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceConfiguration; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.tdm.container.pac.TdmContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.yang.common.QName; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, MicrowaveModelListener { + + private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev170324.class); + + public static final QName QNAME = MwAirInterfacePac.QNAME; + + + //private NetworkElementCoreData coreData; + private final NotificationService microwaveModelListener; + private final NetconfAccessor acessor; + private final TransactionUtils genericTransactionUtils; + private final FaultService faultService; + + private Optional<NotificationWorker<EventlogEntity>> notificationQueue; + + /** + * @param acessor to access device + */ + public WrapperMicrowaveModelRev170324(@NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) { + this.acessor = acessor; + this.genericTransactionUtils = acessor.getTransactionUtils(); + this.microwaveModelListener = serviceProvider.getNotificationService(); + this.faultService = serviceProvider.getFaultService(); + this.notificationQueue = Optional.empty(); + } + + /*----------------------------------------------------------------------------- + * Setter/Getter + */ + + @SuppressWarnings("unchecked") + @Override + public <T extends NotificationListener> T getNotificationListener() { + return (T)this; + } + + @Override + public void setNotificationQueue(NotificationWorker<EventlogEntity> notificationQueue) { + this.notificationQueue = Optional.of(notificationQueue); + } + + /*----------------------------------------------------------------------------- + * Interface functions + */ + + @Override + public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid, + FaultData resultList) { + + switch (lpName) { + case MWAirInterface: + readTheFaultsOfMwAirInterfacePac(uuid, resultList); + break; + + case EthernetContainer12: + readTheFaultsOfMwEthernetContainerPac(uuid, resultList); + break; + + case TDMContainer: + readTheFaultsOfMwTdmContainerPac(uuid, resultList); + break; + + case Structure: + if (lpClass == MwHybridMwStructurePac.class) { + readTheFaultsOfMwHybridMwStructurePac(uuid, resultList); + + } else if (lpClass == MwAirInterfaceDiversityPac.class) { + readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList); + + } else if (lpClass == MwPureEthernetStructurePac.class) { + readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList); + + } else { + LOG.warn("Unassigned lp model {} class {}", lpName, lpClass); + } + break; + case Ethernet: + // No alarms supported + break; + case EthernetContainer10: + default: + LOG.warn("Unassigned or not expected lp in model {}", lpName); + } + } + + @Override + public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) { + PerformanceDataLtp res = new PerformanceDataLtp(); + res = readAirInterfacePerformanceData(lp, res); + res = readEthernetContainerPerformanceData(lp, res); + return res; + } + +// @Override +// public @NonNull List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) { +// switch (lpName) { +// case MWAirInterface: +// return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp); +// +// case EthernetContainer12: +// return readTheHistoricalPerformanceDataOfEthernetContainer(lp); +// +// case EthernetContainer10: +// case EthernetPhysical: +// case Ethernet: +// case TDMContainer: +// case Structure: +// case Unknown: +// LOG.debug("Do not read HistoricalPM data for {} {}", lpName, getUuid(lp)); +// break; +// } +// return new ArrayList<>(); +// } + @Override + public Class<?> getClassForLtpExtension(QName qName) { + Class<?> res = null; + if (qName.equals(MwAirInterfacePac.QNAME)) { + res = MwAirInterfacePac.class; + } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) { + res = MwAirInterfaceDiversityPac.class; + } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) { + res = MwPureEthernetStructurePac.class; + } else if (qName.equals(MwHybridMwStructurePac.QNAME)) { + res = MwHybridMwStructurePac.class; + } else if (qName.equals(MwEthernetContainerPac.QNAME)) { + res = MwEthernetContainerPac.class; + } else if (qName.equals(MwTdmContainerPac.QNAME)) { + res = MwTdmContainerPac.class; + } + LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res)); + return res; + } + + @Override + public void onObjectCreationNotification(ObjectCreationNotification notification) { + LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName()); + if (notification != null) { + microwaveModelListener.creationNotification(acessor.getNodeId(), notification.getCounter(), + notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue()); + } + } + + @Override + public void onObjectDeletionNotification( ObjectDeletionNotification notification) { + LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName()); + if (notification != null) { + microwaveModelListener.deletionNotification(acessor.getNodeId(), notification.getCounter(), + notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue()); + } + } + + @Override + public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) { + LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName()); + EventlogEntity beventlogEntity = new EventlogBuilder().setNodeId(acessor.getNodeId().getValue()) + .setCounter(notification.getCounter()).setTimestamp(notification.getTimeStamp()) + .setObjectId(Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue()) + .setAttributeName(notification.getAttributeName()).setNewValue(notification.getNewValue()).build(); + microwaveModelListener.eventNotification(beventlogEntity); + if (notificationQueue.isPresent()) { + notificationQueue.get().put(beventlogEntity); + } + } + + @Override + public void onProblemNotification(ProblemNotification notification) { + + LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName()); + + faultService.faultNotification(acessor.getNodeId(), notification.getCounter(), + notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(), + notification.getProblem(), mapSeverity(notification.getSeverity())); + } + + /*----------------------------------------------------------------------------- + * Reading problems for specific interface pacs + */ + + /** + * Read problems of specific interfaces + * + * @param uuId Universal Id String of the interface + * @return number of alarms + */ + private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid, FaultData resultList) { + + final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class; + // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class; + // final Class<AirInterfaceCurrentProblems> clazzProblems = + // AirInterfaceCurrentProblems.class; + // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem = + // AirInterfaceCurrentProblemTypeG.class; + + String mountpointId = acessor.getNodeId().getValue(); + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + // Step 2.2: construct data and the relative iid + InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid)) + .child(AirInterfaceCurrentProblems.class).build(); + + // Step 2.3: read to the config data store + AirInterfaceCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID); + + if (problems == null) { + LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid); + } else { + for (AirInterfaceCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + + /** + * Read problems of specific interfaces + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + */ + private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid, FaultData resultList) { + + final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class; + // final Class<MwEthernetContainerPacKey> clazzPacKey = + // MwEthernetContainerPacKey.class; + // final Class<EthernetContainerCurrentProblems> clazzProblems = + // EthernetContainerCurrentProblems.class; + // final Class<ContainerCurrentProblemTypeG> clazzProblem = + // ContainerCurrentProblemTypeG.class; + + String mountpointId = acessor.getNodeId().getValue(); + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid)) + .child(EthernetContainerCurrentProblems.class).build(); + + EthernetContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid); + } else { + for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + */ + private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class; + // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey = + // MwAirInterfaceDiversityPacKey.class; + final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class; + // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem = + // AirInterfaceDiversityCurrentProblemTypeG.class; + + String mountpointId = acessor.getNodeId().getValue(); + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build(); + + AirInterfaceDiversityCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid); + } else { + for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + */ + private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class; + // final Class<MwPureEthernetStructurePacKey> clazzPacKey = + // MwPureEthernetStructurePacKey.class; + final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class; + // final Class<StructureCurrentProblemTypeG> clazzProblem = + // StructureCurrentProblemTypeG.class; + + String mountpointId = acessor.getNodeId().getValue(); + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build(); + + PureEthernetStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid); + } else { + for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + */ + private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid, FaultData resultList) { + + final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class; + // final Class<MwHybridMwStructurePacKey> clazzPacKey = + // MwHybridMwStructurePacKey.class; + final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class; + // final Class<HybridMwStructureCurrentProblemsG> clazzProblem = + // HybridMwStructureCurrentProblemsG.class; + + String mountpointId = acessor.getNodeId().getValue(); + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build(); + + HybridMwStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid); + } else { + for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces. TODO Goal for future implementation + * without usage of explicit new. Key is generated by newInstance() function + * here to verify this approach. + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + * @throws SecurityException + * @throws NoSuchMethodException + * @throws InvocationTargetException + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InstantiationException + */ + private FaultData readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid, FaultData resultList) { + + final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class; + final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class; + final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class; + // final Class<ContainerCurrentProblemTypeG> clazzProblem = + // ContainerCurrentProblemTypeG.class; + + String mountpointId = acessor.getNodeId().getValue(); + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + try { + // -- Specific part 1 + Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new() + InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build(); + + // -- Specific part 2 + TdmContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid); + } else { + // -- Specific part 3 + for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { + LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e); + } + return resultList; + } + + /*----------------------------------------------------------------------------- + * Performance related data + */ + +// /** +// * PM MwAirInterfacePac +// * +// * @param lp +// * @return +// */ +// private @NonNull List<ExtendedAirInterfaceHistoricalPerformanceType12> readTheHistoricalPerformanceDataOfMwAirInterfacePac( +// Lp lp) { +// +// List<ExtendedAirInterfaceHistoricalPerformanceType12> resultList = new ArrayList<>(); +// LOG.debug("DBRead Get {} MWAirInterfacePac: {}", coreData.getMountpoint(), lp.getUuid()); +// // ---- +// UniversalId mwAirInterfacePacuuId = lp.getUuid(); +// // Step 2.1: construct data and the relative iid +// InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier +// .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) +// .child(AirInterfaceConfiguration.class).build(); +// AirInterfaceConfiguration airConfiguration = genericTransactionUtils.readData(coreData.getDataBroker(), +// LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID); +// +// if (airConfiguration == null) { +// LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId); +// +// } else { +// // Step 2.2: construct data and the relative iid +// InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier +// .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) +// .child(AirInterfaceHistoricalPerformances.class).build(); +// +// // Step 2.3: read to the config data store +// AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtils.readData( +// coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID); +// +// if (airHistoricalPerformanceData == null) { +// LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances", +// mwAirInterfacePacuuId); +// } else { +// // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList +// List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData +// .nonnullHistoricalPerformanceDataList(); +// LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId, +// airHistPMList.size()); +// for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData +// .nonnullHistoricalPerformanceDataList()) { +// resultList.add(new ExtendedAirInterfaceHistoricalPerformanceType12(pmRecord, airConfiguration)); +// } +// } +// } +// LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, resultList.size()); +// return resultList; +// } + + /** + * Read and add performance data + * @param lp to read from + * @param result Object to be filled with data + * @return result + */ + private @NonNull PerformanceDataLtp readAirInterfacePerformanceData(Lp lp, PerformanceDataLtp result) { + + LOG.debug("DBRead Get {} MWAirInterfacePac: {}", acessor.getNodeId(), lp.getUuid()); + // ---- + UniversalId mwAirInterfacePacuuId = lp.getUuid(); + // Step 2.1: construct data and the relative iid + InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) + .child(AirInterfaceConfiguration.class).build(); + AirInterfaceConfiguration airConfiguration = acessor.getTransactionUtils().readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID); + + if (airConfiguration == null) { + LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId); + + } else { + // Step 2.2: construct data and the relative iid + InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) + .child(AirInterfaceHistoricalPerformances.class).build(); + + // Step 2.3: read to the config data store + AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtils.readData( + acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID); + + if (airHistoricalPerformanceData == null) { + LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances", + mwAirInterfacePacuuId); + } else { + // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData + .nonnullHistoricalPerformanceDataList(); + LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId, + airHistPMList.size()); + for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData + .nonnullHistoricalPerformanceDataList()) { + result.add(new PerformanceDataAirInterface170324Builder(acessor.getNodeId(), lp, pmRecord, airConfiguration)); + } + } + } + LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, result.size()); + return result; + } + +// private @NonNull List<ContainerHistoricalPerformanceTypeG> readTheHistoricalPerformanceDataOfEthernetContainer(Lp lp) { +// +// final String myName = "MWEthernetContainerPac"; +// +// List<ContainerHistoricalPerformanceTypeG> resultList = new ArrayList<>(); +// LOG.debug("DBRead Get {} : {}", coreData.getMountpoint(), myName, lp.getUuid()); +// // ---- +// UniversalId ethContainerPacuuId = lp.getUuid(); +// // Step 2.2: construct data and the relative iid +// InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier +// .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId)) +// .child(EthernetContainerHistoricalPerformances.class).build(); +// +// // Step 2.3: read to the config data store +// EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = genericTransactionUtils +// .readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID); +// +// if (ethContainerHistoricalPerformanceData == null) { +// LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId); +// } else { +// // import +// // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.ethernet.container.historical.performances.g.HistoricalPerformanceDataList +// // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList +// List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData +// .nonnullHistoricalPerformanceDataList(); +// LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size()); +// for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) { +// resultList.add(pmRecord); +// } +// } +// LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, resultList.size()); +// return resultList; +// } + + private @NonNull PerformanceDataLtp readEthernetContainerPerformanceData(Lp lp, PerformanceDataLtp result) { + final String myName = "MWEthernetContainerPac"; + + String mountpointId = acessor.getNodeId().getValue(); + + LOG.debug("DBRead Get {} : {}", mountpointId, myName, lp.getUuid()); + // ---- + UniversalId ethContainerPacuuId = lp.getUuid(); + // Step 2.2: construct data and the relative iid + InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId)) + .child(EthernetContainerHistoricalPerformances.class).build(); + + // Step 2.3: read to the config data store + EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = acessor.getTransactionUtils() + .readData(acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID); + + if (ethContainerHistoricalPerformanceData == null) { + LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId); + } else { + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData + .nonnullHistoricalPerformanceDataList(); + LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size()); + for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) { + result.add(new PerformanceDataAirInterface170324Builder(acessor.getNodeId(), lp, pmRecord)); + } + } + LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, result.size()); + return result; + } + +// private static String getUuid(Lp lp) { +// UniversalId uuid = lp.getUuid(); +// return uuid != null ? uuid.getValue() : null; +// } + + private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity( SeverityType severity) { + + Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType> res = + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.forName(severity.name()); + return res.orElse(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed); + } + + + + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java new file mode 100644 index 000000000..ed3019cec --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java @@ -0,0 +1,689 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.microwave; + + + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.pm.PerformanceDataAirInterface180907Builder; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.notifications.NotificationWorker; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName; +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; +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.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.SeverityType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceCurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceDiversityCurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceHistoricalPerformanceTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AttributeValueChangedNotification; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ContainerCurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ContainerHistoricalPerformanceTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MicrowaveModelListener; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfaceDiversityPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfaceDiversityPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfacePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfacePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwEthernetContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwEthernetContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwHybridMwStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwHybridMwStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwPureEthernetStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwPureEthernetStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwTdmContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwTdmContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ObjectCreationNotification; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ObjectDeletionNotification; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ProblemNotification; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.StructureCurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceConfiguration; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.tdm.container.pac.TdmContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.yang.common.QName; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, MicrowaveModelListener { + + private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev180907.class); + + public static final QName QNAME = MwAirInterfacePac.QNAME; + + + private final NotificationService microwaveModelListener; + private final NetconfAccessor acessor; + private final TransactionUtils genericTransactionUtil; + private final String mountpointId; + private final @NonNull FaultService faultService; + + private Optional<NotificationWorker<EventlogEntity>> notificationQueue; + + + /** + * Handle specific version of microwave model + * @param acessor to access device + * @param serviceProvider for devicemanager services + */ + public WrapperMicrowaveModelRev180907(@NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) { + this.acessor = acessor; + this.mountpointId = acessor.getNodeId().getValue(); + this.genericTransactionUtil = acessor.getTransactionUtils(); + this.microwaveModelListener = serviceProvider.getNotificationService(); + this.faultService = serviceProvider.getFaultService(); + this.notificationQueue = Optional.empty(); + } + + /*----------------------------------------------------------------------------- + * Setter/Getter + */ + + @SuppressWarnings("unchecked") + @Override + public <T extends NotificationListener> T getNotificationListener() { + return (T) this; + } + + @Override + public void setNotificationQueue(NotificationWorker<EventlogEntity> notificationQueue) { + this.notificationQueue = Optional.of(notificationQueue); + } + + /*----------------------------------------------------------------------------- + * Interfacefunctions + */ + + @Override + public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid, + FaultData resultList) { + + switch (lpName) { + case MWAirInterface: + readTheFaultsOfMwAirInterfacePac(uuid, resultList); + break; + + case EthernetContainer12: + readTheFaultsOfMwEthernetContainerPac(uuid, resultList); + break; + + case TDMContainer: + readTheFaultsOfMwTdmContainerPac(uuid, resultList); + break; + + case Structure: + if (lpClass == MwHybridMwStructurePac.class) { + readTheFaultsOfMwHybridMwStructurePac(uuid, resultList); + + } else if (lpClass == MwAirInterfaceDiversityPac.class) { + readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList); + + } else if (lpClass == MwPureEthernetStructurePac.class) { + readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList); + + } else { + LOG.warn("Unassigned lp model {} class {}", lpName, lpClass); + } + break; + case Ethernet: + // No alarms supported + break; + case EthernetContainer10: + default: + LOG.warn("Unassigned or not expected lp in model {}", lpName); + } + } + + @Override + public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) { + PerformanceDataLtp res = new PerformanceDataLtp(); + switch (lpName) { + case MWAirInterface: + res = readAirInterfacePerformanceData(lp, res); + break; + + case EthernetContainer12: + res = readEthernetContainerPerformanceData(lp, res); + break; + + case EthernetContainer10: + case EthernetPhysical: + case Ethernet: + case TDMContainer: + case Structure: + case Unknown: + LOG.debug("Do not read HistoricalPM data for {} {}", lpName, Helper.nnGetUniversalId(lp.getUuid()).getValue()); + break; + } + return res; + } + +// @Override +// public @NonNull List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) { +// switch (lpName) { +// case MWAirInterface: +// return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp); +// +// case EthernetContainer12: +// return readTheHistoricalPerformanceDataOfEthernetContainer(lp); +// +// case EthernetContainer10: +// case EthernetPhysical: +// case Ethernet: +// case TDMContainer: +// case Structure: +// case Unknown: +// LOG.debug("Do not read HistoricalPM data for {} {}", lpName, Helper.nnGetUniversalId(lp.getUuid()).getValue()); +// break; +// } +// return new ArrayList<>(); +// } + + @Override + public Class<?> getClassForLtpExtension(QName qName) { + Class<?> res = null; + if (qName.equals(MwAirInterfacePac.QNAME)) { + res = MwAirInterfacePac.class; + } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) { + res = MwAirInterfaceDiversityPac.class; + } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) { + res = MwPureEthernetStructurePac.class; + } else if (qName.equals(MwHybridMwStructurePac.QNAME)) { + res = MwHybridMwStructurePac.class; + } else if (qName.equals(MwEthernetContainerPac.QNAME)) { + res = MwEthernetContainerPac.class; + } else if (qName.equals(MwTdmContainerPac.QNAME)) { + res = MwTdmContainerPac.class; + } + LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res)); + return res; + } + + @Override + public void onObjectCreationNotification(ObjectCreationNotification notification) { + LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName()); + if (notification != null) { + microwaveModelListener.creationNotification(acessor.getNodeId(), notification.getCounter(), + notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue()); + } + } + + @Override + public void onObjectDeletionNotification( ObjectDeletionNotification notification) { + LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName()); + if (notification != null) { + microwaveModelListener.deletionNotification(acessor.getNodeId(), notification.getCounter(), + notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue()); + } + } + + @Override + public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) { + LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName()); + EventlogEntity beventlogEntity = new EventlogBuilder().setNodeId(acessor.getNodeId().getValue()) + .setCounter(notification.getCounter()).setTimestamp(notification.getTimeStamp()) + .setObjectId(Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue()) + .setAttributeName(notification.getAttributeName()).setNewValue(notification.getNewValue()).build(); + microwaveModelListener.eventNotification(beventlogEntity); + if (notificationQueue.isPresent()) { + notificationQueue.get().put(beventlogEntity); + } + } + + @Override + public void onProblemNotification(ProblemNotification notification) { + + LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName()); + + faultService.faultNotification(acessor.getNodeId(), notification.getCounter(), + notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(), + notification.getProblem(), mapSeverity(notification.getSeverity())); + } + + /*----------------------------------------------------------------------------- + * Reading problems for specific interface pacs + */ + + /** + * Read problems of specific interfaces + * + * @param uuId Universal Id String of the interface + * @return number of alarms + */ + private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class; + // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class; + // final Class<AirInterfaceCurrentProblems> clazzProblems = + // AirInterfaceCurrentProblems.class; + // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem = + // AirInterfaceCurrentProblemTypeG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + // Step 2.2: construct data and the relative iid + InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid)) + .child(AirInterfaceCurrentProblems.class).build(); + + // Step 2.3: read to the config data store + AirInterfaceCurrentProblems problems = genericTransactionUtil.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID); + + if (problems == null) { + LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid); + } else { + for (AirInterfaceCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + */ + private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class; + // final Class<MwEthernetContainerPacKey> clazzPacKey = + // MwEthernetContainerPacKey.class; + // final Class<EthernetContainerCurrentProblems> clazzProblems = + // EthernetContainerCurrentProblems.class; + // final Class<ContainerCurrentProblemTypeG> clazzProblem = + // ContainerCurrentProblemTypeG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid)) + .child(EthernetContainerCurrentProblems.class).build(); + + EthernetContainerCurrentProblems problems = genericTransactionUtil.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid); + } else { + for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + */ + private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class; + // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey = + // MwAirInterfaceDiversityPacKey.class; + final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class; + // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem = + // AirInterfaceDiversityCurrentProblemTypeG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build(); + + AirInterfaceDiversityCurrentProblems problems = genericTransactionUtil.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid); + } else { + for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + */ + private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class; + // final Class<MwPureEthernetStructurePacKey> clazzPacKey = + // MwPureEthernetStructurePacKey.class; + final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class; + // final Class<StructureCurrentProblemTypeG> clazzProblem = + // StructureCurrentProblemTypeG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build(); + + PureEthernetStructureCurrentProblems problems = genericTransactionUtil.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid); + } else { + for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + */ + private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class; + // final Class<MwHybridMwStructurePacKey> clazzPacKey = + // MwHybridMwStructurePacKey.class; + final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class; + // final Class<HybridMwStructureCurrentProblemsG> clazzProblem = + // HybridMwStructureCurrentProblemsG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build(); + + HybridMwStructureCurrentProblems problems = genericTransactionUtil.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid); + } else { + for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces. TODO Goal for future implementation + * without usage of explicit new. Key is generated by newInstance() function + * here to verify this approach. + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + * @throws SecurityException + * @throws NoSuchMethodException + * @throws InvocationTargetException + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InstantiationException + */ + private FaultData readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class; + final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class; + final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class; + // final Class<ContainerCurrentProblemTypeG> clazzProblem = + // ContainerCurrentProblemTypeG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + try { + // -- Specific part 1 + Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new() + InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build(); + + // -- Specific part 2 + TdmContainerCurrentProblems problems = genericTransactionUtil.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid); + } else { + // -- Specific part 3 + for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { + LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e); + } + return resultList; + } + + /*----------------------------------------------------------------------------- + * Performance related data + */ + +// /** +// * PM MwAirInterfacePac +// * +// * @param lp +// * @return +// */ +// private @NonNull List<ExtendedAirInterfaceHistoricalPerformanceType1211> readTheHistoricalPerformanceDataOfMwAirInterfacePac( +// Lp lp) { +// +// String uuId = Helper.nnGetUniversalId(lp.getUuid()).getValue(); +// +// List<ExtendedAirInterfaceHistoricalPerformanceType1211> resultList = new ArrayList<>(); +// LOG.debug("DBRead Get {} MWAirInterfacePac: {}", coreData.getMountpoint(), uuId); +// // ---- +// UniversalId mwAirInterfacePacuuId = new UniversalId(uuId); +// // Step 2.1: construct data and the relative iid +// InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier +// .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) +// .child(AirInterfaceConfiguration.class).build(); +// AirInterfaceConfiguration airConfiguration = genericTransactionUtil.readData(coreData.getDataBroker(), +// LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID); +// +// if (airConfiguration == null) { +// LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId); +// +// } else { +// // Step 2.2: construct data and the relative iid +// InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier +// .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) +// .child(AirInterfaceHistoricalPerformances.class).build(); +// +// // Step 2.3: read to the config data store +// AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtil.readData( +// coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID); +// +// if (airHistoricalPerformanceData == null) { +// LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances", +// mwAirInterfacePacuuId); +// } else { +// List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData +// .nonnullHistoricalPerformanceDataList(); +// LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId, +// airHistPMList.size()); +// for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistPMList) { +// resultList.add(new ExtendedAirInterfaceHistoricalPerformanceType1211(pmRecord, airConfiguration)); +// } +// } +// } +// LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, resultList.size()); +// return resultList; +// } + +// private @NonNull List<ContainerHistoricalPerformanceTypeG> readTheHistoricalPerformanceDataOfEthernetContainer(Lp lp) { +// +// final String myName = "MWEthernetContainerPac"; +// String uuId = Helper.nnGetUniversalId(lp.getUuid()).getValue(); +// +// List<ContainerHistoricalPerformanceTypeG> resultList = new ArrayList<>(); +// LOG.debug("DBRead Get {} : {}", coreData.getMountpoint(), myName, uuId); +// // ---- +// UniversalId ethContainerPacuuId = new UniversalId(uuId); +// // Step 2.2: construct data and the relative iid +// InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier +// .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId)) +// .child(EthernetContainerHistoricalPerformances.class).build(); +// +// // Step 2.3: read to the config data store +// EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = genericTransactionUtil +// .readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID); +// +// if (ethContainerHistoricalPerformanceData == null) { +// LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId); +// } else { +// // import +// // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.ethernet.container.historical.performances.g.HistoricalPerformanceDataList +// List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData +// .nonnullHistoricalPerformanceDataList(); +// LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size()); +// for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) { +// resultList.add(pmRecord); +// } +// } +// LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, resultList.size()); +// return resultList; +// } + + /** + * Read and add performance data + * @param lp to read from + * @param result Object to be filled with data + * @return result + */ + private @NonNull PerformanceDataLtp readAirInterfacePerformanceData(Lp lp, PerformanceDataLtp result) { + + LOG.debug("DBRead Get {} MWAirInterfacePac: {}", acessor.getNodeId(), lp.getUuid()); + // ---- + UniversalId mwAirInterfacePacuuId = lp.getUuid(); + // Step 2.1: construct data and the relative iid + InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) + .child(AirInterfaceConfiguration.class).build(); + AirInterfaceConfiguration airConfiguration = acessor.getTransactionUtils().readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID); + + if (airConfiguration == null) { + LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId); + + } else { + // Step 2.2: construct data and the relative iid + InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) + .child(AirInterfaceHistoricalPerformances.class).build(); + + // Step 2.3: read to the config data store + AirInterfaceHistoricalPerformances airHistoricalPerformanceData = acessor.getTransactionUtils().readData( + acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID); + + if (airHistoricalPerformanceData == null) { + LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances", + mwAirInterfacePacuuId); + } else { + // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData + .nonnullHistoricalPerformanceDataList(); + LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId, + airHistPMList.size()); + for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData + .nonnullHistoricalPerformanceDataList()) { + result.add(new PerformanceDataAirInterface180907Builder(acessor.getNodeId(), lp, pmRecord, airConfiguration)); + } + } + } + LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, result.size()); + return result; + } + + private @NonNull PerformanceDataLtp readEthernetContainerPerformanceData(Lp lp, PerformanceDataLtp result) { + final String myName = "MWEthernetContainerPac"; + + LOG.debug("DBRead Get {} : {}", myName, lp.getUuid()); + // ---- + UniversalId ethContainerPacuuId = lp.getUuid(); + // Step 2.2: construct data and the relative iid + InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId)) + .child(EthernetContainerHistoricalPerformances.class).build(); + + // Step 2.3: read to the config data store + EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = acessor.getTransactionUtils() + .readData(acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID); + + if (ethContainerHistoricalPerformanceData == null) { + LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId); + } else { + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData + .nonnullHistoricalPerformanceDataList(); + LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size()); + for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) { + result.add(new PerformanceDataAirInterface180907Builder(acessor.getNodeId(), lp, pmRecord)); + } + } + LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, result.size()); + return result; + } + + private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity( SeverityType severity) { + + Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType> res = + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.forName(severity.name()); + return res.orElse(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed); + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java new file mode 100644 index 000000000..dc2c4e995 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java @@ -0,0 +1,590 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.microwave; + + + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.pm.PerformanceDataAirInterface181010Builder; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.notifications.NotificationWorker; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName; +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; +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.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceCurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceDiversityCurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceHistoricalPerformanceTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AttributeValueChangedNotification; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerCurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerHistoricalPerformanceTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MicrowaveModelListener; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ObjectCreationNotification; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ObjectDeletionNotification; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ProblemNotification; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.StructureCurrentProblemTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceConfiguration; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.tdm.container.pac.TdmContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.yang.common.QName; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, MicrowaveModelListener { + + private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev181010.class); + + public static final QName QNAME = MwAirInterfacePac.QNAME; + + + private final NetconfAccessor acessor; + private final NotificationService microwaveModelListener; + private final TransactionUtils genericTransactionUtils; + private final String mountpointId; + private final @NonNull FaultService faultService; + + private Optional<NotificationWorker<EventlogEntity>> notificationQueue; + + /** + * Handle specific version of microwave model + * @param acessor to access device + * @param serviceProvider for devicemanager services + */ + public WrapperMicrowaveModelRev181010(@NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) { + this.acessor = acessor; + this.genericTransactionUtils = acessor.getTransactionUtils(); + this.mountpointId = acessor.getNodeId().getValue(); + this.microwaveModelListener = serviceProvider.getNotificationService(); + this.faultService = serviceProvider.getFaultService(); + this.notificationQueue = Optional.empty(); + } + + /*----------------------------------------------------------------------------- + * Setter/Getter + */ + + @SuppressWarnings("unchecked") + @Override + public <T extends NotificationListener> T getNotificationListener() { + return (T) this; + } + + @Override + public void setNotificationQueue(NotificationWorker<EventlogEntity> notificationQueue) { + this.notificationQueue = Optional.of(notificationQueue); + } + + /*----------------------------------------------------------------------------- + * Interfacefunctions + */ + + @Override + public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid, + FaultData resultList) { + + switch (lpName) { + case MWAirInterface: + readTheFaultsOfMwAirInterfacePac(uuid, resultList); + break; + + case EthernetContainer12: + readTheFaultsOfMwEthernetContainerPac(uuid, resultList); + break; + + case TDMContainer: + readTheFaultsOfMwTdmContainerPac(uuid, resultList); + break; + + case Structure: + if (lpClass == MwHybridMwStructurePac.class) { + readTheFaultsOfMwHybridMwStructurePac(uuid, resultList); + + } else if (lpClass == MwAirInterfaceDiversityPac.class) { + readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList); + + } else if (lpClass == MwPureEthernetStructurePac.class) { + readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList); + + } else { + LOG.warn("Unassigned lp model {} class {}", lpName, lpClass); + } + break; + case Ethernet: + // No alarms supported + break; + case EthernetContainer10: + default: + LOG.warn("Unassigned or not expected lp in model {}", lpName); + } + } + + @Override + public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) { + PerformanceDataLtp res = new PerformanceDataLtp(); + switch (lpName) { + case MWAirInterface: + return readAirInterfacePerformanceData(lp, res); + + case EthernetContainer12: + return readEthernetContainerPerformanceData(lp, res); + + case EthernetContainer10: + case EthernetPhysical: + case Ethernet: + case TDMContainer: + case Structure: + case Unknown: + LOG.debug("Do not read HistoricalPM data for {} {}", lpName, Helper.nnGetUniversalId(lp.getUuid()).getValue()); + } + return res; + } + + @Override + public Class<?> getClassForLtpExtension(QName qName) { + Class<?> res = null; + if (qName.equals(MwAirInterfacePac.QNAME)) { + res = MwAirInterfacePac.class; + } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) { + res = MwAirInterfaceDiversityPac.class; + } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) { + res = MwPureEthernetStructurePac.class; + } else if (qName.equals(MwHybridMwStructurePac.QNAME)) { + res = MwHybridMwStructurePac.class; + } else if (qName.equals(MwEthernetContainerPac.QNAME)) { + res = MwEthernetContainerPac.class; + } else if (qName.equals(MwTdmContainerPac.QNAME)) { + res = MwTdmContainerPac.class; + } + LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res)); + return res; + } + + @Override + public void onObjectCreationNotification(ObjectCreationNotification notification) { + LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName()); + if (notification != null) { + microwaveModelListener.creationNotification(acessor.getNodeId(), notification.getCounter(), + notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue()); + } + } + + @Override + public void onObjectDeletionNotification( ObjectDeletionNotification notification) { + LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName()); + if (notification != null) { + microwaveModelListener.deletionNotification(acessor.getNodeId(), notification.getCounter(), + notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue()); + } + } + + @Override + public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) { + LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName()); + EventlogEntity beventlogEntity = new EventlogBuilder().setNodeId(acessor.getNodeId().getValue()) + .setCounter(notification.getCounter()).setTimestamp(notification.getTimeStamp()) + .setObjectId(Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue()) + .setAttributeName(notification.getAttributeName()).setNewValue(notification.getNewValue()).build(); + microwaveModelListener.eventNotification(beventlogEntity); + if (notificationQueue.isPresent()) { + notificationQueue.get().put(beventlogEntity); + } + } + + @Override + public void onProblemNotification(ProblemNotification notification) { + + LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName()); + + faultService.faultNotification(acessor.getNodeId(), notification.getCounter(), + notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(), + notification.getProblem(), mapSeverity(notification.getSeverity())); + } + + /*----------------------------------------------------------------------------- + * Reading problems for specific interface pacs + */ + + /** + * Read problems of specific interfaces + * + * @param uuId Universal Id String of the interface + * @return number of alarms + */ + private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class; + // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class; + // final Class<AirInterfaceCurrentProblems> clazzProblems = + // AirInterfaceCurrentProblems.class; + // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem = + // AirInterfaceCurrentProblemTypeG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + // Step 2.2: construct data and the relative iid + InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid)) + .child(AirInterfaceCurrentProblems.class).build(); + + // Step 2.3: read to the config data store + AirInterfaceCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID); + + if (problems == null) { + LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid); + } else if (problems.getCurrentProblemList() == null) { + LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid); + } else { + for (AirInterfaceCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + */ + private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class; + // final Class<MwEthernetContainerPacKey> clazzPacKey = + // MwEthernetContainerPacKey.class; + // final Class<EthernetContainerCurrentProblems> clazzProblems = + // EthernetContainerCurrentProblems.class; + // final Class<ContainerCurrentProblemTypeG> clazzProblem = + // ContainerCurrentProblemTypeG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid)) + .child(EthernetContainerCurrentProblems.class).build(); + + EthernetContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid); + } else if (problems.getCurrentProblemList() == null) { + LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid); + } else { + for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + */ + private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class; + // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey = + // MwAirInterfaceDiversityPacKey.class; + final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class; + // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem = + // AirInterfaceDiversityCurrentProblemTypeG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build(); + + AirInterfaceDiversityCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid); + } else if (problems.getCurrentProblemList() == null) { + LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid); + } else { + for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + */ + private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class; + // final Class<MwPureEthernetStructurePacKey> clazzPacKey = + // MwPureEthernetStructurePacKey.class; + final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class; + // final Class<StructureCurrentProblemTypeG> clazzProblem = + // StructureCurrentProblemTypeG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build(); + + PureEthernetStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid); + } else if (problems.getCurrentProblemList() == null) { + LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid); + } else { + for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + */ + private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class; + // final Class<MwHybridMwStructurePacKey> clazzPacKey = + // MwHybridMwStructurePacKey.class; + final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class; + // final Class<HybridMwStructureCurrentProblemsG> clazzProblem = + // HybridMwStructureCurrentProblemsG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build(); + + HybridMwStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid); + } else if (problems.getCurrentProblemList() == null) { + LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid); + } else { + for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + return resultList; + } + + /** + * Read problems of specific interfaces. TODO Goal for future implementation + * without usage of explicit new. Key is generated by newInstance() function + * here to verify this approach. + * + * @param uuId Universal index of Interfacepac + * @return number of alarms + * @throws SecurityException + * @throws NoSuchMethodException + * @throws InvocationTargetException + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InstantiationException + */ + private FaultData readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid, + FaultData resultList) { + + final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class; + final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class; + final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class; + // final Class<ContainerCurrentProblemTypeG> clazzProblem = + // ContainerCurrentProblemTypeG.class; + + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), + mountpointId, interfacePacUuid.getValue()); + + try { + // -- Specific part 1 + Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new() + InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build(); + + // -- Specific part 2 + TdmContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID); + if (problems == null) { + LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid); + } else { + // -- Specific part 3 + for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { + resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(), + interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity())); + } + } + } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { + LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e); + } + return resultList; + } + + /*----------------------------------------------------------------------------- + * Performance related data + */ + + /** + * Read and add performance data + * @param lp to read from + * @param result Object to be filled with data + * @return result + */ + private @NonNull PerformanceDataLtp readAirInterfacePerformanceData(Lp lp, PerformanceDataLtp result) { + + LOG.debug("DBRead Get {} MWAirInterfacePac: {}", acessor.getNodeId(), lp.getUuid()); + // ---- + UniversalId mwAirInterfacePacuuId = lp.getUuid(); + // Step 2.1: construct data and the relative iid + InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) + .child(AirInterfaceConfiguration.class).build(); + AirInterfaceConfiguration airConfiguration = acessor.getTransactionUtils().readData(acessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID); + + if (airConfiguration == null) { + LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId); + + } else { + // Step 2.2: construct data and the relative iid + InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) + .child(AirInterfaceHistoricalPerformances.class).build(); + + // Step 2.3: read to the config data store + AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtils.readData( + acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID); + + if (airHistoricalPerformanceData == null) { + LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances", + mwAirInterfacePacuuId); + } else { + // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData + .nonnullHistoricalPerformanceDataList(); + LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId, + airHistPMList.size()); + for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData + .nonnullHistoricalPerformanceDataList()) { + result.add(new PerformanceDataAirInterface181010Builder(acessor.getNodeId(), lp, pmRecord, airConfiguration)); + } + } + } + LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, result.size()); + return result; + } + + private @NonNull PerformanceDataLtp readEthernetContainerPerformanceData(Lp lp, PerformanceDataLtp result) { + final String myName = "MWEthernetContainerPac"; + + LOG.debug("DBRead Get {} : {}", mountpointId, myName, lp.getUuid()); + // ---- + UniversalId ethContainerPacuuId = lp.getUuid(); + // Step 2.2: construct data and the relative iid + InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId)) + .child(EthernetContainerHistoricalPerformances.class).build(); + + // Step 2.3: read to the config data store + EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = acessor.getTransactionUtils() + .readData(acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID); + + if (ethContainerHistoricalPerformanceData == null) { + LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId); + } else { + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData + .nonnullHistoricalPerformanceDataList(); + LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size()); + for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) { + result.add(new PerformanceDataAirInterface181010Builder(acessor.getNodeId(), lp, pmRecord)); + } + } + LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, result.size()); + return result; + } + + public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity( SeverityType severity) { + + Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType> res = + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.forName(severity.name()); + return res.orElse(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed); + } + + + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface170324Builder.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface170324Builder.java new file mode 100644 index 000000000..a24f235a3 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface170324Builder.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.microwave.pm; + +import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.Helper; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceHistoricalPerformanceTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerHistoricalPerformanceTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performance.type.g.PerformanceData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceConfiguration; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.GranularityPeriodType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntityBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.pmdata.entity.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; + +public class PerformanceDataAirInterface170324Builder extends PmdataEntityBuilder { + + private PerformanceDataAirInterface170324Builder(NodeId nodeId, Lp lp, OtnHistoryDataG pmRecord) { + super(); + Optional<GranularityPeriodType> gp = GranularityPeriodType.forName(Helper.nnGetGranularityPeriodType(pmRecord.getGranularityPeriod()).getName()); + this.setGranularityPeriod(gp.orElse(GranularityPeriodType.Unknown)); + this.setUuidInterface(Helper.nnGetUniversalId(lp.getUuid()).getValue()); + this.setLayerProtocolName(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue()); + this.setNodeName(nodeId.getValue()); + this.setScannerId(pmRecord.getHistoryDataId()); + this.setTimeStamp(pmRecord.getPeriodEndTime()); + this.setSuspectIntervalFlag(pmRecord.isSuspectIntervalFlag()); + } + + /** + * Move data to generic type + * @param nodeId of node + * @param lp to get data from + * @param pmRecord data itself + * @param airConfiguration configuration for additional parameter + */ + public PerformanceDataAirInterface170324Builder(NodeId nodeId, Lp lp, AirInterfaceHistoricalPerformanceTypeG pmRecord, + AirInterfaceConfiguration airConfiguration) { + this(nodeId, lp, pmRecord); + + this.setRadioSignalId(airConfiguration.getRadioSignalId()); + PerformanceData pmr = pmRecord.getPerformanceData(); + if (pmr != null) { + PerformanceDataBuilder bPerformanceData = new PerformanceDataBuilder(); + bPerformanceData.setTimePeriod(pmr.getTimePeriod()); + bPerformanceData.setEs(pmr.getEs()); + bPerformanceData.setSes(pmr.getSes()); + bPerformanceData.setCses(pmr.getCses()); + bPerformanceData.setUnavailability(pmr.getUnavailability()); + bPerformanceData.setTxLevelMin(pmr.getTxLevelMin()); + bPerformanceData.setTxLevelMax(pmr.getTxLevelMax()); + bPerformanceData.setTxLevelAvg(pmr.getTxLevelAvg()); + bPerformanceData.setRxLevelMin(pmr.getRxLevelMin()); + bPerformanceData.setRxLevelMax(pmr.getRxLevelMax()); + bPerformanceData.setRxLevelAvg(pmr.getRxLevelAvg()); + bPerformanceData.setTime2States(pmr.getTime2States()); + bPerformanceData.setTime4StatesS(pmr.getTime4StatesS()); + bPerformanceData.setTime4States(pmr.getTime4States()); + bPerformanceData.setTime8States(pmr.getTime8States()); + bPerformanceData.setTime16StatesS(pmr.getTime16StatesS()); + bPerformanceData.setTime16States(pmr.getTime16States()); + bPerformanceData.setTime32States(pmr.getTime32States()); + bPerformanceData.setTime64States(pmr.getTime64States()); + bPerformanceData.setTime128States(pmr.getTime128States()); + bPerformanceData.setTime256States(pmr.getTime256States()); + bPerformanceData.setTime512States(pmr.getTime512States()); + bPerformanceData.setTime512StatesL(pmr.getTime512StatesL()); + bPerformanceData.setTime1024States(pmr.getTime1024States()); + bPerformanceData.setTime1024StatesL(pmr.getTime1024StatesL()); + bPerformanceData.setTime2048States(pmr.getTime2048States()); + bPerformanceData.setTime2048StatesL(pmr.getTime2048StatesL()); + bPerformanceData.setTime4096States(pmr.getTime4096States()); + bPerformanceData.setTime4096StatesL(pmr.getTime4096StatesL()); + bPerformanceData.setTime8192States(pmr.getTime8192States()); + bPerformanceData.setTime8192StatesL(pmr.getTime8192StatesL()); + bPerformanceData.setSnirMin(pmr.getSnirMin()); + bPerformanceData.setSnirMax(pmr.getSnirMax()); + bPerformanceData.setSnirAvg(pmr.getSnirAvg()); + bPerformanceData.setXpdMin(pmr.getXpdMin()); + bPerformanceData.setXpdMax(pmr.getXpdMax()); + bPerformanceData.setXpdAvg(pmr.getXpdAvg()); + bPerformanceData.setRfTempMin(pmr.getRfTempMin()); + bPerformanceData.setRfTempMax(pmr.getRfTempMax()); + bPerformanceData.setRfTempAvg(pmr.getRfTempAvg()); + bPerformanceData.setDefectBlocksSum(pmr.getDefectBlocksSum()); + this.setPerformanceData(bPerformanceData.build()); + } + } + + /** + * Move data to generic type + * @param nodeId of node + * @param lp to get data from + * @param pmRecord data itself + */ + public PerformanceDataAirInterface170324Builder(NodeId nodeId, Lp lp, ContainerHistoricalPerformanceTypeG pmRecord) { + this(nodeId, lp, (OtnHistoryDataG) pmRecord); + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.container.historical.performance.type.g.PerformanceData pmr = pmRecord + .getPerformanceData(); + if (pmr != null) { + PerformanceDataBuilder bPerformanceData = new PerformanceDataBuilder(); + bPerformanceData.setTimePeriod(pmr.getTimePeriod()); + bPerformanceData.setTxEthernetBytesMaxM(pmr.getTxEthernetBytesMaxM()); + bPerformanceData.setTxEthernetBytesMaxS(pmr.getTxEthernetBytesMaxS()); + bPerformanceData.setTxEthernetBytesSum(pmr.getTxEthernetBytesSum()); + this.setPerformanceData(bPerformanceData.build()); + } + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface180907Builder.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface180907Builder.java new file mode 100644 index 000000000..62382e326 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface180907Builder.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.microwave.pm; + +import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.Helper; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceHistoricalPerformanceTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ContainerHistoricalPerformanceTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performance.type.g.PerformanceData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceConfiguration; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.GranularityPeriodType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntityBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.pmdata.entity.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; + +public class PerformanceDataAirInterface180907Builder extends PmdataEntityBuilder { + + private PerformanceDataAirInterface180907Builder(NodeId nodeId, Lp lp, OtnHistoryDataG pmRecord) { + super(); + Optional<GranularityPeriodType> gp = GranularityPeriodType.forName(Helper.nnGetGranularityPeriodType(pmRecord.getGranularityPeriod()).getName()); + this.setGranularityPeriod(gp.orElse(GranularityPeriodType.Unknown)); + this.setUuidInterface(Helper.nnGetUniversalId(lp.getUuid()).getValue()); + this.setLayerProtocolName(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue()); + this.setNodeName(nodeId.getValue()); + this.setScannerId(pmRecord.getHistoryDataId()); + this.setTimeStamp(pmRecord.getPeriodEndTime()); + this.setSuspectIntervalFlag(pmRecord.isSuspectIntervalFlag()); + } + + /** + * Move data to generic type + * @param nodeId of node + * @param lp to get data from + * @param pmRecord data itself + * @param airConfiguration configuration for additional parameter + */ + public PerformanceDataAirInterface180907Builder(NodeId nodeId, Lp lp, AirInterfaceHistoricalPerformanceTypeG pmRecord, + AirInterfaceConfiguration airConfiguration) { + this(nodeId, lp, pmRecord); + + this.setRadioSignalId(airConfiguration.getRadioSignalId()); + PerformanceData pmr = pmRecord.getPerformanceData(); + if (pmr != null) { + PerformanceDataBuilder bPerformanceData = new PerformanceDataBuilder(); + bPerformanceData.setTimePeriod(pmr.getTimePeriod()); + bPerformanceData.setEs(pmr.getEs()); + bPerformanceData.setSes(pmr.getSes()); + bPerformanceData.setCses(pmr.getCses()); + bPerformanceData.setUnavailability(pmr.getUnavailability()); + bPerformanceData.setTxLevelMin(pmr.getTxLevelMin()); + bPerformanceData.setTxLevelMax(pmr.getTxLevelMax()); + bPerformanceData.setTxLevelAvg(pmr.getTxLevelAvg()); + bPerformanceData.setRxLevelMin(pmr.getRxLevelMin()); + bPerformanceData.setRxLevelMax(pmr.getRxLevelMax()); + bPerformanceData.setRxLevelAvg(pmr.getRxLevelAvg()); + bPerformanceData.setTime2States(pmr.getTime2States()); + bPerformanceData.setTime4StatesS(pmr.getTime4StatesS()); + bPerformanceData.setTime4States(pmr.getTime4States()); + bPerformanceData.setTime8States(pmr.getTime8States()); + bPerformanceData.setTime16StatesS(pmr.getTime16StatesS()); + bPerformanceData.setTime16States(pmr.getTime16States()); + bPerformanceData.setTime32States(pmr.getTime32States()); + bPerformanceData.setTime64States(pmr.getTime64States()); + bPerformanceData.setTime128States(pmr.getTime128States()); + bPerformanceData.setTime256States(pmr.getTime256States()); + bPerformanceData.setTime512States(pmr.getTime512States()); + bPerformanceData.setTime512StatesL(pmr.getTime512StatesL()); + bPerformanceData.setTime1024States(pmr.getTime1024States()); + bPerformanceData.setTime1024StatesL(pmr.getTime1024StatesL()); + bPerformanceData.setTime2048States(pmr.getTime2048States()); + bPerformanceData.setTime2048StatesL(pmr.getTime2048StatesL()); + bPerformanceData.setTime4096States(pmr.getTime4096States()); + bPerformanceData.setTime4096StatesL(pmr.getTime4096StatesL()); + bPerformanceData.setTime8192States(pmr.getTime8192States()); + bPerformanceData.setTime8192StatesL(pmr.getTime8192StatesL()); + bPerformanceData.setSnirMin(pmr.getSnirMin()); + bPerformanceData.setSnirMax(pmr.getSnirMax()); + bPerformanceData.setSnirAvg(pmr.getSnirAvg()); + bPerformanceData.setXpdMin(pmr.getXpdMin()); + bPerformanceData.setXpdMax(pmr.getXpdMax()); + bPerformanceData.setXpdAvg(pmr.getXpdAvg()); + bPerformanceData.setRfTempMin(pmr.getRfTempMin()); + bPerformanceData.setRfTempMax(pmr.getRfTempMax()); + bPerformanceData.setRfTempAvg(pmr.getRfTempAvg()); + bPerformanceData.setDefectBlocksSum(pmr.getDefectBlocksSum()); + this.setPerformanceData(bPerformanceData.build()); + } + } + + /** + * Move data to generic type + * @param nodeId of node + * @param lp to get data from + * @param pmRecord data itself + */ + public PerformanceDataAirInterface180907Builder(NodeId nodeId, Lp lp, ContainerHistoricalPerformanceTypeG pmRecord) { + this(nodeId, lp, (OtnHistoryDataG) pmRecord); + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.container.historical.performance.type.g.PerformanceData pmr = pmRecord + .getPerformanceData(); + if (pmr != null) { + PerformanceDataBuilder bPerformanceData = new PerformanceDataBuilder(); + bPerformanceData.setTimePeriod(pmr.getTimePeriod()); + bPerformanceData.setTxEthernetBytesMaxM(pmr.getTxEthernetBytesMaxM()); + bPerformanceData.setTxEthernetBytesMaxS(pmr.getTxEthernetBytesMaxS()); + bPerformanceData.setTxEthernetBytesSum(pmr.getTxEthernetBytesSum()); + this.setPerformanceData(bPerformanceData.build()); + } + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface181010Builder.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface181010Builder.java new file mode 100644 index 000000000..2b80a13ad --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface181010Builder.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ifpac.microwave.pm; + +import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.Helper; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceHistoricalPerformanceTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerHistoricalPerformanceTypeG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performance.type.g.PerformanceData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceConfiguration; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.GranularityPeriodType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntityBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.pmdata.entity.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; + +public class PerformanceDataAirInterface181010Builder extends PmdataEntityBuilder { + + private PerformanceDataAirInterface181010Builder(NodeId nodeId, Lp lp, OtnHistoryDataG pmRecord) { + super(); + Optional<GranularityPeriodType> gp = GranularityPeriodType.forName(Helper.nnGetGranularityPeriodType(pmRecord.getGranularityPeriod()).getName()); + this.setGranularityPeriod(gp.orElse(GranularityPeriodType.Unknown)); + this.setUuidInterface(Helper.nnGetUniversalId(lp.getUuid()).getValue()); + this.setLayerProtocolName(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue()); + this.setNodeName(nodeId.getValue()); + this.setScannerId(pmRecord.getHistoryDataId()); + this.setTimeStamp(pmRecord.getPeriodEndTime()); + this.setSuspectIntervalFlag(pmRecord.isSuspectIntervalFlag()); + } + + /** + * Move data to generic type + * @param nodeId of node + * @param lp to get data from + * @param pmRecord data itself + * @param airConfiguration configuration for additional parameter + */ + public PerformanceDataAirInterface181010Builder(NodeId nodeId, Lp lp, AirInterfaceHistoricalPerformanceTypeG pmRecord, + AirInterfaceConfiguration airConfiguration) { + this(nodeId, lp, pmRecord); + + this.setRadioSignalId(airConfiguration.getRadioSignalId()); + PerformanceData pmr = pmRecord.getPerformanceData(); + if (pmr != null) { + PerformanceDataBuilder bPerformanceData = new PerformanceDataBuilder(); + bPerformanceData.setTimePeriod(pmr.getTimePeriod()); + bPerformanceData.setEs(pmr.getEs()); + bPerformanceData.setSes(pmr.getSes()); + bPerformanceData.setCses(pmr.getCses()); + bPerformanceData.setUnavailability(pmr.getUnavailability()); + bPerformanceData.setTxLevelMin(pmr.getTxLevelMin()); + bPerformanceData.setTxLevelMax(pmr.getTxLevelMax()); + bPerformanceData.setTxLevelAvg(pmr.getTxLevelAvg()); + bPerformanceData.setRxLevelMin(pmr.getRxLevelMin()); + bPerformanceData.setRxLevelMax(pmr.getRxLevelMax()); + bPerformanceData.setRxLevelAvg(pmr.getRxLevelAvg()); + bPerformanceData.setTime2States(pmr.getTime2States()); + bPerformanceData.setTime4StatesS(pmr.getTime4StatesS()); + bPerformanceData.setTime4States(pmr.getTime4States()); + bPerformanceData.setTime8States(pmr.getTime8States()); + bPerformanceData.setTime16StatesS(pmr.getTime16StatesS()); + bPerformanceData.setTime16States(pmr.getTime16States()); + bPerformanceData.setTime32States(pmr.getTime32States()); + bPerformanceData.setTime64States(pmr.getTime64States()); + bPerformanceData.setTime128States(pmr.getTime128States()); + bPerformanceData.setTime256States(pmr.getTime256States()); + bPerformanceData.setTime512States(pmr.getTime512States()); + bPerformanceData.setTime512StatesL(pmr.getTime512StatesL()); + bPerformanceData.setTime1024States(pmr.getTime1024States()); + bPerformanceData.setTime1024StatesL(pmr.getTime1024StatesL()); + bPerformanceData.setTime2048States(pmr.getTime2048States()); + bPerformanceData.setTime2048StatesL(pmr.getTime2048StatesL()); + bPerformanceData.setTime4096States(pmr.getTime4096States()); + bPerformanceData.setTime4096StatesL(pmr.getTime4096StatesL()); + bPerformanceData.setTime8192States(pmr.getTime8192States()); + bPerformanceData.setTime8192StatesL(pmr.getTime8192StatesL()); + bPerformanceData.setSnirMin(pmr.getSnirMin()); + bPerformanceData.setSnirMax(pmr.getSnirMax()); + bPerformanceData.setSnirAvg(pmr.getSnirAvg()); + bPerformanceData.setXpdMin(pmr.getXpdMin()); + bPerformanceData.setXpdMax(pmr.getXpdMax()); + bPerformanceData.setXpdAvg(pmr.getXpdAvg()); + bPerformanceData.setRfTempMin(pmr.getRfTempMin()); + bPerformanceData.setRfTempMax(pmr.getRfTempMax()); + bPerformanceData.setRfTempAvg(pmr.getRfTempAvg()); + bPerformanceData.setDefectBlocksSum(pmr.getDefectBlocksSum()); + this.setPerformanceData(bPerformanceData.build()); + } + } + + /** + * Move data to generic type + * @param nodeId of node + * @param lp to get data from + * @param pmRecord data itself + */ + public PerformanceDataAirInterface181010Builder(NodeId nodeId, Lp lp, ContainerHistoricalPerformanceTypeG pmRecord) { + this(nodeId, lp, (OtnHistoryDataG) pmRecord); + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.container.historical.performance.type.g.PerformanceData pmr = pmRecord + .getPerformanceData(); + if (pmr != null) { + PerformanceDataBuilder bPerformanceData = new PerformanceDataBuilder(); + bPerformanceData.setTimePeriod(pmr.getTimePeriod()); + bPerformanceData.setTxEthernetBytesMaxM(pmr.getTxEthernetBytesMaxM()); + bPerformanceData.setTxEthernetBytesMaxS(pmr.getTxEthernetBytesMaxS()); + bPerformanceData.setTxEthernetBytesSum(pmr.getTxEthernetBytesSum()); + this.setPerformanceData(bPerformanceData.build()); + } + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java new file mode 100644 index 000000000..056247941 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.impl; + +import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.FactoryRegistration; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DeviceManagerOnfImpl implements AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerOnfImpl.class); + private static final String APPLICATION_NAME = "DeviceManagerOnf"; + private static final String CONFIGURATIONFILE = "etc/devicemanager-onf.properties"; + + + private NetconfNetworkElementService netconfNetworkElementService; + + private HtDatabaseClient htDatabaseClient; + private Boolean devicemanagerInitializationOk = false; + private FactoryRegistration<ONFCoreNetworkElementFactory> resORan; + + // Blueprint begin + public DeviceManagerOnfImpl() { + LOG.info("Creating provider for {}", APPLICATION_NAME); + resORan = null; + } + + public void setNetconfNetworkElementService(NetconfNetworkElementService netconfNetworkElementService) { + this.netconfNetworkElementService = netconfNetworkElementService; + } + + public void init() throws Exception { + + LOG.info("Session Initiated start {}", APPLICATION_NAME); + + resORan = netconfNetworkElementService.registerNetworkElementFactory(new ONFCoreNetworkElementFactory()); + + + netconfNetworkElementService.writeToEventLog(APPLICATION_NAME, "startup", "done"); + this.devicemanagerInitializationOk = true; + + LOG.info("Session Initiated end. Initialization done {}", devicemanagerInitializationOk); + } + // Blueprint end + + @Override + public void close() throws Exception { + LOG.info("closing ..."); + close(htDatabaseClient); + close(resORan); + LOG.info("closing done"); + } + + /** + * Used to close all Services, that should support AutoCloseable Pattern + * + * @param toClose + * @throws Exception + */ + private void close(AutoCloseable... toCloseList) { + for (AutoCloseable element : toCloseList) { + if (element != null) { + try { + element.close(); + } catch (Exception e) { + LOG.warn("Fail during close: ", e); + } + } + } + } +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/ONFCoreNetworkElementFactory.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/ONFCoreNetworkElementFactory.java new file mode 100644 index 000000000..f9434f88c --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/ONFCoreNetworkElementFactory.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.impl; + +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.OnfMicrowaveModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev170324; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev180907; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev181010; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Basic; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Microwave; +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.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Create a Network Element representation according to the capability + * information. The capabilities are more than an ODL-QName. After the ? other + * terms than "revision" are provided. + * + */ +public class ONFCoreNetworkElementFactory implements NetworkElementFactory { + + private static final Logger log = LoggerFactory.getLogger(ONFCoreNetworkElementFactory.class); + + @Override + public Optional<org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement> create( + @NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) { + + log.info("Enter factory {}", ONFCoreNetworkElementFactory.class.getName(), acessor.getNodeId()); + + Capabilities capabilities = acessor.getCapabilites(); + + if (capabilities.isSupportingNamespaceAndRevision(NetworkElement.QNAME)) { + OnfMicrowaveModel onfMicrowaveModel = null; + + if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)) { + onfMicrowaveModel = new WrapperMicrowaveModelRev170324(acessor, serviceProvider); + } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)) { + onfMicrowaveModel = new WrapperMicrowaveModelRev180907(acessor, serviceProvider); + } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)) { + onfMicrowaveModel = new WrapperMicrowaveModelRev181010(acessor, serviceProvider); + } + + if (onfMicrowaveModel != null) { + return Optional.of(new ONFCoreNetworkElement12Microwave(acessor, serviceProvider, onfMicrowaveModel)); + } else { + return Optional.of(new ONFCoreNetworkElement12Basic(acessor, serviceProvider)); + } + } + + return Optional.empty(); + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElement.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElement.java new file mode 100644 index 000000000..e2371de74 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElement.java @@ -0,0 +1,168 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.impl; + +import java.util.List; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.mdsal.binding.api.MountPoint; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.IetfNetconfNotificationsListener; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfirmedCommit; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEnd; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + */ +public class OnfNetworkElement implements NetworkElement { + + private static final Logger log = LoggerFactory.getLogger(OnfNetworkElement.class); + + private final NetconfAccessor netconfAccessor; + + private final DataProvider databaseService; + + private @NonNull final OnfListener ranListener; + + private ListenerRegistration<NotificationListener> ranListenerRegistrationResult; + + OnfNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) { + log.info("Create {}",OnfNetworkElement.class.getSimpleName()); + this.netconfAccessor = netconfAccess; + this.databaseService = databaseService; + + this.ranListenerRegistrationResult = null; + this.ranListener = new OnfListener(); + + } + + public void initialReadFromNetworkElement() { + } + + @Override + public NetworkElementDeviceType getDeviceType() { + return NetworkElementDeviceType.ORAN; + } + + private void doRegisterNotificationListener(MountPoint mountPoint) { + log.info("Begin register listener for Mountpoint {}", mountPoint.getIdentifier().toString()); + final Optional<NotificationService> optionalNotificationService = mountPoint + .getService(NotificationService.class); + final NotificationService notificationService = optionalNotificationService.get(); + // notificationService.registerNotificationListener(microwaveEventListener); + ranListenerRegistrationResult = notificationService.registerNotificationListener(ranListener); + log.info("End registration listener for Mountpoint {} Listener: {} Result: {}", + mountPoint.getIdentifier().toString(), optionalNotificationService, ranListenerRegistrationResult); + } + + private class OnfListener implements IetfNetconfNotificationsListener { + + @Override + public void onNetconfConfirmedCommit(NetconfConfirmedCommit notification) { + log.info("onNetconfConfirmedCommit ", notification); + } + + @Override + public void onNetconfSessionStart(NetconfSessionStart notification) { + log.info("onNetconfSessionStart ", notification); + } + + @Override + public void onNetconfSessionEnd(NetconfSessionEnd notification) { + log.info("onNetconfSessionEnd ", notification); + } + + @Override + public void onNetconfCapabilityChange(NetconfCapabilityChange notification) { + log.info("onNetconfCapabilityChange ", notification); + } + + @Override + public void onNetconfConfigChange(NetconfConfigChange notification) { + log.info("onNetconfConfigChange (1) {}", notification); + StringBuffer sb = new StringBuffer(); + List<Edit> editList = notification.nonnullEdit(); + for (Edit edit : editList) { + if (sb.length() > 0) { + sb.append(", "); + } + sb.append(edit); + + EventlogBuilder eventlogBuilder = new EventlogBuilder(); + + InstanceIdentifier<?> target = edit.getTarget(); + if (target != null) { + eventlogBuilder.setObjectId(target.toString()); + log.info("TARGET: {} {} {}", target.getClass(), target.getTargetType()); + for (PathArgument pa : target.getPathArguments()) { + log.info("PathArgument {}", pa); + } + } + eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()); + eventlogBuilder.setNewValue(String.valueOf(edit.getOperation())); + databaseService.writeEventLog(eventlogBuilder.build()); + } + log.info("onNetconfConfigChange (2) {}", sb); + } + } + + @Override + public void register() { + } + + @Override + public void deregister() { + } + + + @Override + public NodeId getNodeId() { + return netconfAccessor.getNodeId(); + } + + @Override + public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { + return Optional.empty(); + } + + @Override + public void warmstart() { + } + + @Override + public Optional<NetconfAccessor> getAcessor() { + return Optional.of(netconfAccessor); + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElementFactory.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElementFactory.java new file mode 100644 index 000000000..e086c0ca0 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElementFactory.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.impl; + +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +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.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class OnfNetworkElementFactory implements NetworkElementFactory { + + private static final Logger log = LoggerFactory.getLogger(OnfNetworkElementFactory.class); + + @Override + public Optional<NetworkElement> create(@NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) { + if (acessor.getCapabilites().isSupportingNamespace(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement.QNAME)) { + log.info("Create device {} ",OnfNetworkElement.class.getName()); + return Optional.of(new OnfNetworkElement(acessor, serviceProvider.getDataProvider())); + } else { + return Optional.empty(); + } + } +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Base.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Base.java new file mode 100644 index 000000000..48f1ebba6 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Base.java @@ -0,0 +1,436 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ne; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CopyOnWriteArrayList; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.NetworkElementCoreData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.WrapperPTPModelRev170208; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment.ONFCoreNetworkElement12Equipment; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.Helper; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev181010; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationDcae; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.mdsal.binding.api.MountPoint; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.pac.NetworkElementCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * This class contains the ONF Core model Version 1.2 related functions.<br> + * Provides the basic ONF Core Model function.<br> + * - initialReadFromNetworkElement is not implemented in child classes. + */ +public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementBase implements NetworkElementCoreData { + + private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Base.class); + + protected static final @NonNull List<Extension> EMPTYLTPEXTENSIONLIST = new ArrayList<>(); + // private static final List<Ltp> EMPTYLTPLIST = new ArrayList<>(); + + protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier + .builder(NetworkElement.class).build(); + + + /*----------------------------------------------------------------------------- + * Class members + */ + + // Non specific part. Used by all functions. + /** interfaceList is used by PM task and should be synchronized */ + @SuppressWarnings("null") + private final @NonNull List<Lp> interfaceList = Collections.synchronizedList(new CopyOnWriteArrayList<>()); + private Optional<NetworkElement> optionalNe; + + // Performance monitoring specific part + /** Lock for the PM access specific elements that could be null */ + private final @NonNull Object pmLock = new Object(); + protected @Nullable Iterator<Lp> interfaceListIterator = null; + /** Actual pmLp used during iteration over interfaces */ + protected @Nullable Lp pmLp = null; + + // Device monitoring specific part + /** Lock for the DM access specific elements that could be null */ + protected final @NonNull Object dmLock = new Object(); + + protected final boolean isNetworkElementCurrentProblemsSupporting12; + + protected final ONFCoreNetworkElement12Equipment equipment; + + protected final NodeId nodeId; + + /*--------------------------------------------------------------- + * Constructor + */ + + protected ONFCoreNetworkElement12Base(@NonNull NetconfAccessor acessor) { + super(acessor); + this.optionalNe = Optional.empty(); + this.nodeId = getAcessor().get().getNodeId(); + this.isNetworkElementCurrentProblemsSupporting12 = acessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME); + this.equipment = new ONFCoreNetworkElement12Equipment(acessor, this, acessor.getCapabilites()); + WrapperPTPModelRev170208.initSynchronizationExtension(acessor); + LOG.debug("support necurrent-problem-list={}", this.isNetworkElementCurrentProblemsSupporting12); + } + + /*--------------------------------------------------------------- + * Getter/ Setter + */ + + @Override + public Optional<NetworkElement> getOptionalNetworkElement() { + return optionalNe; + } + + List<Lp> getInterfaceList() { + return interfaceList; + } + + public Object getPmLock() { + return pmLock; + } + + /*--------------------------------------------------------------- + * Core model related function + */ + + /** + * Get uuid of Optional NE. + * + * @return Uuid or EMPTY String if optionNE is not available + */ + protected String getUuId() { + String uuid = optionalNe.isPresent() ? Helper.nnGetUniversalId(optionalNe.get().getUuid()).getValue() : EMPTY; + return uuid; + } + + /** + * Read from NetworkElement and verify LTPs have changed. If the NE has changed, update to the new + * structure. From initial state it changes also. + */ + protected synchronized boolean readNetworkElementAndInterfaces() { + + LOG.debug("Update mountpoint if changed {}", getMountPointNodeName()); + + optionalNe = Optional.ofNullable(getGenericTransactionUtils().readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL, + NETWORKELEMENT_IID)); + synchronized (pmLock) { + boolean change = false; + + if (!optionalNe.isPresent()) { + LOG.debug("Unable to read NE data for mountpoint {}", getMountPointNodeName()); + if (!interfaceList.isEmpty()) { + interfaceList.clear(); + interfaceListIterator = null; + change = true; + } + + } else { + NetworkElement ne = optionalNe.get(); + LOG.debug("Mountpoint '{}' NE-Name '{}'", getMountPointNodeName(), ne.getName()); + List<Lp> actualInterfaceList = getLtpList(ne); + if (!interfaceList.equals(actualInterfaceList)) { + LOG.debug("Mountpoint '{}' Update LTP List. Elements {}", getMountPointNodeName(), + actualInterfaceList.size()); + interfaceList.clear(); + interfaceList.addAll(actualInterfaceList); + interfaceListIterator = null; + change = true; + } + } + return change; + } + } + + /** + * Get List of UUIDs for conditional packages from Networkelement<br> + * Possible interfaces are:<br> + * MWPS, LTP(MWPS-TTP), MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface<br> + * ETH-CTP,LTP(Client), MW_EthernetContainer_Pac<br> + * MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac, + * MicrowaveModel-ObjectClasses-AirInterfaceDiversity<br> + * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-HybridMwStructure<br> + * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-PureEthernetStructure<br> + * + * @param ne NetworkElement + * @return Id List, never null. + */ + + private static List<Lp> getLtpList(@Nullable NetworkElement ne) { + + List<Lp> res = Collections.synchronizedList(new ArrayList<Lp>()); + + if (ne != null) { + List<Ltp> ltpRefList = ne.getLtp(); + if (ltpRefList == null) { + LOG.debug("DBRead NE-Interfaces: null"); + } else { + for (Ltp ltRefListE : ltpRefList) { + List<Lp> lpList = ltRefListE.getLp(); + if (lpList == null) { + LOG.debug("DBRead NE-Interfaces Reference List: null"); + } else { + for (Lp ltp : lpList) { + res.add(ltp); + } + } + } + } + } else { + LOG.debug("DBRead NE: null"); + } + + // ---- Debug + if (LOG.isDebugEnabled()) { + StringBuffer strBuf = new StringBuffer(); + for (Lp ltp : res) { + if (strBuf.length() > 0) { + strBuf.append(", "); + } + strBuf.append(Helper.nnGetLayerProtocolName(ltp.getLayerProtocolName()).getValue()); + strBuf.append(':'); + strBuf.append(Helper.nnGetUniversalId(ltp.getUuid()).getValue()); + } + LOG.debug("DBRead NE-Interfaces: {}", strBuf.toString()); + } + // ---- Debug end + + return res; + } + + /** + * Read current problems of AirInterfaces and EthernetContainer according to NE status into DB + * + * @return List with all problems + */ + protected FaultData readAllCurrentProblemsOfNode() { + + // Step 2.3: read the existing faults and add to DB + FaultData resultList = new FaultData(); + int idxStart; // Start index for debug messages + UniversalId uuid; + + synchronized (pmLock) { + for (Lp lp : interfaceList) { + + idxStart = resultList.size(); + uuid = lp.getUuid(); + FaultData.debugResultList(LOG, uuid.getValue(), resultList, idxStart); + + } + } + + // Step 2.4: Read other problems from mountpoint + if (isNetworkElementCurrentProblemsSupporting12) { + idxStart = resultList.size(); + readNetworkElementCurrentProblems12(resultList); + FaultData.debugResultList(LOG, "CurrentProblems12", resultList, idxStart); + } + + return resultList; + + } + + /** + * Reading problems for the networkElement V1.2 + * @param resultList to collect the problems + * @return resultList with additonal problems + */ + protected FaultData readNetworkElementCurrentProblems12(FaultData resultList) { + + LOG.info("DBRead Get {} NetworkElementCurrentProblems12", getMountPointNodeName()); + + InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac> networkElementCurrentProblemsIID = + InstanceIdentifier.builder( + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac.class) + .build(); + + // Step 2.3: read to the config data store + NetworkElementPac problemPac; + NetworkElementCurrentProblems problems = null; + try { + problemPac = getGenericTransactionUtils().readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL, + networkElementCurrentProblemsIID); + if (problemPac != null) { + problems = problemPac.getNetworkElementCurrentProblems(); + } + if (problems == null) { + LOG.debug("DBRead no NetworkElementCurrentProblems12"); + } else { + for (org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.current.problems.g.CurrentProblemList problem : problems + .nonnullCurrentProblemList()) { + resultList.add(nodeId, problem.getSequenceNumber(), problem.getTimeStamp(), + problem.getObjectReference(), problem.getProblemName(), + WrapperMicrowaveModelRev181010.mapSeverity(problem.getProblemSeverity())); + } + } + } catch (Exception e) { + LOG.warn("DBRead {} NetworkElementCurrentProblems12 not supported. Message '{}' ", getMountPointNodeName(), + e.getMessage()); + } + return resultList; + } + + /*--------------------------------------------------------------- + * Device Monitor + */ + + @Override + public boolean checkIfConnectionToMediatorIsOk() { + synchronized (dmLock) { + return optionalNe != null; + } + } + + /* + * New implementation to interpret status with empty LTP List as notConnected => return false + * 30.10.2018 Since this behavior is very specific and implicit for specific NE Types + * it needs to be activated by extension or configuration. Change to be disabled at the moment + */ + @Override + public boolean checkIfConnectionToNeIsOk() { + return true; + } + + /*--------------------------------------------------------------- + * Synchronization + */ + + + /*--------------------------------------------------------------- + * Equipment related functions + */ + + @Override + public @NonNull InventoryInformationDcae getInventoryInformation(String layerProtocolFilter) { + LOG.debug("request inventory information. filter:" + layerProtocolFilter); + return this.equipment.getInventoryInformation(getFilteredInterfaceUuidsAsStringList(layerProtocolFilter)); + } + + @Override + public InventoryInformationDcae getInventoryInformation() { + return getInventoryInformation(null); + } + + protected List<String> getFilteredInterfaceUuidsAsStringList(String layerProtocolFilter) { + List<String> uuids = new ArrayList<>(); + + LOG.debug("request inventory information. filter:" + layerProtocolFilter); + if (optionalNe != null) { + // uuids + for (Lp lp : this.interfaceList) { + if (layerProtocolFilter == null || layerProtocolFilter.isEmpty()) { + uuids.add(Helper.nnGetUniversalId(lp.getUuid()).getValue()); + } else if (layerProtocolFilter.equals(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue())) { + uuids.add(Helper.nnGetUniversalId(lp.getUuid()).getValue()); + } + } + } + LOG.debug("uuids found: {}", uuids); + return uuids; + } + + + /*--------------------------------------------------------------- + * Performancemanagement specific interface + */ + + @Override + public void resetPMIterator() { + synchronized (pmLock) { + interfaceListIterator = interfaceList.iterator(); + } + LOG.debug("PM reset iterator"); + } + + @SuppressWarnings("null") + @Override + public boolean hasNext() { + boolean res; + synchronized (pmLock) { + res = interfaceListIterator != null ? interfaceListIterator.hasNext() : false; + } + LOG.debug("PM hasNext LTP {}", res); + return res; + } + + @SuppressWarnings("null") + @Override + public void next() { + synchronized (pmLock) { + if (interfaceListIterator == null) { + pmLp = null; + LOG.debug("PM next LTP null"); + } else { + pmLp = interfaceListIterator.next(); + LOG.debug("PM next LTP {}", Helper.nnGetLayerProtocolName(pmLp.getLayerProtocolName()).getValue()); + } + } + } + + @SuppressWarnings("null") + @Override + public String pmStatusToString() { + StringBuffer res = new StringBuffer(); + synchronized (pmLock) { + res.append(pmLp == null ? "no interface" : Helper.nnGetLayerProtocolName(pmLp.getLayerProtocolName()).getValue()); + for (Lp lp : getInterfaceList()) { + res.append("IF:"); + res.append(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue()); + res.append(" "); + } + } + return res.toString(); + } + + @Override + public void doRegisterEventListener(MountPoint mountPoint) { + //Do nothing + } + + @SuppressWarnings("unchecked") + @Override + public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { + return clazz.isInstance(this) ? Optional.of((L)this) : Optional.empty(); + } + + @Override + public Optional<PerformanceDataLtp> getLtpHistoricalPerformanceData() { + return Optional.empty(); + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java new file mode 100644 index 000000000..fb73b823e --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java @@ -0,0 +1,212 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ne; + +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.AaiService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EventHandlingService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.MaintenanceService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.PerformanceManager; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Get information over NETCONF device according to ONF Coremodel. Read networkelement and + * conditional packages. + * + * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP), + * MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client), + * MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac, + * MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP), + * ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP), + * ,MicrowaveModel-ObjectClasses-PureEthernetStructure + * + * @author herbert + * + */ +public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base { + + private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Basic.class); + + /*----------------------------------------------------------------------------- + * Class members + */ + private final @NonNull FaultService faultService; + private final @NonNull EquipmentService equipmentService; + private final @NonNull MaintenanceService maintenanceService; + private final @NonNull AaiService aaiProviderClient; + private final @NonNull PerformanceManager performanceManager; + private final @NonNull EventHandlingService eventListenerHandler; + + + private final @NonNull String mountPointNodeName; + private final @NonNull NetconfAccessor acessor; + + /*----------------------------------------------------------------------------- + * Construction + */ + + /** + * Basic element for netconf device with ONF Core model V1.2 + * @param acessor to manage device connection + * @param serviceProvider to get devicemanager services + */ + public ONFCoreNetworkElement12Basic(@NonNull NetconfAccessor acessor, + @NonNull DeviceManagerServiceProvider serviceProvider) { + + super(acessor); + this.mountPointNodeName = acessor.getNodeId().getValue(); + this.acessor = acessor; + + this.faultService = serviceProvider.getFaultService(); + this.equipmentService = serviceProvider.getEquipmentService(); + this.maintenanceService = serviceProvider.getMaintenanceService(); + this.aaiProviderClient = serviceProvider.getAaiService(); + this.performanceManager = serviceProvider.getPerformanceManagerService(); + this.eventListenerHandler = serviceProvider.getEventHandlingService(); + + + } + + /*----------------------------------------------------------------------------- + * Functions + */ + + /** + * DeviceMonitor Prepare check by updating NE state and reading all interfaces. + */ + @Override + public void prepareCheck() { + synchronized (dmLock) { + boolean change = readNetworkElementAndInterfaces(); + if (change) { + int problems = faultService.removeAllCurrentProblemsOfNode(nodeId); + FaultData resultList = readAllCurrentProblemsOfNode(); + faultService.initCurrentProblemStatus(nodeId, resultList); + LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountPointNodeName(), + getUuId(), problems, resultList.size()); + } + } + } + + // public boolean checkIfConnectionToMediatorIsOk() -> Shifted to super class + // public boolean checkIfConnectionToNeIsOk() -> Shifted to super class + + /*----------------------------------------------------------------------------- + * Synchronization + */ + + // public void initSynchronizationExtension() -> Shifted to super class + // private InstanceList readPTPClockInstances() -> Shifted to super class + + + /*----------------------------------------------------------------------------- + * Problem/Fault related functions + */ + + /** + * Read during startup all relevant structure and status parameters from device + */ + @Override + public synchronized void initialReadFromNetworkElement() { + // optionalNe.getLtp().get(0).getLp(); + LOG.debug("Get info about {}", getMountPointNodeName()); + + int problems = faultService.removeAllCurrentProblemsOfNode(nodeId); + LOG.debug("Removed all {} problems from database at registration", problems); + + // Step 2.1: access data broker within this mount point + LOG.debug("DBRead start"); + + // Step 2.2: read ne from data store + readNetworkElementAndInterfaces(); + equipment.readNetworkElementEquipment(); + + // Step 2.3: read the existing faults and add to DB + FaultData resultList = readAllCurrentProblemsOfNode(); + equipment.addProblemsofNode(resultList); + + faultService.initCurrentProblemStatus(nodeId, resultList); + equipmentService.writeEquipment(equipment.getEquipmentData()); + + LOG.info("Found info at {} for device {} number of problems: {}", getMountPointNodeName(), getUuId(), + resultList.size()); + } + + /** + * Remove all entries from list + */ + @Override + public int removeAllCurrentProblemsOfNode() { + return faultService.removeAllCurrentProblemsOfNode(nodeId); + } + + @Override + public void register() { + + // Setup microwaveEventListener for notification service + // MicrowaveEventListener microwaveEventListener = new + // MicrowaveEventListener(mountPointNodeName, websocketmanagerService, + // xmlMapper, databaseClientEvents); + doRegisterEventListener(acessor.getMountpoint()); + + // Register netconf stream + acessor.registerNotificationsStream(NetconfAccessor.DefaultNotificationsStream); + + // -- Read data from NE + initialReadFromNetworkElement(); + + // create automatic empty maintenance entry into db before reading and listening + // for problems + maintenanceService.createIfNotExists(mountPointNodeName); + + aaiProviderClient.onDeviceRegistered(mountPointNodeName); + // -- Register NE to performance manager + performanceManager.registration(mountPointNodeName, this); + + eventListenerHandler.registration(mountPointNodeName, acessor.getNetconfNode()); + eventListenerHandler.connectIndication(mountPointNodeName, getDeviceType()); + LOG.info("Starting Event listener finished. Added Netconf device:{} type:{}", mountPointNodeName, getDeviceType()); + + } + + + @Override + public void deregister() { + maintenanceService.deleteIfNotRequired(mountPointNodeName); + performanceManager.deRegistration(mountPointNodeName); + aaiProviderClient.onDeviceUnregistered(mountPointNodeName); + } + + @Override + public void close() throws Exception { + } + + + @Override + public NetworkElementDeviceType getDeviceType() { + return NetworkElementDeviceType.Optical; + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Microwave.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Microwave.java new file mode 100644 index 000000000..c90e76efc --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Microwave.java @@ -0,0 +1,398 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ne; + +import java.util.List; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.Helper; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.OnfMicrowaveModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.notifications.NotificationActor; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.notifications.NotificationWorker; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService; +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.NetconfAccessor; +import org.opendaylight.mdsal.binding.api.MountPoint; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.yang.common.QName; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Get information over NETCONF device according to ONF Coremodel. Read networkelement and + * conditional packages. + * + * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP), + * MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client), + * MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac, + * MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP), + * ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP), + * ,MicrowaveModel-ObjectClasses-PureEthernetStructure + * + * @author herbert + * + */ +public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Basic + implements NotificationActor<EventlogEntity> { + + private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Microwave.class); + + private final @NonNull FaultService microwaveEventListener; + private final @NonNull EquipmentService equipmentService; + private final @NonNull OnfMicrowaveModel microwaveModel; + private final NotificationWorker<EventlogEntity> notificationQueue; + + private ListenerRegistration<NotificationListener> listenerRegistrationresult = null; + + /*----------------------------------------------------------------------------- + * Construction + */ + + /** + * Constructor + * @param acessor for device + * @param serviceProvider to get services + * @param onfMicrowaveModel handling ofmicrosoft model data + */ + public ONFCoreNetworkElement12Microwave(@NonNull NetconfAccessor acessor, + @NonNull DeviceManagerServiceProvider serviceProvider, @NonNull OnfMicrowaveModel onfMicrowaveModel) { + + super(acessor, serviceProvider); + this.microwaveModel = onfMicrowaveModel; + + this.microwaveEventListener = serviceProvider.getFaultService(); + this.equipmentService = serviceProvider.getEquipmentService(); + + this.notificationQueue = new NotificationWorker<>(1, 100, this); + this.microwaveModel.setNotificationQueue(notificationQueue); + + } + + /*----------------------------------------------------------------------------- + * Functions + */ + + /** + * DeviceMonitor Prepare check by updating NE state and reading all interfaces. + */ + @Override + public void prepareCheck() { + synchronized (dmLock) { + boolean change = readNetworkElementAndInterfaces(); + if (change) { + int problems = microwaveEventListener.removeAllCurrentProblemsOfNode(nodeId); + FaultData resultList = readAllCurrentProblemsOfNode(); + microwaveEventListener.initCurrentProblemStatus(nodeId, resultList); + LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountPointNodeName(), + getUuId(), problems, resultList.size()); + } + } + } + + // public boolean checkIfConnectionToMediatorIsOk() -> Shifted to super class + // public boolean checkIfConnectionToNeIsOk() -> Shifted to super class + + /*----------------------------------------------------------------------------- + * Synchronization + */ + + // public void initSynchronizationExtension() -> Shifted to super class + // private InstanceList readPTPClockInstances() -> Shifted to super class + + /*----------------------------------------------------------------------------- + * Services for NE/Device synchronization + */ + + /** + * Handling of specific Notifications from NE, indicating changes and need for synchronization. + * + * <attribute-value-changed-notification xmlns="urn:onf:params:xml:ns:yang:microwave-model"> + * <attribute-name>/equipment-pac/equipment-current-problems</attribute-name> + * <object-id-ref>CARD-1.1.1.0</object-id-ref> <new-value></new-value> + * </attribute-value-changed-notification> + * <attribute-value-changed-notification xmlns="urn:onf:params:xml:ns:yang:microwave-model"> + * <attribute-name>/network-element/extension[value-name="top-level-equipment"]/value</attribute-name> + * <object-id-ref>Hybrid-Z</object-id-ref> + * <new-value>SHELF-1.1.0.0,IDU-1.55.0.0,ODU-1.56.0.0,IDU-1.65.0.0</new-value> + * </attribute-value-changed-notification> + */ + @Override + public void notificationActor(@NonNull EventlogEntity notification) { + + LOG.debug("Enter change notification listener"); + if (LOG.isTraceEnabled()) { + LOG.trace("Notification: {}", notification); + } + String attributeName = notification.getAttributeName(); + if (attributeName != null) { + if (attributeName.equals("/equipment-pac/equipment-current-problems")) { + syncEquipmentPac(notification.getObjectId()); + } else if (attributeName.equals("/network-element/extension[value-name=\"top-level-equipment\"]/value")) { + initialReadFromNetworkElement(); + } + } + LOG.debug("Leave change notification listener"); + } + + /** + * Synchronize problems for a specific equipment-pac + * + * @param uuidString of the equipment-pac + */ + private synchronized void syncEquipmentPac(String uuidString) { + + int problems = microwaveEventListener.removeObjectsCurrentProblemsOfNode(nodeId, uuidString); + LOG.debug("Removed {} problems for uuid {}", problems, uuidString); + + FaultData resultList = equipment.addProblemsofNodeObject(uuidString); + microwaveEventListener.initCurrentProblemStatus(nodeId, resultList); + LOG.debug("Added {} problems for uuid {}", resultList.size(), uuidString); + + } + + + /*----------------------------------------------------------------------------- + * Problem/Fault related functions + */ + + /** + * Read during startup all relevant structure and status parameters from device + */ + @Override + public synchronized void initialReadFromNetworkElement() { + // optionalNe.getLtp().get(0).getLp(); + LOG.debug("Get info about {}", getMountPointNodeName()); + + int problems = microwaveEventListener.removeAllCurrentProblemsOfNode(nodeId); + LOG.debug("Removed all {} problems from database at registration", problems); + + // Step 2.1: access data broker within this mount point + LOG.debug("DBRead start"); + + // Step 2.2: read ne from data store + readNetworkElementAndInterfaces(); + equipment.readNetworkElementEquipment(); + + // Step 2.3: read the existing faults and add to DB + FaultData resultList = readAllCurrentProblemsOfNode(); + equipment.addProblemsofNode(resultList); + + microwaveEventListener.initCurrentProblemStatus(nodeId, resultList); + equipmentService.writeEquipment(equipment.getEquipmentData()); + + LOG.info("Found info at {} for device {} number of problems: {}", getMountPointNodeName(), getUuId(), + resultList.size()); + } + + /** + * LOG the newly added problems of the interface pac + * + * @param idxStart + * @param uuid + * @param resultList + */ + private void debugResultList(String uuid, FaultData resultList, int idxStart) { + if (LOG.isDebugEnabled()) { + StringBuffer sb = new StringBuffer(); + int idx = 0; + for (int t = idxStart; t < resultList.size(); t++) { + sb.append(idx++); + sb.append(":{"); + sb.append(resultList.get(t)); + sb.append('}'); + } + LOG.debug("Found problems {} {}", uuid, sb.toString()); + } + } + + /** + * Read current problems of AirInterfaces and EthernetContainer according to NE status into DB + * + * @return List with all problems + */ + @Override + protected FaultData readAllCurrentProblemsOfNode() { + + // Step 2.3: read the existing faults and add to DB + FaultData resultList = new FaultData(); + int idxStart; // Start index for debug messages + @NonNull UniversalId uuid; + + synchronized (getPmLock()) { + for (Lp lp : getInterfaceList()) { + + idxStart = resultList.size(); + uuid = Helper.nnGetUniversalId(lp.getUuid()); + Class<?> lpClass = getLpExtension(lp); + + ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(lp.getLayerProtocolName()); + microwaveModel.readTheFaultsOfMicrowaveModel(lpName, lpClass, uuid, resultList); + debugResultList(uuid.getValue(), resultList, idxStart); + } + } + + // Step 2.4: Read other problems from mountpoint + if (isNetworkElementCurrentProblemsSupporting12) { + idxStart = resultList.size(); + readNetworkElementCurrentProblems12(resultList); + debugResultList("CurrentProblems12", resultList, idxStart); + } + + return resultList; + + } + + /** + * Get from LayerProtocolExtensions the related generated ONF Interface PAC class which represents it. + * + * @param lp logical termination point + * @return Class of InterfacePac + */ + @Nullable + private Class<?> getLpExtension(@Nullable Lp lp) { + + String capability = EMPTY; + String revision = EMPTY; + String conditionalPackage = EMPTY; + Class<?> res = null; + + if (lp != null) { + for (Extension e : getExtensionList(lp)) { + String valueName = e.getValueName(); + if (valueName != null) { + if (valueName.contentEquals("capability")) { + capability = e.getValue(); + if (capability != null) { + int idx = capability.indexOf("?"); + if (idx != -1) { + capability = capability.substring(0, idx); + } + } + } + if (valueName.contentEquals("revision")) { + revision = e.getValue(); + } + if (valueName.contentEquals("conditional-package")) { + conditionalPackage = e.getValue(); + } + } + } + } + // QName qName = + // org.opendaylight.yangtools.yang.common.QName.create("urn:onf:params:xml:ns:yang:microwave-model", + // "2017-03-24", "mw-air-interface-pac").intern(); + LOG.info("LpExtension capability={} revision={} conditionalPackage={}", capability, revision, + conditionalPackage); + if (!capability.isEmpty() && !revision.isEmpty() && !conditionalPackage.isEmpty()) { + try { + QName qName = QName.create(capability, revision, conditionalPackage); + res = this.microwaveModel.getClassForLtpExtension(qName); + } catch (IllegalArgumentException e) { + LOG.debug("Can not create QName from ({}{}{}): {}", capability, revision, conditionalPackage, + e.getMessage()); + } + } + return res; + } + + /** + * Read element from class that could be not available + * + * @param ltp layer termination point + * @return List with extension parameters or empty list + */ + @NonNull + private static List<Extension> getExtensionList(@Nullable Lp ltp) { + if (ltp != null) { + return ltp.nonnullExtension(); + } else { + return EMPTYLTPEXTENSIONLIST; + } + } + + @Override + public Optional<PerformanceDataLtp> getLtpHistoricalPerformanceData() { + synchronized (getPmLock()) { + if (pmLp != null) { + LOG.debug("Enter query PM"); + @SuppressWarnings("null") + @NonNull + Lp lp = pmLp; + ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(lp.getLayerProtocolName()); + return Optional.of(this.microwaveModel.getLtpHistoricalPerformanceData(lpName, lp)); + } + return Optional.empty(); + } + } + + /** + * Remove all entries from list + */ + @Override + public int removeAllCurrentProblemsOfNode() { + return microwaveEventListener.removeAllCurrentProblemsOfNode(nodeId); + } + + /** + * Register the listener + */ + @Override + public void doRegisterEventListener(MountPoint mountPoint) { + LOG.info("Begin registration listener for Mountpoint"); + final Optional<NotificationService> optionalNotificationService = + mountPoint.getService(NotificationService.class); + final NotificationService notificationService = optionalNotificationService.get(); + // notificationService.registerNotificationListener(microwaveEventListener); + listenerRegistrationresult = + notificationService.registerNotificationListener(microwaveModel.getNotificationListener()); + LOG.info("End registration listener for Mountpoint Result: {}",listenerRegistrationresult); + } + + /*------------------------------------------------------------ + * private function to access database + */ + + /*----------------------------------------------------------------------------- + * Reading problems for the networkElement V1.2 + */ + + @Override + public void close() throws Exception { + if (listenerRegistrationresult != null) { + listenerRegistrationresult.close(); + } + } + + @Override + public NetworkElementDeviceType getDeviceType() { + return NetworkElementDeviceType.Wireless; + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java new file mode 100644 index 000000000..0eb1982b2 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java @@ -0,0 +1,177 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ne; + +import java.util.Optional; +import javax.annotation.Nonnull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ONFCoreNetworkElementRepresentation; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InternalConnectionStatus; +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.TransactionUtils; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionLogStatus; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.network.element.connection.entity.NodeDetailsBuilder; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author herbert + * + */ +@SuppressWarnings("deprecation") +public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCoreNetworkElementRepresentation { + + private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElementBase.class); + + protected static final String EMPTY = ""; + + private final String mountPointNodeName; + private final NodeId nodeId; + private final DataBroker netconfNodeDataBroker; + private final Capabilities capabilities; + private final NetconfAccessor acessor; + + protected ONFCoreNetworkElementBase(NetconfAccessor acessor) { + LOG.info("Create ONFCoreNetworkElementBase"); + this.mountPointNodeName = acessor.getNodeId().getValue(); + this.nodeId = acessor.getNodeId(); + this.netconfNodeDataBroker = acessor.getDataBroker(); + this.capabilities = acessor.getCapabilites(); + this.acessor = acessor; + + } + + @Override + public Optional<NetconfAccessor> getAcessor() { + return Optional.of(acessor); + } + + @Override + public String getMountPointNodeName() { + return mountPointNodeName; + } + + /** + * @return the netconfNodeDataBroker + */ + public DataBroker getNetconfNodeDataBroker() { + return netconfNodeDataBroker; + } + + /** + * @return the capabilities + */ + public Capabilities getCapabilities() { + return capabilities; + } + + /** + * Update devicetype and let all other field empty + * @param deviceType that should be updated + * @return NetworkElementConnectionEntity with related parameter + */ + public static NetworkElementConnectionEntity getNetworkConnectionDeviceTpe(NetworkElementDeviceType deviceType) { + NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); + eb.setDeviceType(deviceType); + return eb.build(); + } + + /** + * Provide device specific data + * @param nodeId mountpoint id + * @param nNode data + * @return NetworkElementConnectionEntity specific information + */ + public static NetworkElementConnectionEntity getNetworkConnection(String nodeId, @Nonnull NetconfNode nNode) { + + NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); + // -- basics + eb.setId(nodeId).setNodeId(nodeId).setDeviceType(NetworkElementDeviceType.Unknown).setIsRequired(false); + + // -- connection status + ConnectionLogStatus status = InternalConnectionStatus.statusFromNodeStatus(nNode.getConnectionStatus()); + eb.setStatus(status); + + // -- capabilites + Capabilities availableCapabilities = Capabilities.getAvailableCapabilities(nNode); + Capabilities unAvailableCapabilities = Capabilities.getUnavailableCapabilities(nNode); + eb.setCoreModelCapability(availableCapabilities.getRevisionForNamespace(NetworkElement.QNAME)); + + NodeDetailsBuilder nodeDetails = new NodeDetailsBuilder() + .setAvailableCapabilities(availableCapabilities.getCapabilities()) + .setUnavailableCapabilities(unAvailableCapabilities.getCapabilities()); + eb.setNodeDetails(nodeDetails.build()); + // -- host information + Host host = nNode.getHost(); + PortNumber portNumber = nNode.getPort(); + if (host != null && portNumber != null) { + eb.setHost(host.stringValue()).setPort(portNumber.getValue().longValue()); + } + + Credentials credentials = nNode.getCredentials(); + if (credentials instanceof LoginPassword) { + LoginPassword loginPassword = (LoginPassword) credentials; + eb.setUsername(loginPassword.getUsername()).setPassword(loginPassword.getPassword()); + } + return eb.build(); + } + + + @Override + public void warmstart() { + int problems = removeAllCurrentProblemsOfNode(); + LOG.debug("Removed all {} problems from database at deregistration for {}", problems, mountPointNodeName); + } + + @Override + public NodeId getNodeId() { + return nodeId; + } + + public TransactionUtils getGenericTransactionUtils() { + return acessor.getTransactionUtils(); + } + + /*--------------------------------------------------------------- + * Getter/ Setter + */ + @Override + public String getMountpoint() { + return mountPointNodeName; + } + + @Override + public DataBroker getDataBroker() { + return netconfNodeDataBroker; + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementEmpty.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementEmpty.java new file mode 100644 index 000000000..ef2636ca8 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementEmpty.java @@ -0,0 +1,170 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.ne; + +import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ONFCoreNetworkElementRepresentation; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationDcae; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.MountPoint; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author herbert + * + */ +public class ONFCoreNetworkElementEmpty implements ONFCoreNetworkElementRepresentation { + + private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElementEmpty.class); + + private final NetconfAccessor acessor; + private final String mountPointNodeName; + private final NodeId nodeId; + + public ONFCoreNetworkElementEmpty(NetconfAccessor acessor, String mountPointNodeName) { + LOG.info("Create {}",ONFCoreNetworkElementEmpty.class.getSimpleName()); + this.mountPointNodeName = mountPointNodeName; + this.nodeId = new NodeId(mountPointNodeName); + this.acessor = acessor; + } + + @Override + public void initialReadFromNetworkElement() { + } + + @Override + public String getMountPointNodeName() { + return mountPointNodeName; + } + + @Override + public String getMountpoint() { + return mountPointNodeName; + } + + @Override + public void resetPMIterator() { + } + + @Override + public boolean hasNext() { + return false; + } + + @Override + public void next() { + } + + @Override + public String pmStatusToString() { + return this.getClass().getSimpleName(); + } + + @Override + public int removeAllCurrentProblemsOfNode() { + return 0; + } + + @Override + public void doRegisterEventListener(MountPoint mointPoint) { + //Do nothing + } + + @Override + public void prepareCheck() { + //Do nothing here + } + + @Override + public boolean checkIfConnectionToMediatorIsOk() { + return true; + } + + @Override + public boolean checkIfConnectionToNeIsOk() { + return true; + } + + @Override + public InventoryInformationDcae getInventoryInformation() { + return InventoryInformationDcae.getDefault(); + } + + @Override + public InventoryInformationDcae getInventoryInformation(String layerProtocolFilter) { + return InventoryInformationDcae.getDefault(); + } + + @Override + public DataBroker getDataBroker() { + return null; + } + + @Override + public Optional<NetworkElement> getOptionalNetworkElement() { + return Optional.empty(); + } + + @Override + public NetworkElementDeviceType getDeviceType() { + return NetworkElementDeviceType.Unknown; + } + + @Override + public void register() { + } + + @Override + public void deregister() { + } + + @Override + public NodeId getNodeId() { + return nodeId; + } + + @Override + public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { + return Optional.empty(); + } + + @Override + public void warmstart() { + } + + @Override + public Optional<NetconfAccessor> getAcessor() { + return Optional.of(acessor); + } + + @Override + public Optional<PerformanceDataLtp> getLtpHistoricalPerformanceData() { + return Optional.empty(); + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationActor.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationActor.java new file mode 100644 index 000000000..e216cff38 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationActor.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.notifications; + +import org.eclipse.jdt.annotation.NonNull; + +public interface NotificationActor<T> { + + public void notificationActor(@NonNull T item); + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationWorker.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationWorker.java new file mode 100644 index 000000000..44fad1b3a --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationWorker.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.notifications; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; + +/** + * Provide a thread that is receiving and process notifications. + * @param <T> represents the object that is provided with a notification and + * forwarded to the NotificationActor<T>. + */ + +public class NotificationWorker<T> implements AutoCloseable { + + private final BlockingQueue<T> workQueue; + private final ExecutorService service; + private final NotificationActor<T> actor; + + public NotificationWorker(int numWorkers, int workQueueSize, NotificationActor<T> actorObject) { + workQueue = new LinkedBlockingQueue<>(workQueueSize); + service = Executors.newFixedThreadPool(numWorkers); + actor = actorObject; + + for (int i=0; i < numWorkers; i++) { + service.submit(new Worker<>(workQueue, actor)); + } + } + + public void put(T item) { + try { + workQueue.put(item); + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } + } + + @Override + public void close() throws Exception { + // TODO Auto-generated method stub + } + + private static class Worker<T> implements Runnable { + private final BlockingQueue<T> workQueue; + private final NotificationActor<T> actor; + + + public Worker(BlockingQueue<T> workQueue, NotificationActor<T> actor) { + this.workQueue = workQueue; + this.actor = actor; + } + + @Override + public void run() { + while (!Thread.currentThread().isInterrupted()) { + try { + T item = workQueue.take(); + if (item != null) { + // Process item + actor.notificationActor(item); + } + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + break; + } + } + } + } + + + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/InternalSeverity.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/InternalSeverity.java new file mode 100644 index 000000000..4326fec32 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/InternalSeverity.java @@ -0,0 +1,191 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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========================================================================== + ******************************************************************************/ +/** + * @author herbert + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util; + + +import org.eclipse.jdt.annotation.Nullable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType; + +public enum InternalSeverity { + + NonAlarmed, + Warning, + Minor, + Major, + Critical; + + public boolean isNoAlarmIndication() { + return this == NonAlarmed; + } + + public String getValueAsString() { + return this.name(); + } + + @Override + public String toString() { + return this.name(); + } + + public String toNetconfString() { + switch (this) { + case NonAlarmed: + return "non-alarmed"; + case Warning: + return "warning"; + case Minor: + return "minor"; + case Major: + return "major"; + case Critical: + return "critical"; + } + return "not-specified"; + } + + public SeverityType toDataProviderSeverityType() { + switch (this) { + case NonAlarmed: + return SeverityType.NonAlarmed; + case Warning: + return SeverityType.Warning; + case Minor: + return SeverityType.Minor; + case Major: + return SeverityType.Major; + case Critical: + return SeverityType.Critical; + } + return null; //Should never happen + } + + /** + * convert ONF 1.2 Severity + * @param severity as input + * @return String with related output + */ + public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.SeverityType severity ) { + switch( severity ) { + case NonAlarmed: + return InternalSeverity.NonAlarmed; + case Warning: + return InternalSeverity.Warning; + case Minor: + return InternalSeverity.Minor; + case Major: + return InternalSeverity.Major; + case Critical: + return InternalSeverity.Critical; + } + return null; + } + + /** + * convert ONF 1.2.1.1 Severity + * @param severity as input + * @return String with related output + */ + public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.SeverityType severity ) { + switch( severity ) { + case NonAlarmed: + return InternalSeverity.NonAlarmed; + case Warning: + return InternalSeverity.Warning; + case Minor: + return InternalSeverity.Minor; + case Major: + return InternalSeverity.Major; + case Critical: + return InternalSeverity.Critical; + } + return null; + } + + /** + * convert ONF 1.2.1.1p Severity + * @param severity as input + * @return String with related output + */ + public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType severity ) { + switch( severity ) { + case NonAlarmed: + return InternalSeverity.NonAlarmed; + case Warning: + return InternalSeverity.Warning; + case Minor: + return InternalSeverity.Minor; + case Major: + return InternalSeverity.Major; + case Critical: + return InternalSeverity.Critical; + } + return null; + } + + + + /** + * convert a text string into Severity + * @param severityString with textes: warning minor major critical non[-]alarmed. (Capital or lowercase) + * @return related enum. Unknown oe illegal are converted to NonAlarm + */ + public static @Nullable InternalSeverity valueOfString(String severityString) { + + switch( severityString.toLowerCase().trim() ) { + case "warning": + return InternalSeverity.Warning; + case "minor": + return InternalSeverity.Minor; + case "major": + return InternalSeverity.Major; + case "critical": + return InternalSeverity.Critical; + } + return InternalSeverity.NonAlarmed; + + } + + /** + * Convert to InternalSeverity + * @param severity to be converted + * @return InternalSeverity, null converted to NonAlarmed + */ + public static InternalSeverity valueOf(@org.eclipse.jdt.annotation.Nullable SeverityType severity) { + if (severity != null) { + switch (severity) { + case NonAlarmed: + return InternalSeverity.NonAlarmed; + case Warning: + return InternalSeverity.Warning; + case Minor: + return InternalSeverity.Minor; + case Major: + return InternalSeverity.Major; + case Critical: + return InternalSeverity.Critical; + } + } + return InternalSeverity.NonAlarmed; + } + + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/ONFLayerProtocolName.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/ONFLayerProtocolName.java new file mode 100644 index 000000000..3fa52e110 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/ONFLayerProtocolName.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.onf.util; + +import org.eclipse.jdt.annotation.NonNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public enum ONFLayerProtocolName { + + MWAirInterface("MWPS"), //V1.0 + V1.2 + EthernetContainer10("ETH-CTP"), //V1.0 + EthernetContainer12("ETC"), //V1.2 + V1.2.1.1 + EthernetPhysical("ETY"), //V1.2 + TDMContainer("TDM"), //V1.2 + Structure("MWS"), //V1.0 + V1.2 + Ethernet("ETH"), //V1.2 + Unknown(""); + + private static final Logger LOG = LoggerFactory.getLogger(ONFLayerProtocolName.class); + + private final String myLayerProtocolName; + + ONFLayerProtocolName( String myLayerProtocolName ) { + this.myLayerProtocolName = myLayerProtocolName; + } + + public boolean is( org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LayerProtocolName onfName ) { + return myLayerProtocolName.equals(onfName.getValue()); + } + + public static @NonNull ONFLayerProtocolName valueOf( org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LayerProtocolName onfName ) { + for (ONFLayerProtocolName protocol : ONFLayerProtocolName.values()) { + if (protocol.is(onfName)) { + return protocol; + } + } + LOG.info("Can not map {}. Use Unknown",onfName.getValue() ); + return Unknown; + } + + public String getValue() { + return myLayerProtocolName; + } + +} + |