import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.NetworkBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.CpToDegree;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.CpToDegreeBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.CpToDegreeKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.NodeInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.NodeInfo.OpenroadmVersion;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.NodeInfoBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.SwitchingPoolLcp;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.SwitchingPoolLcpBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.switching.pool.lcp.NonBlockingList;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.switching.pool.lcp.NonBlockingListBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.NetworkBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.CpToDegree;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.CpToDegreeBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.CpToDegreeKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.NodeInfo.OpenroadmVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.SwitchingPoolLcp;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.SwitchingPoolLcpBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.switching.pool.lcp.NonBlockingList;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.switching.pool.lcp.NonBlockingListBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.Direction;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.PortQual;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.XpdrNodeTypes;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.Direction;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.PortQual;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.XpdrNodeTypes;
// Get value for max Srg from info subtree, required for iteration
// if not present assume to be 20 (temporary)
if (ordmInfo.getMaxSrgs() != null) {
// Get value for max Srg from info subtree, required for iteration
// if not present assume to be 20 (temporary)
if (ordmInfo.getMaxSrgs() != null) {
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (ordmSrgObject.isPresent()) {
srgCps.addAll(ordmSrgObject.get().getCircuitPacks());
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
if (ordmSrgObject.isPresent()) {
srgCps.addAll(ordmSrgObject.get().getCircuitPacks());
List<String> keys = new ArrayList<>();
for (org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.srg.CircuitPacks cp : cpList) {
String circuitPackName = cp.getCircuitPackName();
List<String> keys = new ArrayList<>();
for (org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.srg.CircuitPacks cp : cpList) {
String circuitPackName = cp.getCircuitPackName();
} else if (PortQual.RoadmExternal.getIntValue() == port.getPortQual().getIntValue()
&& Direction.Bidirectional.getIntValue() == port.getPortDirection().getIntValue()
&& !keys.contains(currentKey)) {
} else if (PortQual.RoadmExternal.getIntValue() == port.getPortQual().getIntValue()
&& Direction.Bidirectional.getIntValue() == port.getPortDirection().getIntValue()
&& !keys.contains(currentKey)) {
LOG.info("{} : Logical Connection Point for {} {} is {}", nodeId, circuitPackName,
port.getPortName(), logicalConnectionPoint);
portMapList.add(createMappingObject(nodeId, port, circuitPackName, logicalConnectionPoint));
LOG.info("{} : Logical Connection Point for {} {} is {}", nodeId, circuitPackName,
port.getPortName(), logicalConnectionPoint);
portMapList.add(createMappingObject(nodeId, port, circuitPackName, logicalConnectionPoint));
LOG.info("{} : Logical Connection Point for {} {} is {}", nodeId, circuitPackName,
port.getPortName(), logicalConnectionPoint1);
InstanceIdentifier<Ports> port2ID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
LOG.info("{} : Logical Connection Point for {} {} is {}", nodeId, circuitPackName,
port.getPortName(), logicalConnectionPoint1);
InstanceIdentifier<Ports> port2ID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
== PortQual.RoadmExternal.getIntValue()) {
Ports port2 = port2Object.get();
if (checkPartnerPort(circuitPackName, port, port2)) {
== PortQual.RoadmExternal.getIntValue()) {
Ports port2 = port2Object.get();
if (checkPartnerPort(circuitPackName, port, port2)) {
LOG.info("{} : Logical Connection Point for {} {} is {}", nodeId, circuitPackName,
port2.getPortName(), logicalConnectionPoint2);
portMapList.add(createMappingObject(nodeId, port, circuitPackName,
LOG.info("{} : Logical Connection Point for {} {} is {}", nodeId, circuitPackName,
port2.getPortName(), logicalConnectionPoint2);
portMapList.add(createMappingObject(nodeId, port, circuitPackName,
// Get value for max degree from info subtree, required for iteration
// if not present assume to be 20 (temporary)
if (ordmInfo.getMaxDegrees() != null) {
// Get value for max degree from info subtree, required for iteration
// if not present assume to be 20 (temporary)
if (ordmInfo.getMaxDegrees() != null) {
mpBldr = new MappingBuilder()
.withKey(new MappingKey(logicalConnectionPoint))
.setLogicalConnectionPoint(logicalConnectionPoint)
.setSupportingCircuitPackName(circuitPackName)
.setSupportingPort(port.getPortName())
mpBldr = new MappingBuilder()
.withKey(new MappingKey(logicalConnectionPoint))
.setLogicalConnectionPoint(logicalConnectionPoint)
.setSupportingCircuitPackName(circuitPackName)
.setSupportingPort(port.getPortName())
postPortMapping(nodeId, null, null, cpToDegreeList, null);
Map<Integer, List<ConnectionPorts>> connectionPortMap = getPerDegreePorts(nodeId, deviceInfo);
postPortMapping(nodeId, null, null, cpToDegreeList, null);
Map<Integer, List<ConnectionPorts>> connectionPortMap = getPerDegreePorts(nodeId, deviceInfo);
- LOG.info("Fetching connection-port {} at circuit pack {}", connectionPortMap.get(k).get(0)
- .getPortName().toString(), connectionPortMap.get(k).get(0).getCircuitPackName());
+ LOG.info("Fetching connection-port {} at circuit pack {}", connectionPortMap.get(cpMapEntry.getKey()).get(0)
+ .getPortName().toString(), connectionPortMap.get(cpMapEntry.getKey()).get(0).getCircuitPackName());
Optional<Ports> portObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, portID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
Optional<Ports> portObject = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, portID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- .child(Ports.class, new PortsKey(connectionPortMap.get(k).get(0).getPortName().toString()));
- LOG.info("Fetching connection-port {} at circuit pack {}", connectionPortMap.get(k).get(0)
+ .child(Ports.class, new PortsKey(connectionPortMap.get(cpMapEntry.getKey()).get(0).getPortName().toString()));
+ LOG.info("Fetching connection-port {} at circuit pack {}", connectionPortMap.get(cpMapEntry.getKey()).get(0)
.getPortName().toString(), cp1Name);
Optional<Ports> port1Object = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, port1ID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
InstanceIdentifier<Ports> port2ID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
.child(CircuitPacks.class, new CircuitPacksKey(cp2Name))
.getPortName().toString(), cp1Name);
Optional<Ports> port1Object = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, port1ID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
InstanceIdentifier<Ports> port2ID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
.child(CircuitPacks.class, new CircuitPacksKey(cp2Name))
Optional<Ports> port2Object = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, port2ID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
Optional<Ports> port2Object = this.deviceTransactionManager.getDataFromDevice(nodeId,
LogicalDatastoreType.OPERATIONAL, port2ID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
&& port1.getPartnerPort().getPortName().equals(port2.getPortName())
&& port2.getPartnerPort().getCircuitPackName().equals(cp1Name)
&& port2.getPartnerPort().getPortName().equals(port1.getPortName()))) {
&& port1.getPartnerPort().getPortName().equals(port2.getPortName())
&& port2.getPartnerPort().getCircuitPackName().equals(cp1Name)
&& port2.getPartnerPort().getPortName().equals(port1.getPortName()))) {
+ /**
+ * Implements the FNV-1 128bit algorithm.
+ * https://www.wikiwand.com/en/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#/FNV-1_hash
+ * https://github.com/pmdamora/fnv-cracker-app/blob/master/src/main/java/passwordcrack/cracking/HashChecker.java
+ * @param stringdata the String to be hashed
+ * @return the hash string
+ */
+ private String fnv(String stringdata) {
+ BigInteger hash = FNV_INIT;
+ byte[] data = stringdata.getBytes(StandardCharsets.UTF_8);
+
+ for (byte b : data) {
+ hash = hash.multiply(FNV_PRIME).mod(FNV_MOD);
+ hash = hash.xor(BigInteger.valueOf((int) b & 0xff));
+ }
+
+ return hash.toString(16);
+ }