From 4ef19c0a7cddd25efa5c74c402b5f6b46bb73739 Mon Sep 17 00:00:00 2001 From: "guillaume.lambert" Date: Fri, 20 Jul 2018 17:44:29 +0200 Subject: [PATCH] package ietf-network 2015-06-08 yang models JIRA: NETCONF-550 JIRA: TSC-124 JIRA: TRNSPRTPCE-29 Change-Id: I416422e94a8f684b1246efa21cddb424d2136c11 Co-authored-by: Martial COULIBALY Signed-off-by: guillaume.lambert --- api/src/main/yang/olm@2017-04-18.yang | 2 +- .../common/mapping/PortMappingImpl.java | 8 +- .../OpenRoadmInterfacesImpl.java | 6 +- features/features-transportpce/pom.xml | 4 +- features/odl-transportpce/pom.xml | 8 + .../job/PeriodicDeviceBackupJob.java | 36 ++- .../inventory/listener/DeviceListener.java | 22 +- .../networkmodel/NetConfTopologyListener.java | 6 +- .../networkmodel/NetworkUtilsImpl.java | 18 +- .../networkmodel/R2RLinkDiscovery.java | 9 +- .../networkmodel/Rdm2XpdrLink.java | 5 +- .../service/NetworkModelServiceImpl.java | 13 +- .../networkmodel/util/ClliNetwork.java | 5 +- .../networkmodel/util/OpenRoadmNetwork.java | 8 +- .../networkmodel/util/OpenRoadmTopology.java | 15 +- .../olm/OlmPowerServiceRpcImpl.java | 26 +- .../transportpce/olm/power/PowerMgmt.java | 40 ++- .../olm/service/OlmPowerServiceImpl.java | 38 ++- .../old-ietf-network-topology@2015-06-08.yang | 243 ++++++++++++++++++ .../yang/old-ietf-network@2015-06-08.yang | 144 +++++++++++ ...org-openroadm-clli-network@2017-06-26.yang | 2 +- ...openroadm-network-topology@2017-09-29.yang | 4 +- ...rg-openroadm-network-types@2017-09-29.yang | 2 +- .../org-openroadm-network@2017-09-29.yang | 2 +- ...g-openroadm-opposite-links@2017-09-29.yang | 4 +- ...roadm-otn-network-topology@2017-09-29.yang | 4 +- .../org-openroadm-xponder@2017-09-29.yang | 4 +- .../transportpce/pce/PceCalculation.java | 6 +- .../transportpce/pce/PceLink.java | 6 +- .../transportpce/pce/PceNode.java | 57 ++-- .../transportpce/pce/PcePathDescription.java | 68 +++-- .../pce/impl/PceServiceRPCImpl.java | 12 +- .../renderer/ModelMappingUtils.java | 10 +- .../OpenRoadmInterfaceFactory.java | 3 +- .../DeviceRendererServiceImpl.java | 10 +- .../renderer/rpcs/DeviceRendererRPCImpl.java | 13 +- .../rpcs/TransportPCEServicePathRPCImpl.java | 13 +- .../DeviceRendererServiceImplTest.java | 2 +- .../renderer/stub/OlmServiceStub.java | 14 +- .../renderer/utils/MountPointUtils.java | 2 +- .../renderer/utils/ServiceDataUtils.java | 26 +- .../servicehandler/ModelMappingUtils.java | 14 +- .../impl/ServicehandlerImpl.java | 28 +- .../test/common/DataStoreContextImpl.java | 42 +-- tests/stubpce/pom.xml | 35 +++ .../transportpce/stubpce/TpNodeTp.java | 65 +++-- .../stubpce/impl/StubpceImpl.java | 126 +++++---- .../stubpce/topology/InterNodePath.java | 54 ++-- .../stubpce/topology/SuperNodePath.java | 48 ++-- tests/stubrenderer/pom.xml | 27 ++ .../stubrenderer/impl/StubrendererImpl.java | 87 +++---- 51 files changed, 938 insertions(+), 508 deletions(-) create mode 100644 ordmodels/network/src/main/yang/old-ietf-network-topology@2015-06-08.yang create mode 100644 ordmodels/network/src/main/yang/old-ietf-network@2015-06-08.yang diff --git a/api/src/main/yang/olm@2017-04-18.yang b/api/src/main/yang/olm@2017-04-18.yang index 541b429cc..a0b58126f 100644 --- a/api/src/main/yang/olm@2017-04-18.yang +++ b/api/src/main/yang/olm@2017-04-18.yang @@ -8,7 +8,7 @@ module olm { revision-date 2017-09-07; } - import ietf-network-topology { + import old-ietf-network-topology { prefix ietf-network-topology; revision-date 2015-06-08; } diff --git a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingImpl.java b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingImpl.java index 3dc9f3f6b..a3d10279c 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingImpl.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingImpl.java @@ -9,7 +9,6 @@ package org.opendaylight.transportpce.common.mapping; import com.google.common.util.concurrent.CheckedFuture; - import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; @@ -22,7 +21,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; @@ -405,7 +403,7 @@ public class PortMappingImpl implements PortMapping { private Mapping createMappingObject(String nodeId, Ports port, String circuitPackName, String logicalConnectionPoint) { MappingBuilder mpBldr = new MappingBuilder(); - mpBldr.setKey(new MappingKey(logicalConnectionPoint)).setLogicalConnectionPoint(logicalConnectionPoint) + mpBldr.withKey(new MappingKey(logicalConnectionPoint)).setLogicalConnectionPoint(logicalConnectionPoint) .setSupportingCircuitPackName(circuitPackName).setSupportingPort(port.getPortName()); // Get OMS and OTS interface provisioned on the TTP's @@ -436,7 +434,7 @@ public class PortMappingImpl implements PortMapping { } private static CpToDegree createCpToDegreeObject(String circuitPackName, String degreeNumber) { - return new CpToDegreeBuilder().setKey(new CpToDegreeKey(circuitPackName)).setCircuitPackName(circuitPackName) + return new CpToDegreeBuilder().withKey(new CpToDegreeKey(circuitPackName)).setCircuitPackName(circuitPackName) .setDegreeNumber(new Long(degreeNumber)).build(); } @@ -476,7 +474,7 @@ public class PortMappingImpl implements PortMapping { private boolean postPortMapping(Info deviceInfo, List portMapList, Integer nodeType, List cp2DegreeList) { NodesBuilder nodesBldr = new NodesBuilder(); - nodesBldr.setKey(new NodesKey(deviceInfo.getNodeId())).setNodeId(deviceInfo.getNodeId()); + nodesBldr.withKey(new NodesKey(deviceInfo.getNodeId())).setNodeId(deviceInfo.getNodeId()); nodesBldr.setNodeType(NodeTypes.forValue(nodeType)); if (portMapList != null) { diff --git a/common/src/main/java/org/opendaylight/transportpce/common/openroadminterfaces/OpenRoadmInterfacesImpl.java b/common/src/main/java/org/opendaylight/transportpce/common/openroadminterfaces/OpenRoadmInterfacesImpl.java index d85b36db1..6e1714cf7 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/openroadminterfaces/OpenRoadmInterfacesImpl.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/openroadminterfaces/OpenRoadmInterfacesImpl.java @@ -9,11 +9,9 @@ package org.opendaylight.transportpce.common.openroadminterfaces; import com.google.common.util.concurrent.ListenableFuture; - import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; - import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.transportpce.common.Timeouts; import org.opendaylight.transportpce.common.device.DeviceTransaction; @@ -105,7 +103,7 @@ public class OpenRoadmInterfacesImpl implements OpenRoadmInterfaces { // State admin state to out of service InterfaceBuilder ifBuilder = new InterfaceBuilder(intf2Delete); if (ifBuilder.getType() == OtnOdu.class) { - Interface1Builder oduBuilder = new Interface1Builder(intf2Delete.getAugmentation(Interface1.class)); + Interface1Builder oduBuilder = new Interface1Builder(intf2Delete.augmentation(Interface1.class)); OduBuilder odu = new OduBuilder(oduBuilder.getOdu()); if (odu.getMaintTestsignal() != null) { MaintTestsignalBuilder maintSignalBuilder = @@ -120,7 +118,7 @@ public class OpenRoadmInterfacesImpl implements OpenRoadmInterfaces { .interfaces.rev161014.Interface1Builder otuBuilder = new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu .interfaces.rev161014.Interface1Builder(intf2Delete - .getAugmentation(org.opendaylight.yang.gen.v1 + .augmentation(org.opendaylight.yang.gen.v1 .http.org.openroadm.otn.otu.interfaces.rev161014.Interface1.class)); OtuBuilder otu = new OtuBuilder(otuBuilder.getOtu()); if (otu.getMaintLoopback() != null) { diff --git a/features/features-transportpce/pom.xml b/features/features-transportpce/pom.xml index a9d52281d..e05558d05 100644 --- a/features/features-transportpce/pom.xml +++ b/features/features-transportpce/pom.xml @@ -50,12 +50,12 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL features xml - + diff --git a/features/odl-transportpce/pom.xml b/features/odl-transportpce/pom.xml index 07f6a58f3..b1ceee092 100644 --- a/features/odl-transportpce/pom.xml +++ b/features/odl-transportpce/pom.xml @@ -27,12 +27,20 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL 1.8.0-SNAPSHOT 2.0.7 1.5.0-SNAPSHOT + 1.8.0-SNAPSHOT etc/opendaylight/karaf OpenDaylight :: transportpce + + org.opendaylight.netconf + odl-restconf-all + ${restconf.version} + features + xml + org.opendaylight.controller odl-mdsal-broker diff --git a/inventory/src/main/java/org/opendaylight/transportpce/inventory/job/PeriodicDeviceBackupJob.java b/inventory/src/main/java/org/opendaylight/transportpce/inventory/job/PeriodicDeviceBackupJob.java index a431dd21b..a99b4def0 100644 --- a/inventory/src/main/java/org/opendaylight/transportpce/inventory/job/PeriodicDeviceBackupJob.java +++ b/inventory/src/main/java/org/opendaylight/transportpce/inventory/job/PeriodicDeviceBackupJob.java @@ -12,7 +12,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Strings; import com.google.common.io.Files; - import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -20,7 +19,6 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Optional; import java.util.concurrent.ExecutionException; - import org.apache.karaf.scheduler.Job; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; @@ -82,7 +80,7 @@ public class PeriodicDeviceBackupJob implements Runnable { @Override public void run() { - LOG.info("Running periodical device backup into {}", folder); + LOG.info("Running periodical device backup into {}", this.folder); try { backupAllDevices(); } catch (InterruptedException | ExecutionException e) { @@ -96,7 +94,7 @@ public class PeriodicDeviceBackupJob implements Runnable { * @return the folder */ public String getFolder() { - return folder; + return this.folder; } /** @@ -114,7 +112,7 @@ public class PeriodicDeviceBackupJob implements Runnable { * @return the filePrefix */ public String getFilePrefix() { - return filePrefix; + return this.filePrefix; } /** @@ -133,7 +131,7 @@ public class PeriodicDeviceBackupJob implements Runnable { * @throws ExecutionException execution exception */ private void backupAllDevices() throws InterruptedException, ExecutionException { - ReadOnlyTransaction newReadOnlyTransaction = dataBroker.newReadOnlyTransaction(); + ReadOnlyTransaction newReadOnlyTransaction = this.dataBroker.newReadOnlyTransaction(); Optional topology = newReadOnlyTransaction .read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifiers.NETCONF_TOPOLOGY_II).get().toJavaUtil(); if (!topology.isPresent()) { @@ -159,7 +157,7 @@ public class PeriodicDeviceBackupJob implements Runnable { private void storeRoadmDevice(String nodeId) { InstanceIdentifier deviceIi = InstanceIdentifier.create(OrgOpenroadmDevice.class); Optional deviceObject = - deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIi, + this.deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, deviceIi, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); if (!deviceObject.isPresent()) { LOG.warn("Device object {} is not present.", nodeId); @@ -182,13 +180,13 @@ public class PeriodicDeviceBackupJob implements Runnable { } String prepareFileName = prepareFileName(nodeId); - File parent = new File(folder); + File parent = new File(this.folder); if (!parent.exists() && !parent.isDirectory() && !parent.mkdirs()) { - LOG.error("Could not create empty directory {}", folder); - throw new IllegalStateException(String.format("Could not create empty directory %s", folder)); + LOG.error("Could not create empty directory {}", this.folder); + throw new IllegalStateException(String.format("Could not create empty directory %s", this.folder)); } - File file = new File(parent, filePrefix.concat(prepareFileName)); + File file = new File(parent, this.filePrefix.concat(prepareFileName)); if (file.exists()) { throw new IllegalStateException(String.format("The file %s already exists", file)); } @@ -200,7 +198,7 @@ public class PeriodicDeviceBackupJob implements Runnable { } private String prepareFileName(String nodeId) { - String format = filenameFormatter.format(new Date()); + String format = this.filenameFormatter.format(new Date()); StringBuilder sb = new StringBuilder(format); sb.append("__").append(nodeId).append("__").append(".xml"); return sb.toString(); @@ -219,31 +217,31 @@ public class PeriodicDeviceBackupJob implements Runnable { LOG.trace("The node is null"); return ""; } - NetconfNode netconfNode = node.getAugmentation(NetconfNode.class); + NetconfNode netconfNode = node.augmentation(NetconfNode.class); if (netconfNode == null) { LOG.trace("The node {} has not properties of NetconfNode", node); return ""; } - if (netconfNode.getAvailableCapabilities() == null - || netconfNode.getAvailableCapabilities().getAvailableCapability() == null) { + if ((netconfNode.getAvailableCapabilities() == null) + || (netconfNode.getAvailableCapabilities().getAvailableCapability() == null)) { LOG.trace("No available capabilities"); return ""; } long count = netconfNode.getAvailableCapabilities().getAvailableCapability().stream() - .filter(cp -> cp.getCapability() != null && cp.getCapability().contains(ORG_OPENROADM_DEVICE)).count(); + .filter(cp -> (cp.getCapability() != null) && cp.getCapability().contains(ORG_OPENROADM_DEVICE)).count(); if (count < 1) { LOG.trace("The node {} has not capabilities of OpenROADMDevice", node); return ""; } - if (node.getKey() == null || node.getKey().getNodeId() == null) { + if ((node.key() == null) || (node.key().getNodeId() == null)) { LOG.trace("Node {} has invalid key", node); return ""; } - if ("controller-config".equalsIgnoreCase(node.getKey().getNodeId().getValue())) { + if ("controller-config".equalsIgnoreCase(node.key().getNodeId().getValue())) { LOG.info("Got controller-config instead of roadm-node"); return ""; } - return node.getKey().getNodeId().getValue(); + return node.key().getNodeId().getValue(); } } diff --git a/inventory/src/main/java/org/opendaylight/transportpce/inventory/listener/DeviceListener.java b/inventory/src/main/java/org/opendaylight/transportpce/inventory/listener/DeviceListener.java index 2f8f8c673..daa2b30f7 100644 --- a/inventory/src/main/java/org/opendaylight/transportpce/inventory/listener/DeviceListener.java +++ b/inventory/src/main/java/org/opendaylight/transportpce/inventory/listener/DeviceListener.java @@ -47,8 +47,8 @@ public class DeviceListener implements DataTreeChangeListener { public void onDataTreeChanged(Collection> changes) { List> changesWithoutDefaultNetconfNode = getRealDevicesOnly(changes); for (DataTreeModification device : changesWithoutDefaultNetconfNode) { - String nodeId = device.getRootNode().getDataAfter().getKey().getNodeId().getValue(); - NetconfNode netconfNode = device.getRootNode().getDataAfter().getAugmentation(NetconfNode.class); + String nodeId = device.getRootNode().getDataAfter().key().getNodeId().getValue(); + NetconfNode netconfNode = device.getRootNode().getDataAfter().augmentation(NetconfNode.class); if (isCreate(device) || isUpdate(device)) { LOG.info("Node {} was modified", nodeId); try { @@ -82,7 +82,7 @@ public class DeviceListener implements DataTreeChangeListener { return; } if (ConnectionStatus.Connected.equals(connectionStatus)) { - deviceInventory.initializeDevice(nodeId); + this.deviceInventory.initializeDevice(nodeId); } else if (ConnectionStatus.Connecting.equals(connectionStatus) || ConnectionStatus.UnableToConnect.equals(connectionStatus)) { LOG.info("The device is in {} state", connectionStatus); @@ -100,14 +100,14 @@ public class DeviceListener implements DataTreeChangeListener { */ private static List> getRealDevicesOnly(Collection> changes) { return changes.stream() - .filter(change -> (change.getRootNode().getDataAfter() != null + .filter(change -> ((change.getRootNode().getDataAfter() != null) && !StringConstants.DEFAULT_NETCONF_NODEID - .equalsIgnoreCase(change.getRootNode().getDataAfter().getKey().getNodeId().getValue()) - && change.getRootNode().getDataAfter().getAugmentation(NetconfNode.class) != null) - || (change.getRootNode().getDataBefore() != null + .equalsIgnoreCase(change.getRootNode().getDataAfter().key().getNodeId().getValue()) + && (change.getRootNode().getDataAfter().augmentation(NetconfNode.class) != null)) + || ((change.getRootNode().getDataBefore() != null) && !StringConstants.DEFAULT_NETCONF_NODEID.equalsIgnoreCase( - change.getRootNode().getDataBefore().getKey().getNodeId().getValue()) - && change.getRootNode().getDataBefore().getAugmentation(NetconfNode.class) != null + change.getRootNode().getDataBefore().key().getNodeId().getValue()) + && (change.getRootNode().getDataBefore().augmentation(NetconfNode.class) != null) )).collect(Collectors.toList()); } @@ -119,7 +119,7 @@ public class DeviceListener implements DataTreeChangeListener { * @return boolean true if the change is a new write */ private static boolean isCreate(DataTreeModification change) { - return change.getRootNode().getDataBefore() == null && change.getRootNode().getDataAfter() != null + return (change.getRootNode().getDataBefore() == null) && (change.getRootNode().getDataAfter() != null) && ModificationType.WRITE.equals(change.getRootNode().getModificationType()); } @@ -140,7 +140,7 @@ public class DeviceListener implements DataTreeChangeListener { * @return boolean true if the node was deleted */ private static boolean isDelete(DataTreeModification change) { - return change.getRootNode().getDataBefore() != null && change.getRootNode().getDataAfter() == null + return (change.getRootNode().getDataBefore() != null) && (change.getRootNode().getDataAfter() == null) && ModificationType.DELETE.equals(change.getRootNode().getModificationType()); } } diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/NetConfTopologyListener.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/NetConfTopologyListener.java index 059479b02..06ab2f73a 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/NetConfTopologyListener.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/NetConfTopologyListener.java @@ -163,7 +163,7 @@ public class NetConfTopologyListener implements DataTreeChangeListener { } if (rootNode.getModificationType() == ModificationType.DELETE) { if (rootNode.getDataBefore() != null) { - String nodeId = rootNode.getDataBefore().getKey().getNodeId().getValue(); + String nodeId = rootNode.getDataBefore().key().getNodeId().getValue(); LOG.info("Node {} deleted", nodeId); this.networkModelService.deleteOpenROADMnode(nodeId); onDeviceDisConnected(nodeId); @@ -172,8 +172,8 @@ public class NetConfTopologyListener implements DataTreeChangeListener { } continue; } - String nodeId = rootNode.getDataAfter().getKey().getNodeId().getValue(); - NetconfNode netconfNode = rootNode.getDataAfter().getAugmentation(NetconfNode.class); + String nodeId = rootNode.getDataAfter().key().getNodeId().getValue(); + NetconfNode netconfNode = rootNode.getDataAfter().augmentation(NetconfNode.class); if ((netconfNode != null) && !StringConstants.DEFAULT_NETCONF_NODEID.equals(nodeId)) { switch (rootNode.getModificationType()) { diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/NetworkUtilsImpl.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/NetworkUtilsImpl.java index 428697618..7100c56c1 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/NetworkUtilsImpl.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/NetworkUtilsImpl.java @@ -8,10 +8,9 @@ package org.opendaylight.transportpce.networkmodel; import com.google.common.base.Optional; +import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; @@ -56,7 +55,7 @@ public class NetworkUtilsImpl implements NetworkutilsService { } @Override - public Future> deleteLink(DeleteLinkInput input) { + public ListenableFuture> deleteLink(DeleteLinkInput input) { LinkId linkId = new LinkId(input.getLinkId()); // Building link instance identifier @@ -99,9 +98,9 @@ public class NetworkUtilsImpl implements NetworkutilsService { } } - public Future> initRoadmNodes(InitRoadmNodesInput input) { + public ListenableFuture> initRoadmNodes(InitRoadmNodesInput input) { boolean createRdmLinks = OrdLink.createRdm2RdmLinks(input, - openRoadmTopology, dataBroker); + this.openRoadmTopology,this.dataBroker); if (createRdmLinks) { return RpcResultBuilder .success(new InitRoadmNodesOutputBuilder().setResult( @@ -113,10 +112,10 @@ public class NetworkUtilsImpl implements NetworkutilsService { } @Override - public Future> initXpdrRdmLinks(InitXpdrRdmLinksInput input) { + public ListenableFuture> initXpdrRdmLinks(InitXpdrRdmLinksInput input) { // Assigns user provided input in init-network-view RPC to nodeId boolean createXpdrRdmLinks = Rdm2XpdrLink.createXpdrRdmLinks(input.getLinksInput(), - openRoadmTopology, dataBroker); + this.openRoadmTopology,this.dataBroker); if (createXpdrRdmLinks) { return RpcResultBuilder .success(new InitXpdrRdmLinksOutputBuilder().setResult("Xponder Roadm Link created successfully")) @@ -126,9 +125,10 @@ public class NetworkUtilsImpl implements NetworkutilsService { } } - public Future> initRdmXpdrLinks(InitRdmXpdrLinksInput input) { + @Override + public ListenableFuture> initRdmXpdrLinks(InitRdmXpdrLinksInput input) { boolean createRdmXpdrLinks = Rdm2XpdrLink.createRdmXpdrLinks(input.getLinksInput(), - openRoadmTopology, dataBroker); + this.openRoadmTopology,this.dataBroker); if (createRdmXpdrLinks) { return RpcResultBuilder .success(new InitRdmXpdrLinksOutputBuilder().setResult("Roadm Xponder links created successfully")) diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/R2RLinkDiscovery.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/R2RLinkDiscovery.java index 2dd9da353..40ae84c06 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/R2RLinkDiscovery.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/R2RLinkDiscovery.java @@ -9,7 +9,6 @@ package org.opendaylight.transportpce.networkmodel; import java.util.Optional; import java.util.concurrent.ExecutionException; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.MountPoint; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; @@ -64,11 +63,11 @@ public class R2RLinkDiscovery { Optional protocolObject = this.deviceTransactionManager.getDataFromDevice(nodeId.getValue(), LogicalDatastoreType.OPERATIONAL, protocolsIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); - if (!protocolObject.isPresent() || (protocolObject.get().getAugmentation(Protocols1.class) == null)) { + if (!protocolObject.isPresent() || (protocolObject.get().augmentation(Protocols1.class) == null)) { LOG.warn("LLDP subtree is missing : isolated openroadm device"); return false; } - NbrList nbrList = protocolObject.get().getAugmentation(Protocols1.class).getLldp().getNbrList(); + NbrList nbrList = protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList(); LOG.info("LLDP subtree is present. Device has {} neighbours", nbrList.getIfName().size()); for (IfName ifName : nbrList.getIfName()) { if (ifName.getRemoteSysName() == null) { @@ -170,7 +169,7 @@ public class R2RLinkDiscovery { r2rlinkBuilderAToZ.setRdmANode(nodeId.getValue()).setDegANum(srcDegId.shortValue()) .setTerminationPointA(srcTpTx).setRdmZNode(destNodeId.getValue()).setDegZNum(destDegId.shortValue()) .setTerminationPointZ(destTpRx); - if (!OrdLink.createRdm2RdmLinks(r2rlinkBuilderAToZ.build(), openRoadmTopology, dataBroker)) { + if (!OrdLink.createRdm2RdmLinks(r2rlinkBuilderAToZ.build(), this.openRoadmTopology, this.dataBroker)) { LOG.error("OMS Link creation failed between node: {} and nodeId: {} in A->Z direction", nodeId.getValue(), destNodeId.getValue()); return false; @@ -185,7 +184,7 @@ public class R2RLinkDiscovery { r2rlinkBuilderZToA.setRdmANode(destNodeId.getValue()).setDegANum(destDegId.shortValue()) .setTerminationPointA(destTpTx).setRdmZNode(nodeId.getValue()).setDegZNum(srcDegId.shortValue()) .setTerminationPointZ(srcTpRx); - if (!OrdLink.createRdm2RdmLinks(r2rlinkBuilderZToA.build(), openRoadmTopology, dataBroker)) { + if (!OrdLink.createRdm2RdmLinks(r2rlinkBuilderZToA.build(), this.openRoadmTopology, this.dataBroker)) { LOG.error("OMS Link creation failed between node: {} and nodeId: {} in Z->A direction", destNodeId.getValue(), nodeId.getValue()); return false; diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/Rdm2XpdrLink.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/Rdm2XpdrLink.java index 73b765cf7..b67091ee7 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/Rdm2XpdrLink.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/Rdm2XpdrLink.java @@ -10,7 +10,6 @@ package org.opendaylight.transportpce.networkmodel; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.CheckedFuture; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -100,13 +99,13 @@ final class Rdm2XpdrLink { NetworkId nwId = new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID); NetworkBuilder nwBuilder = new NetworkBuilder(); nwBuilder.setNetworkId(nwId); - nwBuilder.setKey(new NetworkKey(nwId)); + nwBuilder.withKey(new NetworkKey(nwId)); Link1Builder lnk1bldr = new Link1Builder(); LinkBuilder linkBuilder = openRoadmTopology.createLink(srcNode, destNode, srcTp, destTp); lnk1bldr.setLinkType(isXponderInput ? OpenroadmLinkType.XPONDERINPUT : OpenroadmLinkType.XPONDEROUTPUT); linkBuilder.addAugmentation(Link1.class, lnk1bldr.build()); LOG.info("Link id in the linkbldr {}", linkBuilder.getLinkId()); - LOG.info("Link with oppo link {}", linkBuilder.getAugmentation(Link1.class)); + LOG.info("Link with oppo link {}", linkBuilder.augmentation(Link1.class)); Network1Builder nwBldr1 = new Network1Builder(); nwBldr1.setLink(ImmutableList.of(linkBuilder.build())); nwBuilder.addAugmentation(Network1.class, nwBldr1.build()); diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelServiceImpl.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelServiceImpl.java index 78e4510a2..81079870e 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelServiceImpl.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelServiceImpl.java @@ -9,7 +9,6 @@ package org.opendaylight.transportpce.networkmodel.service; import java.util.HashMap; import java.util.concurrent.ExecutionException; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -95,14 +94,14 @@ public class NetworkModelServiceImpl implements NetworkModelService { LOG.info("creating node in {}", NetworkUtils.CLLI_NETWORK_ID); InstanceIdentifier iiClliNode = InstanceIdentifier .builder(Network.class, new NetworkKey(new NetworkId(NetworkUtils.CLLI_NETWORK_ID))) - .child(Node.class, clliNode.getKey()) + .child(Node.class, clliNode.key()) .build(); writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, iiClliNode, clliNode, CREATE_MISSING_PARENTS); LOG.info("creating node in {}", NetworkUtils.UNDERLAY_NETWORK_ID); InstanceIdentifier iiOpenRoadmNode = InstanceIdentifier .builder(Network.class, new NetworkKey(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID))) - .child(Node.class, openRoadmNode.getKey()) + .child(Node.class, openRoadmNode.key()) .build(); writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmNode, openRoadmNode, CREATE_MISSING_PARENTS); @@ -111,7 +110,7 @@ public class NetworkModelServiceImpl implements NetworkModelService { NetworkUtils.OVERLAY_NETWORK_ID); InstanceIdentifier iiOpenRoadmTopologyNode = InstanceIdentifier .builder(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) - .child(Node.class, openRoadmTopologyNode.getKey()) + .child(Node.class, openRoadmTopologyNode.key()) .build(); writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyNode, openRoadmTopologyNode, CREATE_MISSING_PARENTS); @@ -122,7 +121,7 @@ public class NetworkModelServiceImpl implements NetworkModelService { InstanceIdentifier iiOpenRoadmTopologyLink = InstanceIdentifier .builder(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) .augmentation(Network1.class) - .child(Link.class, openRoadmTopologyLink.getKey()) + .child(Link.class, openRoadmTopologyLink.key()) .build(); writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyLink, openRoadmTopologyLink, CREATE_MISSING_PARENTS); @@ -176,7 +175,7 @@ public class NetworkModelServiceImpl implements NetworkModelService { NetworkUtils.OVERLAY_NETWORK_ID); InstanceIdentifier iiOpenRoadmTopologyNode = InstanceIdentifier .builder(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) - .child(Node.class, openRoadmTopologyNode.getKey()) + .child(Node.class, openRoadmTopologyNode.key()) .build(); writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyNode); } @@ -186,7 +185,7 @@ public class NetworkModelServiceImpl implements NetworkModelService { InstanceIdentifier iiOpenRoadmTopologyLink = InstanceIdentifier .builder(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) .augmentation(Network1.class) - .child(Link.class, openRoadmTopologyLink.getKey()) + .child(Link.class, openRoadmTopologyLink.key()) .build(); writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyLink); } diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/ClliNetwork.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/ClliNetwork.java index 1af2d3567..037944262 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/ClliNetwork.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/ClliNetwork.java @@ -12,7 +12,6 @@ import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -89,7 +88,7 @@ public final class ClliNetwork { NodeBuilder nodeBldr = new NodeBuilder(); NodeId nwNodeId = new NodeId(clli); nodeBldr.setNodeId(nwNodeId); - nodeBldr.setKey(new NodeKey(nwNodeId)); + nodeBldr.withKey(new NodeKey(nwNodeId)); /* * create clli node augmentation * defined in openroadm-clli-network.yang @@ -107,7 +106,7 @@ public final class ClliNetwork { NetworkBuilder nwBuilder = new NetworkBuilder(); NetworkId nwId = new NetworkId(NetworkUtils.CLLI_NETWORK_ID); nwBuilder.setNetworkId(nwId); - nwBuilder.setKey(new NetworkKey(nwId)); + nwBuilder.withKey(new NetworkKey(nwId)); //set network type to clli NetworkTypes1Builder clliNetworkTypesBldr = new NetworkTypes1Builder(); clliNetworkTypesBldr.setClliNetwork(new ClliNetworkBuilder().build()); diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetwork.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetwork.java index 39924b27e..df6f824be 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetwork.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetwork.java @@ -9,12 +9,10 @@ package org.opendaylight.transportpce.networkmodel.util; import com.google.common.collect.ImmutableList; - import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -96,7 +94,7 @@ public final class OpenRoadmNetwork { NodeBuilder nodeBldr = new NodeBuilder(); NodeId nwNodeId = new NodeId(nodeId); nodeBldr.setNodeId(nwNodeId); - nodeBldr.setKey(new NodeKey(nwNodeId)); + nodeBldr.withKey(new NodeKey(nwNodeId)); Node1Builder node1bldr = new Node1Builder(); /* @@ -126,7 +124,7 @@ public final class OpenRoadmNetwork { // attribute String clli = deviceInfo.getClli(); SupportingNodeBuilder supportbldr = new SupportingNodeBuilder(); - supportbldr.setKey(new SupportingNodeKey(new NetworkId(NetworkUtils.CLLI_NETWORK_ID), new NodeId(clli))); + supportbldr.withKey(new SupportingNodeKey(new NetworkId(NetworkUtils.CLLI_NETWORK_ID), new NodeId(clli))); supportbldr.setNetworkRef(new NetworkId(NetworkUtils.CLLI_NETWORK_ID)); supportbldr.setNodeRef(new NodeId(clli)); nodeBldr.setSupportingNode(ImmutableList.of(supportbldr.build())); @@ -143,7 +141,7 @@ public final class OpenRoadmNetwork { NetworkBuilder openrdmnwBuilder = new NetworkBuilder(); NetworkId nwId = new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID); openrdmnwBuilder.setNetworkId(nwId); - openrdmnwBuilder.setKey(new NetworkKey(nwId)); + openrdmnwBuilder.withKey(new NetworkKey(nwId)); // sets network type to OpenRoadmNetwork NetworkTypes1Builder openRoadmNetworkTypesBldr = new NetworkTypes1Builder(); openRoadmNetworkTypesBldr.setOpenroadmNetwork(new OpenroadmNetworkBuilder().build()); diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopology.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopology.java index 0abc53d5c..95364d09e 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopology.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopology.java @@ -15,7 +15,6 @@ import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -124,7 +123,7 @@ public class OpenRoadmTopology { NetworkBuilder nwBuilder = new NetworkBuilder(); NetworkId nwId = new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID); nwBuilder.setNetworkId(nwId); - nwBuilder.setKey(new NetworkKey(nwId)); + nwBuilder.withKey(new NetworkKey(nwId)); // set network type to Transport Underlay NetworkTypes1Builder topoNetworkTypesBldr = new NetworkTypes1Builder(); topoNetworkTypesBldr.setOpenroadmTopology(new OpenroadmTopologyBuilder().build()); @@ -300,7 +299,7 @@ public class OpenRoadmTopology { String nodeIdtopo = new StringBuilder().append(nodeId).append("-XPDR1").toString(); // Ad degree node specific augmentation nodebldr.setNodeId(new NodeId(nodeIdtopo)); - nodebldr.setKey(new NodeKey(new NodeId(nodeIdtopo))); + nodebldr.withKey(new NodeKey(new NodeId(nodeIdtopo))); nodebldr.addAugmentation(Node1.class, node1bldr.build()); while (clientCounter != 0) { // Create CLNT-TX termination @@ -589,7 +588,7 @@ public class OpenRoadmTopology { // Sets the value of Network-ref and Node-ref as a part of the supporting node // attribute SupportingNodeBuilder supportbldr = new SupportingNodeBuilder(); - supportbldr.setKey(new SupportingNodeKey(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID), new NodeId(nodeId))); + supportbldr.withKey(new SupportingNodeKey(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID), new NodeId(nodeId))); supportbldr.setNetworkRef(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID)); supportbldr.setNodeRef(new NodeId(nodeId)); ArrayList supportlist = new ArrayList<>(); @@ -629,7 +628,7 @@ public class OpenRoadmTopology { TerminationPointBuilder tpBldr = new TerminationPointBuilder(); TpId tp = new TpId(tpId); TerminationPointKey tpKey = new TerminationPointKey(tp); - tpBldr.setKey(tpKey); + tpBldr.withKey(tpKey); tpBldr.setTpId(tp); return tpBldr; } @@ -650,7 +649,7 @@ public class OpenRoadmTopology { lnkBldr.setDestination(dstNodeBldr.build()); lnkBldr.setSource(srcNodeBldr.build()); lnkBldr.setLinkId(LinkIdUtil.buildLinkId(srcNode, srcTp, dstNode, destTp)); - lnkBldr.setKey(new LinkKey(lnkBldr.getLinkId())); + lnkBldr.withKey(new LinkKey(lnkBldr.getLinkId())); org.opendaylight.yang.gen.v1.http.org.openroadm.opposite.links.rev170929.Link1Builder lnk1Bldr = new org.opendaylight.yang.gen.v1.http.org.openroadm.opposite.links.rev170929.Link1Builder(); LinkId oppositeLinkId = LinkIdUtil.getOppositeLinkId(srcNode, srcTp, dstNode, destTp); @@ -829,7 +828,7 @@ public class OpenRoadmTopology { for (int i = 1; i < 97; i++) { AvailableWavelengthsBuilder avalBldr = new AvailableWavelengthsBuilder(); avalBldr.setIndex((long) i); - avalBldr.setKey(new AvailableWavelengthsKey((long) i)); + avalBldr.withKey(new AvailableWavelengthsKey((long) i)); waveList.add(avalBldr.build()); } @@ -848,7 +847,7 @@ public class OpenRoadmTopology { new org.opendaylight.yang.gen.v1.http.org.openroadm.srg.rev170929.srg.node.attributes .AvailableWavelengthsBuilder(); avalBldr.setIndex((long) i); - avalBldr.setKey( + avalBldr.withKey( new org.opendaylight.yang.gen.v1.http.org.openroadm.srg.rev170929.srg.node.attributes .AvailableWavelengthsKey((long) i)); waveList.add(avalBldr.build()); diff --git a/olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImpl.java b/olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImpl.java index 85244577c..c0dfb2054 100644 --- a/olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImpl.java +++ b/olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImpl.java @@ -7,7 +7,7 @@ */ package org.opendaylight.transportpce.olm; -import java.util.concurrent.Future; +import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.transportpce.olm.service.OlmPowerService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossBaseInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossBaseOutput; @@ -53,8 +53,8 @@ public class OlmPowerServiceRpcImpl implements OlmService { * @return Result of the request */ @Override - public Future> getPm(GetPmInput input) { - return RpcResultBuilder.success(olmPowerService.getPm(input)).buildFuture(); + public ListenableFuture> getPm(GetPmInput input) { + return RpcResultBuilder.success(this.olmPowerService.getPm(input)).buildFuture(); } /** @@ -78,9 +78,9 @@ public class OlmPowerServiceRpcImpl implements OlmService { * @return Result of the request */ @Override - public Future> servicePowerSetup( + public ListenableFuture> servicePowerSetup( ServicePowerSetupInput input) { - return RpcResultBuilder.success(olmPowerService.servicePowerSetup(input)).buildFuture(); + return RpcResultBuilder.success(this.olmPowerService.servicePowerSetup(input)).buildFuture(); } /** @@ -104,8 +104,8 @@ public class OlmPowerServiceRpcImpl implements OlmService { * @return Result of the request */ @Override - public Future> servicePowerTurndown(ServicePowerTurndownInput input) { - return RpcResultBuilder.success(olmPowerService.servicePowerTurndown(input)).buildFuture(); + public ListenableFuture> servicePowerTurndown(ServicePowerTurndownInput input) { + return RpcResultBuilder.success(this.olmPowerService.servicePowerTurndown(input)).buildFuture(); } /** @@ -131,18 +131,18 @@ public class OlmPowerServiceRpcImpl implements OlmService { * @return Result of the request */ @Override - public Future> calculateSpanlossBase(CalculateSpanlossBaseInput input) { - return RpcResultBuilder.success(olmPowerService.calculateSpanlossBase(input)).buildFuture(); + public ListenableFuture> calculateSpanlossBase(CalculateSpanlossBaseInput input) { + return RpcResultBuilder.success(this.olmPowerService.calculateSpanlossBase(input)).buildFuture(); } @Override - public Future> calculateSpanlossCurrent( + public ListenableFuture> calculateSpanlossCurrent( CalculateSpanlossCurrentInput input) { - return RpcResultBuilder.success(olmPowerService.calculateSpanlossCurrent(input)).buildFuture(); + return RpcResultBuilder.success(this.olmPowerService.calculateSpanlossCurrent(input)).buildFuture(); } @Override - public Future> servicePowerReset(ServicePowerResetInput input) { - return RpcResultBuilder.success(olmPowerService.servicePowerReset(input)).buildFuture(); + public ListenableFuture> servicePowerReset(ServicePowerResetInput input) { + return RpcResultBuilder.success(this.olmPowerService.servicePowerReset(input)).buildFuture(); } } \ No newline at end of file diff --git a/olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmt.java b/olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmt.java index 8cbb41def..45172d4a5 100644 --- a/olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmt.java +++ b/olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmt.java @@ -9,14 +9,12 @@ package org.opendaylight.transportpce.olm.power; import com.google.common.util.concurrent.ListenableFuture; - import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.transportpce.common.Timeouts; @@ -85,19 +83,19 @@ public class PowerMgmt { String nodeId = input.getNodes().get(i).getNodeId(); String srcTpId = input.getNodes().get(i).getSrcTp(); String destTpId = input.getNodes().get(i).getDestTp(); - Optional inputNodeOptional = OlmUtils.getNode(nodeId, db); + Optional inputNodeOptional = OlmUtils.getNode(nodeId, this.db); // If node type is transponder if (inputNodeOptional.isPresent() - && inputNodeOptional.get().getNodeType() != null + && (inputNodeOptional.get().getNodeType() != null) && inputNodeOptional.get().getNodeType().equals(NodeTypes.Xpdr)) { Nodes inputNode = inputNodeOptional.get(); LOG.info("Getting data from input node {}", inputNode.getNodeType()); - LOG.info("Getting mapping data for node is {}", inputNode.getMapping().stream().filter(o -> o.getKey() + LOG.info("Getting mapping data for node is {}", inputNode.getMapping().stream().filter(o -> o.key() .equals(new MappingKey(destTpId))).findFirst().toString()); // If its A-End transponder if (destTpId.toLowerCase().contains("network")) { - java.util.Optional mappingObject = inputNode.getMapping().stream().filter(o -> o.getKey() + java.util.Optional mappingObject = inputNode.getMapping().stream().filter(o -> o.key() .equals(new MappingKey(destTpId))).findFirst(); if (mappingObject.isPresent()) { Map txPowerRangeMap = getXponderPowerRange(mappingObject.get() @@ -158,7 +156,7 @@ public class PowerMgmt { LOG.info("{} is a drop node. Net power settings needed", nodeId); } } else if (inputNodeOptional.isPresent() - && inputNodeOptional.get().getNodeType() != null + && (inputNodeOptional.get().getNodeType() != null) && inputNodeOptional.get().getNodeType().equals(NodeTypes.Rdm)) { // If Degree is transmitting end then set power Nodes inputNode = inputNodeOptional.get(); @@ -166,21 +164,21 @@ public class PowerMgmt { String connectionNumber = srcTpId + "-" + destTpId + "-" + input.getWaveNumber(); LOG.info("Connection number is {}", connectionNumber); if (destTpId.toLowerCase().contains("deg")) { - Optional mappingObjectOptional = inputNode.getMapping().stream().filter(o -> o.getKey() + Optional mappingObjectOptional = inputNode.getMapping().stream().filter(o -> o.key() .equals(new MappingKey(destTpId))).findFirst(); if (mappingObjectOptional.isPresent()) { LOG.info("Dest point is Degree {}", mappingObjectOptional.get()); Mapping portMapping = mappingObjectOptional.get(); Optional interfaceOpt; try { - interfaceOpt = openRoadmInterfaces.getInterface(nodeId, portMapping.getSupportingOts()); + interfaceOpt = this.openRoadmInterfaces.getInterface(nodeId, portMapping.getSupportingOts()); } catch (OpenRoadmInterfaceException ex) { LOG.error("Failed to get interface {} from node {}!", portMapping.getSupportingOts(), nodeId, ex); return false; } if (interfaceOpt.isPresent()) { - BigDecimal spanLossTx = interfaceOpt.get().getAugmentation(Interface1.class).getOts() + BigDecimal spanLossTx = interfaceOpt.get().augmentation(Interface1.class).getOts() .getSpanLossTransmit().getValue(); LOG.info("Spanloss TX is {}", spanLossTx); BigDecimal powerValue = BigDecimal.valueOf(Math.min(spanLossTx.doubleValue() - 9, 2)); @@ -304,7 +302,7 @@ public class PowerMgmt { .child(Interface.class, new InterfaceKey(interfaceName)); Optional nodeInterfaceOpt; try { - nodeInterfaceOpt = openRoadmInterfaces.getInterface(nodeId, interfaceName); + nodeInterfaceOpt = this.openRoadmInterfaces.getInterface(nodeId, interfaceName); } catch (OpenRoadmInterfaceException ex) { LOG.error("Failed to get interface {} from node {}!", interfaceName, nodeId, ex); return false; @@ -312,7 +310,7 @@ public class PowerMgmt { if (nodeInterfaceOpt.isPresent()) { InterfaceBuilder intfBuilder = new InterfaceBuilder(nodeInterfaceOpt.get()); intfBuilder.setAdministrativeState(AdminStates.OutOfService); - Future> deviceTxFuture = deviceTransactionManager.getDeviceTransaction(nodeId); + Future> deviceTxFuture = this.deviceTransactionManager.getDeviceTransaction(nodeId); DeviceTransaction deviceTx; try { Optional deviceTxOpt = deviceTxFuture.get(); @@ -361,7 +359,7 @@ public class PowerMgmt { Map powerRangeMap = new HashMap<>(); LOG.info("Fetching logical Connection Point value for port {} at circuit pack {}", portName, circuitPackName); Optional portObject = - deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, portIID, + this.deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, portIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); if (portObject.isPresent()) { Ports port = portObject.get(); @@ -389,8 +387,8 @@ public class PowerMgmt { private Map getSRGRxPowerRange(String nodeId, String srgId) { Map powerRangeMap = new HashMap<>(); LOG.info("Coming inside Xpdr power range"); - Optional mappingSRGOptional = OlmUtils.getNode(nodeId, db).flatMap(node -> node.getMapping() - .stream().filter(o -> o.getKey() + Optional mappingSRGOptional = OlmUtils.getNode(nodeId, this.db).flatMap(node -> node.getMapping() + .stream().filter(o -> o.key() .equals(new MappingKey(srgId))).findFirst()); if (mappingSRGOptional.isPresent()) { LOG.info("Mapping object exists."); @@ -403,7 +401,7 @@ public class PowerMgmt { LOG.info("Fetching logical Connection Point value for port {} at circuit pack {}{}", portName, circuitPackName, portIID); Optional portObject = - deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, portIID, + this.deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, portIID, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); if (portObject.isPresent()) { Ports port = portObject.get(); @@ -446,7 +444,7 @@ public class PowerMgmt { nodeId, interfaceName); Optional interfaceOptional; try { - interfaceOptional = openRoadmInterfaces.getInterface(nodeId, interfaceName); + interfaceOptional = this.openRoadmInterfaces.getInterface(nodeId, interfaceName); } catch (OpenRoadmInterfaceException ex) { LOG.error("Failed to get interface {} from node {}!", interfaceName, nodeId, ex); return false; @@ -454,7 +452,7 @@ public class PowerMgmt { if (interfaceOptional.isPresent()) { InterfaceBuilder ochInterfaceBuilder = new InterfaceBuilder(interfaceOptional.get()); - OchBuilder ochBuilder = new OchBuilder(ochInterfaceBuilder.getAugmentation( + OchBuilder ochBuilder = new OchBuilder(ochInterfaceBuilder.augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014 .Interface1.class).getOch()); ochBuilder.setTransmitPower(new PowerDBm(txPower)); @@ -462,7 +460,7 @@ public class PowerMgmt { org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014 .Interface1.class, new Interface1Builder().setOch(ochBuilder.build()).build()); - Future> deviceTxFuture = deviceTransactionManager.getDeviceTransaction(nodeId); + Future> deviceTxFuture = this.deviceTransactionManager.getDeviceTransaction(nodeId); DeviceTransaction deviceTx; try { Optional deviceTxOpt = deviceTxFuture.get(); @@ -512,7 +510,7 @@ public class PowerMgmt { */ private boolean setPowerLevel(String deviceId, OpticalControlMode mode, BigDecimal powerValue, String connectionNumber) { - Optional rdmConnOpt = crossConnect.getCrossConnect(deviceId, connectionNumber); + Optional rdmConnOpt = this.crossConnect.getCrossConnect(deviceId, connectionNumber); if (rdmConnOpt.isPresent()) { RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder(rdmConnOpt.get()); rdmConnBldr.setOpticalControlMode(mode); @@ -522,7 +520,7 @@ public class PowerMgmt { RoadmConnections newRdmConn = rdmConnBldr.build(); Future> deviceTxFuture = - deviceTransactionManager.getDeviceTransaction(deviceId); + this.deviceTransactionManager.getDeviceTransaction(deviceId); DeviceTransaction deviceTx; try { Optional deviceTxOpt = deviceTxFuture.get(); diff --git a/olm/src/main/java/org/opendaylight/transportpce/olm/service/OlmPowerServiceImpl.java b/olm/src/main/java/org/opendaylight/transportpce/olm/service/OlmPowerServiceImpl.java index ba455724b..d06f64042 100644 --- a/olm/src/main/java/org/opendaylight/transportpce/olm/service/OlmPowerServiceImpl.java +++ b/olm/src/main/java/org/opendaylight/transportpce/olm/service/OlmPowerServiceImpl.java @@ -10,7 +10,6 @@ package org.opendaylight.transportpce.olm.service; import com.google.common.base.Strings; import com.google.common.util.concurrent.ListenableFuture; - import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; @@ -22,7 +21,6 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -112,14 +110,14 @@ public class OlmPowerServiceImpl implements OlmPowerService { @Override public GetPmOutput getPm(GetPmInput pmInput) { - GetPmOutputBuilder pmOutputBuilder = OlmUtils.pmFetch(pmInput, deviceTransactionManager); + GetPmOutputBuilder pmOutputBuilder = OlmUtils.pmFetch(pmInput, this.deviceTransactionManager); return pmOutputBuilder.build(); } @Override public ServicePowerSetupOutput servicePowerSetup(ServicePowerSetupInput powerSetupInput) { ServicePowerSetupOutputBuilder powerSetupOutput = new ServicePowerSetupOutputBuilder(); - boolean successValPowerCalculation = powerMgmt.setPower(powerSetupInput); + boolean successValPowerCalculation = this.powerMgmt.setPower(powerSetupInput); if (successValPowerCalculation) { powerSetupOutput.setResult(SUCCESS); @@ -135,7 +133,7 @@ public class OlmPowerServiceImpl implements OlmPowerService { ServicePowerTurndownOutputBuilder powerTurnDownOutput = new ServicePowerTurndownOutputBuilder(); // TODO add flag or return failure instead of string - if (powerMgmt.powerTurnDown(powerTurndownInput)) { + if (this.powerMgmt.powerTurnDown(powerTurndownInput)) { powerTurnDownOutput.setResult(SUCCESS); } else { powerTurnDownOutput.setResult(FAILED); @@ -162,7 +160,7 @@ public class OlmPowerServiceImpl implements OlmPowerService { List roadmLinks = new ArrayList<>(); for (Link link : networkLinks) { - Link1 roadmLinkAugmentation = link.getAugmentation(Link1.class); + Link1 roadmLinkAugmentation = link.augmentation(Link1.class); if (roadmLinkAugmentation == null) { LOG.debug("Missing OpenRoadm link augmentation in link {} from {} topology.", link.getLinkId().getValue(), NetworkUtils.OVERLAY_NETWORK_ID); @@ -207,7 +205,7 @@ public class OlmPowerServiceImpl implements OlmPowerService { } List roadmLinks = new ArrayList<>(); for (Link link : networkLinks) { - Link1 roadmLinkAugmentation = link.getAugmentation(Link1.class); + Link1 roadmLinkAugmentation = link.augmentation(Link1.class); if (roadmLinkAugmentation == null) { LOG.debug("Missing OpenRoadm link augmentation in link {} from {} topology.", link.getLinkId().getValue(), NetworkUtils.OVERLAY_NETWORK_ID); @@ -254,7 +252,7 @@ public class OlmPowerServiceImpl implements OlmPowerService { .augmentation(Network1.class) .build(); Optional networkOptional; - try (ReadOnlyTransaction rtx = dataBroker.newReadOnlyTransaction()) { + try (ReadOnlyTransaction rtx = this.dataBroker.newReadOnlyTransaction()) { //TODO change to constant from Timeouts class when it will be merged. networkOptional = rtx.read(LogicalDatastoreType.CONFIGURATION, networkIID).get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS).toJavaUtil(); @@ -270,7 +268,7 @@ public class OlmPowerServiceImpl implements OlmPowerService { } List networkLinks = networkOptional.get().getLink(); - if (networkLinks == null || networkLinks.isEmpty()) { + if ((networkLinks == null) || networkLinks.isEmpty()) { LOG.warn("Links are not present in {} topology.", NetworkUtils.OVERLAY_NETWORK_ID); return Collections.emptyList(); } @@ -292,7 +290,7 @@ public class OlmPowerServiceImpl implements OlmPowerService { */ private OtsPmHolder getPmMeasurements(String nodeId, String tpID, String pmName) { String realNodeId = getRealNodeId(nodeId); - Mapping mapping = portMapping.getMapping(realNodeId, tpID); + Mapping mapping = this.portMapping.getMapping(realNodeId, tpID); if (mapping == null) { return null; } @@ -343,7 +341,7 @@ public class OlmPowerServiceImpl implements OlmPowerService { com.google.common.base.Optional interfaceObject; try { Future> deviceTxFuture = - deviceTransactionManager.getDeviceTransaction(realNodeId); + this.deviceTransactionManager.getDeviceTransaction(realNodeId); java.util.Optional deviceTxOpt = deviceTxFuture.get(); DeviceTransaction deviceTx; if (deviceTxOpt.isPresent()) { @@ -360,9 +358,9 @@ public class OlmPowerServiceImpl implements OlmPowerService { Interface intf = interfaceObject.get(); InterfaceBuilder interfaceBuilder = new InterfaceBuilder(intf); OtsBuilder otsBuilder = new OtsBuilder(); - if (intf.getAugmentation(Interface1.class) != null - && intf.getAugmentation(Interface1.class).getOts() != null) { - Ots ots = intf.getAugmentation(Interface1.class).getOts(); + if ((intf.augmentation(Interface1.class) != null) + && (intf.augmentation(Interface1.class).getOts() != null)) { + Ots ots = intf.augmentation(Interface1.class).getOts(); otsBuilder.setFiberType(ots.getFiberType()); spanLossRx = ots.getSpanLossReceive(); spanLossTx = ots.getSpanLossTransmit(); @@ -416,7 +414,7 @@ public class OlmPowerServiceImpl implements OlmPowerService { .setScale(0, RoundingMode.HALF_UP); LOG.info("Spanloss Calculated as :" + spanLoss + "=" + srcOtsPmHoler.getOtsParameterVal() + "-" + destOtsPmHoler.getOtsParameterVal()); - if (spanLoss.doubleValue() < 28 && spanLoss.doubleValue() > 0) { + if ((spanLoss.doubleValue() < 28) && (spanLoss.doubleValue() > 0)) { if (!setSpanLoss(roadmLinks.get(i).getSrcNodeId(), srcOtsPmHoler.getOtsInterfaceName(), spanLoss, "TX")) { LOG.info("Setting spanLoss failed for " + roadmLinks.get(i).getSrcNodeId()); @@ -436,22 +434,22 @@ public class OlmPowerServiceImpl implements OlmPowerService { KeyedInstanceIdentifier mappedNodeII = InstanceIdentifiers.OVERLAY_NETWORK_II.child(Node.class, new NodeKey(new NodeId(mappedNodeId))); com.google.common.base.Optional realNode; - try (ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction()) { + try (ReadOnlyTransaction readOnlyTransaction = this.dataBroker.newReadOnlyTransaction()) { realNode = readOnlyTransaction.read(LogicalDatastoreType.CONFIGURATION, mappedNodeII).get(); } catch (InterruptedException | ExecutionException e) { LOG.error(e.getMessage(), e); throw new IllegalStateException(e); } - if (!realNode.isPresent() || realNode.get().getSupportingNode() == null) { + if (!realNode.isPresent() || (realNode.get().getSupportingNode() == null)) { throw new IllegalArgumentException( String.format("Could not find node %s, or supporting node is not present", mappedNodeId)); } List collect = realNode.get().getSupportingNode().stream() - .filter(node -> node.getNetworkRef() != null + .filter(node -> (node.getNetworkRef() != null) && NetworkUtils.UNDERLAY_NETWORK_ID.equals(node.getNetworkRef().getValue()) - && node.getNodeRef() != null && !Strings.isNullOrEmpty(node.getNodeRef().getValue())) + && (node.getNodeRef() != null) && !Strings.isNullOrEmpty(node.getNodeRef().getValue())) .collect(Collectors.toList()); - if (collect.isEmpty() || collect.size() > 1) { + if (collect.isEmpty() || (collect.size() > 1)) { throw new IllegalArgumentException(String.format("Invalid support node count [%d] was found for node %s", collect.size(), mappedNodeId)); } diff --git a/ordmodels/network/src/main/yang/old-ietf-network-topology@2015-06-08.yang b/ordmodels/network/src/main/yang/old-ietf-network-topology@2015-06-08.yang new file mode 100644 index 000000000..81a8a2871 --- /dev/null +++ b/ordmodels/network/src/main/yang/old-ietf-network-topology@2015-06-08.yang @@ -0,0 +1,243 @@ +module old-ietf-network-topology { + yang-version 1; + namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology"; + prefix lnk; + + import ietf-inet-types { + prefix inet; + } + import old-ietf-network { + prefix nd; + } + + organization "TBD"; + contact + "WILL-BE-DEFINED-LATER"; + description + "This module defines a common base model for network topology, + augmenting the base network model with links to connect nodes, + as well as termination points to terminate links on nodes."; + + revision 2015-06-08 { + description + "Initial revision."; + reference "draft-ietf-i2rs-yang-network-topo-01"; + } + + typedef link-id { + type inet:uri; + description + "An identifier for a link in a topology. + The identifier may be opaque. + The identifier SHOULD be chosen such that the same link in a + real network topology will always be identified through the + same identifier, even if the model is instantiated in + separate datastores. An implementation MAY choose to capture + semantics in the identifier, for example to indicate the type + of link and/or the type of topology that the link is a part + of."; + } + + typedef tp-id { + type inet:uri; + description + "An identifier for termination points on a node. + The identifier may be opaque. + The identifier SHOULD be chosen such that the same TP in a + real network topology will always be identified through the + same identifier, even if the model is instantiated in + separate datastores. An implementation MAY choose to capture + semantics in the identifier, for example to indicate the type + of TP and/or the type of node and topology that the TP is a + part of."; + } + + grouping link-ref { + description + "References a link in a specific network."; + leaf link-ref { + type leafref { + path "/nd:network[nd:network-id=current()/../"+ + "nd:network-ref]/link/link-id"; + } + description + "A type for an absolute reference a link instance. + (This type should not be used for relative references. + In such a case, a relative path should be used instead.)"; + } + uses nd:network-ref; + } + + grouping tp-ref { + description + "References a termination point in a specific node."; + leaf tp-ref { + type leafref { + path "/nd:network[nd:network-id=current()/../"+ + "nd:network-ref]/nd:node[nd:node-id=current()/../"+ + "nd:node-ref]/termination-point/tp-id"; + } + description + "A type for an absolute reference to a termination point. + (This type should not be used for relative references. + In such a case, a relative path should be used instead.)"; + } + uses nd:node-ref; + } + + augment "/nd:network" { + description + "Add links to the network model."; + list link { + key "link-id"; + description + "A Network Link connects a by Local (Source) node and + a Remote (Destination) Network Nodes via a set of the + nodes' termination points. + As it is possible to have several links between the same + source and destination nodes, and as a link could + potentially be re-homed between termination points, to + ensure that we would always know to distinguish between + links, every link is identified by a dedicated link + identifier. + Note that a link models a point-to-point link, not a + multipoint link. + Layering dependencies on links in underlay topologies are + not represented as the layering information of nodes and of + termination points is sufficient."; + container source { + description + "This container holds the logical source of a particular + link."; + leaf source-node { + type leafref { + path "../../../nd:node/nd:node-id"; + } + mandatory true; + description + "Source node identifier, must be in same topology."; + } + leaf source-tp { + type leafref { + path "../../../nd:node[nd:node-id=current()/../"+ + "source-node]/termination-point/tp-id"; + } + description + "Termination point within source node that terminates + the link."; + } + } + container destination { + description + "This container holds the logical destination of a + particular link."; + leaf dest-node { + type leafref { + path "../../../nd:node/nd:node-id"; + } + mandatory true; + description + "Destination node identifier, must be in the same + network."; + } + leaf dest-tp { + type leafref { + path "../../../nd:node[nd:node-id=current()/../"+ + "dest-node]/termination-point/tp-id"; + } + description + "Termination point within destination node that + terminates the link."; + } + } + leaf link-id { + type link-id; + description + "The identifier of a link in the topology. + A link is specific to a topology to which it belongs."; + } + list supporting-link { + key "network-ref link-ref"; + description + "Identifies the link, or links, that this link + is dependent on."; + leaf network-ref { + type leafref { + path "../../../nd:supporting-network/nd:network-ref"; + } + description + "This leaf identifies in which underlay topology + supporting link is present."; + } + leaf link-ref { + type leafref { + path "/nd:network[nd:network-id=current()/.."+ + "/network-ref]/link/link-id"; + } + description + "This leaf identifies a link which is a part + of this link's underlay. Reference loops, in which + a link identifies itself as its underlay, either + directly or transitively, are not allowed."; + } + } + } + } + augment "/nd:network/nd:node" { + description + "Augment termination points which terminate links. + Termination points can ultimately be mapped to interfaces."; + list termination-point { + key "tp-id"; + description + "A termination point can terminate a link. + Depending on the type of topology, a termination point + could, for example, refer to a port or an interface."; + leaf tp-id { + type tp-id; + description + "Termination point identifier."; + } + list supporting-termination-point { + key "network-ref node-ref tp-ref"; + description + "The leaf list identifies any termination points that + the termination point is dependent on, or maps onto. + Those termination points will themselves be contained + in a supporting node. + This dependency information can be inferred from + the dependencies between links. For this reason, + this item is not separately configurable. Hence no + corresponding constraint needs to be articulated. + The corresponding information is simply provided by the + implementing system."; + leaf network-ref { + type leafref { + path "../../../nd:supporting-node/nd:network-ref"; + } + description + "This leaf identifies in which topology the + supporting termination point is present."; + } + leaf node-ref { + type leafref { + path "../../../nd:supporting-node/nd:node-ref"; + } + description + "This leaf identifies in which node the supporting + termination point is present."; + } + leaf tp-ref { + type leafref { + path "/nd:network[nd:network-id=current()/../"+ + "network-ref]/nd:node[nd:node-id=current()/../"+ + "node-ref]/termination-point/tp-id"; + } + description + "Reference to the underlay node, must be in a + different topology"; + } + } + } + } +} diff --git a/ordmodels/network/src/main/yang/old-ietf-network@2015-06-08.yang b/ordmodels/network/src/main/yang/old-ietf-network@2015-06-08.yang new file mode 100644 index 000000000..cc90ce2a2 --- /dev/null +++ b/ordmodels/network/src/main/yang/old-ietf-network@2015-06-08.yang @@ -0,0 +1,144 @@ +module old-ietf-network { + yang-version 1; + namespace "urn:ietf:params:xml:ns:yang:ietf-network"; + prefix nd; + + import ietf-inet-types { + prefix inet; + } + + organization "TBD"; + contact + "WILL-BE-DEFINED-LATER"; + description + "This module defines a common base model for a collection + of nodes in a network. Node definitions s are further used + in network topologies and inventories."; + + revision 2015-06-08 { + description + "Initial revision."; + reference "draft-ietf-i2rs-yang-network-topo-01"; + } + + typedef node-id { + type inet:uri; + description + "Identifier for a node."; + } + + typedef network-id { + type inet:uri; + description + "Identifier for a network."; + } + + grouping network-ref { + description + "Contains the information necessary to reference a network, + for example an underlay network."; + leaf network-ref { + type leafref { + path "/network/network-id"; + } + description + "Used to reference a network, for example an underlay + network."; + } + } + + grouping node-ref { + description + "Contains the information necessary to reference a node."; + leaf node-ref { + type leafref { + path "/network[network-id=current()/../network-ref]"+ + "/node/node-id"; + } + description + "Used to reference a node. + Nodes are identified relative to the network they are + contained in."; + } + uses network-ref; + } + + list network { + key "network-id"; + description + "Describes a network. + A network typically contains an inventory of nodes, + topological information (augmented through + network-topology model), as well as layering + information."; + container network-types { + description + "Serves as an augmentation target. + The network type is indicated through corresponding + presence containers augmented into this container."; + } + leaf network-id { + type network-id; + description + "Identifies a network."; + } + leaf server-provided { + type boolean; + config false; + description + "Indicates whether the information concerning this + particular network is populated by the server + (server-provided true, the general case for network + information discovered from the server), + or whether it is configured by a client + (server-provided true, possible e.g. for + service overlays managed through a controller)."; + } + list supporting-network { + key "network-ref"; + description + "An underlay network, used to represent layered network + topologies."; + leaf network-ref { + type leafref { + path "/network/network-id"; + } + description + "References the underlay network."; + } + } + list node { + key "node-id"; + description + "The inventory of nodes of this network."; + leaf node-id { + type node-id; + description + "Identifies a node uniquely within the containing + network."; + } + list supporting-node { + key "network-ref node-ref"; + description + "Represents another node, in an underlay network, that + this node is supported by. Used to represent layering + structure."; + leaf network-ref { + type leafref { + path "../../../supporting-network/network-ref"; + } + description + "References the underlay network that the + underlay node is part of."; + } + leaf node-ref { + type leafref { + path "/network/node/node-id"; + } + description + "References the underlay node itself."; + } + } + } + } +} diff --git a/ordmodels/network/src/main/yang/org-openroadm-clli-network@2017-06-26.yang b/ordmodels/network/src/main/yang/org-openroadm-clli-network@2017-06-26.yang index 6dbd262d7..45916db36 100644 --- a/ordmodels/network/src/main/yang/org-openroadm-clli-network@2017-06-26.yang +++ b/ordmodels/network/src/main/yang/org-openroadm-clli-network@2017-06-26.yang @@ -2,7 +2,7 @@ module org-openroadm-clli-network { namespace "http://org/openroadm/clli/network"; prefix cn; - import ietf-network { + import old-ietf-network { prefix nd; revision-date 2015-06-08; } diff --git a/ordmodels/network/src/main/yang/org-openroadm-network-topology@2017-09-29.yang b/ordmodels/network/src/main/yang/org-openroadm-network-topology@2017-09-29.yang index 817cdf164..afa5f7162 100644 --- a/ordmodels/network/src/main/yang/org-openroadm-network-topology@2017-09-29.yang +++ b/ordmodels/network/src/main/yang/org-openroadm-network-topology@2017-09-29.yang @@ -2,11 +2,11 @@ module org-openroadm-network-topology { namespace "http://org/openroadm/network/topology"; prefix topo; - import ietf-network { + import old-ietf-network { prefix nd; revision-date 2015-06-08; } - import ietf-network-topology { + import old-ietf-network-topology { prefix nwt; revision-date 2015-06-08; } diff --git a/ordmodels/network/src/main/yang/org-openroadm-network-types@2017-09-29.yang b/ordmodels/network/src/main/yang/org-openroadm-network-types@2017-09-29.yang index bfc6da9c4..308f7124f 100644 --- a/ordmodels/network/src/main/yang/org-openroadm-network-types@2017-09-29.yang +++ b/ordmodels/network/src/main/yang/org-openroadm-network-types@2017-09-29.yang @@ -2,7 +2,7 @@ module org-openroadm-network-types { namespace "http://org/openroadm/network/types"; prefix nt; - import ietf-network-topology { + import old-ietf-network-topology { prefix nwt; revision-date 2015-06-08; } diff --git a/ordmodels/network/src/main/yang/org-openroadm-network@2017-09-29.yang b/ordmodels/network/src/main/yang/org-openroadm-network@2017-09-29.yang index cb9498675..8a87a3a76 100644 --- a/ordmodels/network/src/main/yang/org-openroadm-network@2017-09-29.yang +++ b/ordmodels/network/src/main/yang/org-openroadm-network@2017-09-29.yang @@ -2,7 +2,7 @@ module org-openroadm-network { namespace "http://org/openroadm/network"; prefix net; - import ietf-network { + import old-ietf-network { prefix nd; revision-date 2015-06-08; } diff --git a/ordmodels/network/src/main/yang/org-openroadm-opposite-links@2017-09-29.yang b/ordmodels/network/src/main/yang/org-openroadm-opposite-links@2017-09-29.yang index 67641777c..36bdbd8c0 100644 --- a/ordmodels/network/src/main/yang/org-openroadm-opposite-links@2017-09-29.yang +++ b/ordmodels/network/src/main/yang/org-openroadm-opposite-links@2017-09-29.yang @@ -2,11 +2,11 @@ module org-openroadm-opposite-links { namespace "http://org/openroadm/opposite/links"; prefix opp-links; - import ietf-network { + import old-ietf-network { prefix nd; revision-date 2015-06-08; } - import ietf-network-topology { + import old-ietf-network-topology { prefix nwt; revision-date 2015-06-08; } diff --git a/ordmodels/network/src/main/yang/org-openroadm-otn-network-topology@2017-09-29.yang b/ordmodels/network/src/main/yang/org-openroadm-otn-network-topology@2017-09-29.yang index 2b890510d..3de95e74a 100644 --- a/ordmodels/network/src/main/yang/org-openroadm-otn-network-topology@2017-09-29.yang +++ b/ordmodels/network/src/main/yang/org-openroadm-otn-network-topology@2017-09-29.yang @@ -2,11 +2,11 @@ module org-openroadm-otn-network-topology { namespace "http://org/openroadm/otn/network/topology"; prefix otn-topo; - import ietf-network { + import old-ietf-network { prefix nd; revision-date 2015-06-08; } - import ietf-network-topology { + import old-ietf-network-topology { prefix nwt; revision-date 2015-06-08; } diff --git a/ordmodels/network/src/main/yang/org-openroadm-xponder@2017-09-29.yang b/ordmodels/network/src/main/yang/org-openroadm-xponder@2017-09-29.yang index d6934d2be..f6f03b8dc 100644 --- a/ordmodels/network/src/main/yang/org-openroadm-xponder@2017-09-29.yang +++ b/ordmodels/network/src/main/yang/org-openroadm-xponder@2017-09-29.yang @@ -2,11 +2,11 @@ module org-openroadm-xponder { namespace "http://org/openroadm/xponder"; prefix xpndr; - import ietf-network { + import old-ietf-network { prefix nd; revision-date 2015-06-08; } - import ietf-network-topology { + import old-ietf-network-topology { prefix nwt; revision-date 2015-06-08; } diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/PceCalculation.java b/pce/src/main/java/org/opendaylight/transportpce/pce/PceCalculation.java index 3f6bccdee..aede67294 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/PceCalculation.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/PceCalculation.java @@ -9,14 +9,12 @@ package org.opendaylight.transportpce.pce; import com.google.common.base.Optional; - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -149,7 +147,7 @@ public class PceCalculation { return false; } this.allNodes = nw.getNode(); - Network1 nw1 = nw.getAugmentation(Network1.class); + Network1 nw1 = nw.augmentation(Network1.class); this.allLinks = nw1.getLink(); if ((this.allNodes == null) || this.allNodes.isEmpty()) { @@ -353,7 +351,7 @@ public class PceCalculation { } // extract node type - Node1 node1 = node.getAugmentation(Node1.class); + Node1 node1 = node.augmentation(Node1.class); if (node1 == null) { LOG.error("validateNode: no Node1 (type) Augmentation for node: [{}]. Node is ignored", nodeId.getValue()); diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/PceLink.java b/pce/src/main/java/org/opendaylight/transportpce/pce/PceLink.java index 1ed5c122e..f9278ada6 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/PceLink.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/PceLink.java @@ -68,7 +68,7 @@ public class PceLink { OpenroadmLinkType tmplType = null; // ID and type - link1 = link.getAugmentation(Link1.class); + link1 = link.augmentation(Link1.class); if (link1 == null) { this.isValid = false; LOG.error("PceLink: No Link augmentation available. Link is ignored {}", this.linkId); @@ -88,7 +88,7 @@ public class PceLink { // opposite link LinkId tmpoppositeLink = null; org.opendaylight.yang.gen.v1.http.org.openroadm.opposite.links.rev170929.Link1 linkOpposite = link - .getAugmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.opposite.links.rev170929.Link1.class); + .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.opposite.links.rev170929.Link1.class); tmpoppositeLink = linkOpposite.getOppositeLink(); LOG.debug("PceLink: reading oppositeLink. {}", linkOpposite.toString()); if (tmpoppositeLink == null) { @@ -103,7 +103,7 @@ public class PceLink { Long tmplatency = (long)0; Link1 link1 = null; // latency - link1 = link.getAugmentation(Link1.class); + link1 = link.augmentation(Link1.class); tmplatency = link1.getLinkLatency(); if (tmplatency == null) { tmplatency = (long) 0; diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/PceNode.java b/pce/src/main/java/org/opendaylight/transportpce/pce/PceNode.java index 3ec85d9f7..1fc66905b 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/PceNode.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/PceNode.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev170929.Node1; import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev170929.TerminationPoint1; import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev170929.OpenroadmNodeType; @@ -52,34 +51,34 @@ public class PceNode { if ((node == null) || (nodeId == null) || (nodeType == null)) { LOG.error("PceNode: one of parameters is not populated : nodeId, node type"); - valid = false; + this.valid = false; } } public void initWLlist() { - availableWLindex.clear(); + this.availableWLindex.clear(); if (!isValid()) { return; } - Node1 node1 = node.getAugmentation(Node1.class); + Node1 node1 = this.node.augmentation(Node1.class); - switch (nodeType) { + switch (this.nodeType) { case SRG: List srgAvailableWL = node1.getSrgAttributes().getAvailableWavelengths(); if (srgAvailableWL == null) { - valid = false; + this.valid = false; LOG.error("initWLlist: SRG AvailableWavelengths is empty for node {}", this.toString()); return; } for (org.opendaylight.yang.gen.v1.http.org.openroadm.srg.rev170929.srg.node.attributes .AvailableWavelengths awl : srgAvailableWL) { - availableWLindex.add(awl.getIndex()); + this.availableWLindex.add(awl.getIndex()); LOG.debug("initWLlist: SRG next = {} in {}" , awl.getIndex() , this.toString()); } @@ -90,14 +89,14 @@ public class PceNode { .AvailableWavelengths> degAvailableWL = node1.getDegreeAttributes().getAvailableWavelengths(); if (degAvailableWL == null) { - valid = false; + this.valid = false; LOG.error("initWLlist: DEG AvailableWavelengths is empty for node {}", this.toString()); return; } for (org.opendaylight.yang.gen.v1.http.org.openroadm.degree.rev170929.degree.node.attributes .AvailableWavelengths awl : degAvailableWL) { - availableWLindex.add(awl.getIndex()); + this.availableWLindex.add(awl.getIndex()); LOG.debug("initWLlist: DEGREE next = {} in {}", awl.getIndex(), this.toString()); } @@ -107,21 +106,21 @@ public class PceNode { // HARD CODED 96 for (long i = 1; i <= 96; i++) { - availableWLindex.add(i); + this.availableWLindex.add(i); } break; default: - LOG.error("initWLlist: unsupported node type {} in node {}" , nodeType, this.toString()); + LOG.error("initWLlist: unsupported node type {} in node {}" , this.nodeType, this.toString()); break; } - if (availableWLindex.size() == 0) { + if (this.availableWLindex.size() == 0) { LOG.debug("initWLlist: There are no available wavelengths in node {}", this.toString()); - valid = false; + this.valid = false; } - LOG.debug("initWLlist: availableWLindex size = {} in {}" , availableWLindex.size(), this.toString()); + LOG.debug("initWLlist: availableWLindex size = {} in {}" , this.availableWLindex.size(), this.toString()); return; } @@ -133,32 +132,32 @@ public class PceNode { } org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev150608.Node1 nodeTp = - node.getAugmentation( + this.node.augmentation( org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev150608.Node1.class); List allTps = nodeTp.getTerminationPoint(); if (allTps == null) { - valid = false; + this.valid = false; LOG.error("initXndrTps: XPONDER TerminationPoint list is empty for node {}", this.toString()); return; } - valid = false; + this.valid = false; for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev150608.network.node .TerminationPoint tp : allTps) { - TerminationPoint1 tp1 = tp.getAugmentation(TerminationPoint1.class); + TerminationPoint1 tp1 = tp.augmentation(TerminationPoint1.class); if (tp1.getTpType() == OpenroadmTpType.XPONDERNETWORK) { if (tp1.getXpdrNetworkAttributes().getWavelength() != null) { - usedXpndrNWTps.add(tp.getTpId().getValue()); + this.usedXpndrNWTps.add(tp.getTpId().getValue()); LOG.debug("initWLlist: XPONDER tp = {} is used", tp.getTpId().getValue()); } else { - valid = true; + this.valid = true; } // find Client of this network TP @@ -166,9 +165,9 @@ public class PceNode { if ((client.equals("")) || (client == null)) { LOG.error("initXndrTps: XPONDER {} NW TP doesn't have defined Client {}", this.toString(),tp.getTpId().getValue()); - valid = false; + this.valid = false; } - clientPerNwTp.put(tp.getTpId().getValue(), client); + this.clientPerNwTp.put(tp.getTpId().getValue(), client); } } @@ -181,25 +180,25 @@ public class PceNode { } public boolean checkTP(String tp) { - if (usedXpndrNWTps.contains(tp)) { + if (this.usedXpndrNWTps.contains(tp)) { return false; } return true; } public boolean checkWL(long index) { - if (availableWLindex.contains(index)) { + if (this.availableWLindex.contains(index)) { return true; } return false; } public boolean isValid() { - return valid; + return this.valid; } public List getAvailableWLs() { - return availableWLindex; + return this.availableWLindex; } public void addOutgoingLink(PceLink outLink) { @@ -207,16 +206,16 @@ public class PceNode { } public List getOutgoingLinks() { - return outgoingLinks; + return this.outgoingLinks; } public String getClient(String tp) { - return clientPerNwTp.get(tp); + return this.clientPerNwTp.get(tp); } @Override public String toString() { - return "PceNode type=" + nodeType + " ID=" + nodeId.getValue(); + return "PceNode type=" + this.nodeType + " ID=" + this.nodeId.getValue(); } } diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/PcePathDescription.java b/pce/src/main/java/org/opendaylight/transportpce/pce/PcePathDescription.java index 5fc23c886..6c3108217 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/PcePathDescription.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/PcePathDescription.java @@ -8,11 +8,9 @@ package org.opendaylight.transportpce.pce; import com.google.common.collect.ImmutableList; - import java.util.ArrayList; import java.util.List; import java.util.Map; - import org.opendaylight.transportpce.common.ResponseCodes; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirectionBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ZToADirectionBuilder; @@ -43,7 +41,7 @@ public class PcePathDescription { private PceResult rc; public PceResult getReturnStructure() { - return rc; + return this.rc; } private Map allPceLinks = null; @@ -58,34 +56,34 @@ public class PcePathDescription { } public PceResult buildDescriptions() { - LOG.info("In buildDescriptions: AtoZ {}", pathAtoZ.toString()); + LOG.info("In buildDescriptions: AtoZ {}", this.pathAtoZ.toString()); List atozList = new ArrayList(); - if (pathAtoZ == null) { - rc.setRC(ResponseCodes.RESPONSE_FAILED); + if (this.pathAtoZ == null) { + this.rc.setRC(ResponseCodes.RESPONSE_FAILED); LOG.error("In buildDescriptions: there is empty AtoZ path"); - return rc; + return this.rc; } - buildAtoZ(atozList, pathAtoZ); + buildAtoZ(atozList, this.pathAtoZ); - rc.setAtoZDirection(new AToZDirectionBuilder().setRate(rc.getRate()) - .setAToZWavelengthNumber(rc.getResultWavelength()).setAToZ(atozList).build()); + this.rc.setAtoZDirection(new AToZDirectionBuilder().setRate(this.rc.getRate()) + .setAToZWavelengthNumber(this.rc.getResultWavelength()).setAToZ(atozList).build()); - pathZtoA = ImmutableList.copyOf(pathAtoZ).reverse(); - LOG.info("In buildDescriptions: ZtoA {}", pathZtoA.toString()); + this.pathZtoA = ImmutableList.copyOf(this.pathAtoZ).reverse(); + LOG.info("In buildDescriptions: ZtoA {}", this.pathZtoA.toString()); List ztoaList = new ArrayList(); - if (pathZtoA == null) { - rc.setRC(ResponseCodes.RESPONSE_FAILED); + if (this.pathZtoA == null) { + this.rc.setRC(ResponseCodes.RESPONSE_FAILED); LOG.error("In buildDescriptions: there is empty ZtoA path"); - return rc; + return this.rc; } - buildZtoA(ztoaList, pathZtoA); + buildZtoA(ztoaList, this.pathZtoA); - rc.setZtoADirection(new ZToADirectionBuilder().setRate(rc.getRate()) - .setZToAWavelengthNumber(rc.getResultWavelength()).setZToA(ztoaList).build()); + this.rc.setZtoADirection(new ZToADirectionBuilder().setRate(this.rc.getRate()) + .setZToAWavelengthNumber(this.rc.getResultWavelength()).setZToA(ztoaList).build()); - return rc; + return this.rc; } private void buildAtoZ(List etoeList, List path) { @@ -104,7 +102,7 @@ public class PcePathDescription { AToZKey clientKey = new AToZKey(index.toString()); Resource clientResource = new ResourceBuilder().setResource(stp).build(); - AToZ firstResource = new AToZBuilder().setId(tpName).setKey(clientKey).setResource(clientResource).build(); + AToZ firstResource = new AToZBuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build(); etoeList.add(firstResource); index++; @@ -122,7 +120,7 @@ public class PcePathDescription { // Source Resource AToZKey sourceKey = new AToZKey(index.toString()); Resource nodeResource1 = new ResourceBuilder().setResource(sourceNode).build(); - AToZ srcResource = new AToZBuilder().setId(srcName).setKey(sourceKey).setResource(nodeResource1).build(); + AToZ srcResource = new AToZBuilder().setId(srcName).withKey(sourceKey).setResource(nodeResource1).build(); index++; etoeList.add(srcResource); @@ -136,7 +134,7 @@ public class PcePathDescription { // Resource AToZKey srcTPKey = new AToZKey(index.toString());// tpName); Resource tpResource1 = new ResourceBuilder().setResource(stp).build(); - AToZ stpResource = new AToZBuilder().setId(tpName).setKey(srcTPKey).setResource(tpResource1).build(); + AToZ stpResource = new AToZBuilder().setId(tpName).withKey(srcTPKey).setResource(tpResource1).build(); index++; etoeList.add(stpResource); @@ -150,7 +148,7 @@ public class PcePathDescription { // Link Resource AToZKey linkKey = new AToZKey(index.toString()); Resource nodeResource2 = new ResourceBuilder().setResource(atozLink).build(); - AToZ linkResource = new AToZBuilder().setId(linkName).setKey(linkKey).setResource(nodeResource2).build(); + AToZ linkResource = new AToZBuilder().setId(linkName).withKey(linkKey).setResource(nodeResource2).build(); index++; etoeList.add(linkResource); @@ -165,7 +163,7 @@ public class PcePathDescription { // Resource AToZKey destTPKey = new AToZKey(index.toString()); Resource tpResource2 = new ResourceBuilder().setResource(dtp).build(); - AToZ ttpResource = new AToZBuilder().setId(tpName).setKey(destTPKey).setResource(tpResource2).build(); + AToZ ttpResource = new AToZBuilder().setId(tpName).withKey(destTPKey).setResource(tpResource2).build(); index++; etoeList.add(ttpResource); @@ -177,7 +175,7 @@ public class PcePathDescription { // Target Resource AToZKey targetKey = new AToZKey(index.toString()); Resource nodeResource3 = new ResourceBuilder().setResource(targetNode).build(); - lastResource = new AToZBuilder().setId(destName).setKey(targetKey).setResource(nodeResource3).build(); + lastResource = new AToZBuilder().setId(destName).withKey(targetKey).setResource(nodeResource3).build(); lastLink = pcelink; } @@ -196,7 +194,7 @@ public class PcePathDescription { index++; clientKey = new AToZKey(index.toString()); clientResource = new ResourceBuilder().setResource(stp).build(); - lastResource = new AToZBuilder().setId(tpName).setKey(clientKey).setResource(clientResource).build(); + lastResource = new AToZBuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build(); etoeList.add(lastResource); } @@ -207,7 +205,7 @@ public class PcePathDescription { ZToA lastResource = null; // build Z size Client TP - PceLink pcelink = allPceLinks.get(path.get(0).getOppositeLink()); + PceLink pcelink = this.allPceLinks.get(path.get(0).getOppositeLink()); String tpName = pcelink.getClient(); String xname = pcelink.getSourceId().getValue(); TerminationPoint stp = new TerminationPointBuilder() @@ -217,13 +215,13 @@ public class PcePathDescription { ZToAKey clientKey = new ZToAKey(index.toString()); Resource clientResource = new ResourceBuilder().setResource(stp).build(); - ZToA firstResource = new ZToABuilder().setId(tpName).setKey(clientKey).setResource(clientResource).build(); + ZToA firstResource = new ZToABuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build(); etoelist.add(firstResource); index++; for (PceLink pcelinkAtoZ : path) { - pcelink = allPceLinks.get(pcelinkAtoZ.getOppositeLink()); + pcelink = this.allPceLinks.get(pcelinkAtoZ.getOppositeLink()); LOG.debug("link to oppsite: {} to {}", pcelinkAtoZ.toString(), pcelink.toString()); String srcName = pcelink.getSourceId().getValue(); @@ -239,7 +237,7 @@ public class PcePathDescription { // Source Resource ZToAKey sourceKey = new ZToAKey(index.toString()); Resource nodeResource1 = new ResourceBuilder().setResource(sourceNode).build(); - ZToA srcResource = new ZToABuilder().setId(srcName).setKey(sourceKey).setResource(nodeResource1).build(); + ZToA srcResource = new ZToABuilder().setId(srcName).withKey(sourceKey).setResource(nodeResource1).build(); index++; etoelist.add(srcResource); @@ -253,7 +251,7 @@ public class PcePathDescription { // Resource ZToAKey srcTPKey = new ZToAKey(index.toString()); Resource tpResource1 = new ResourceBuilder().setResource(stp).build(); - ZToA stpResource = new ZToABuilder().setId(tpName).setKey(srcTPKey).setResource(tpResource1).build(); + ZToA stpResource = new ZToABuilder().setId(tpName).withKey(srcTPKey).setResource(tpResource1).build(); index++; etoelist.add(stpResource); @@ -266,7 +264,7 @@ public class PcePathDescription { // Link Resource ZToAKey linkKey = new ZToAKey(index.toString()); Resource nodeResource2 = new ResourceBuilder().setResource(ztoaLink).build(); - ZToA linkResource = new ZToABuilder().setId(linkName).setKey(linkKey).setResource(nodeResource2).build(); + ZToA linkResource = new ZToABuilder().setId(linkName).withKey(linkKey).setResource(nodeResource2).build(); index++; etoelist.add(linkResource); @@ -281,7 +279,7 @@ public class PcePathDescription { // Resource ZToAKey destTPKey = new ZToAKey(index.toString()); Resource tpResource2 = new ResourceBuilder().setResource(ttp).build(); - ZToA ttpResource = new ZToABuilder().setId(tpName).setKey(destTPKey).setResource(tpResource2).build(); + ZToA ttpResource = new ZToABuilder().setId(tpName).withKey(destTPKey).setResource(tpResource2).build(); index++; etoelist.add(ttpResource); @@ -292,7 +290,7 @@ public class PcePathDescription { // Target Resource ZToAKey targetKey = new ZToAKey(index.toString()); Resource nodeResource3 = new ResourceBuilder().setResource(targetNode).build(); - lastResource = new ZToABuilder().setId(destName).setKey(targetKey).setResource(nodeResource3).build(); + lastResource = new ZToABuilder().setId(destName).withKey(targetKey).setResource(nodeResource3).build(); lastLink = pcelink; } @@ -310,7 +308,7 @@ public class PcePathDescription { index++; clientKey = new ZToAKey(index.toString()); clientResource = new ResourceBuilder().setResource(stp).build(); - lastResource = new ZToABuilder().setId(tpName).setKey(clientKey).setResource(clientResource).build(); + lastResource = new ZToABuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build(); etoelist.add(lastResource); } diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImpl.java b/pce/src/main/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImpl.java index 9b1d1f2f7..824550d32 100755 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImpl.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImpl.java @@ -7,12 +7,10 @@ */ package org.opendaylight.transportpce.pce.impl; -import java.util.concurrent.Future; - +import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.transportpce.pce.service.PathComputationService; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.CancelResourceReserveInput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.CancelResourceReserveOutput; - import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestInput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PceService; @@ -40,16 +38,16 @@ public class PceServiceRPCImpl implements PceService { } @Override - public Future> cancelResourceReserve(CancelResourceReserveInput input) { + public ListenableFuture> cancelResourceReserve(CancelResourceReserveInput input) { LOG.info("RPC cancelResourceReserve request received"); - return RpcResultBuilder.success(pathComputationService.cancelResourceReserve(input)).buildFuture(); + return RpcResultBuilder.success(this.pathComputationService.cancelResourceReserve(input)).buildFuture(); } @Override - public Future> pathComputationRequest(PathComputationRequestInput input) { + public ListenableFuture> pathComputationRequest(PathComputationRequestInput input) { LOG.info("RPC path computation request received"); - return RpcResultBuilder.success(pathComputationService.pathComputationRequest(input)).buildFuture(); + return RpcResultBuilder.success(this.pathComputationService.pathComputationRequest(input)).buildFuture(); } } diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/ModelMappingUtils.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/ModelMappingUtils.java index 6305d34aa..b747475a5 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/ModelMappingUtils.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/ModelMappingUtils.java @@ -7,12 +7,12 @@ */ package org.opendaylight.transportpce.renderer; +import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; -import java.util.concurrent.Future; import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon; @@ -74,7 +74,7 @@ public final class ModelMappingUtils { return cmBldr.build(); } - public static Future> + public static ListenableFuture> createRpcResponse(ServiceImplementationRequestOutput payload) { return RpcResultBuilder.success(payload).buildFuture(); } @@ -165,7 +165,7 @@ public final class ModelMappingUtils { } else if (desID == null) { desID = values.getTpID(); NodesBuilder nb = new NodesBuilder(); - nb.setKey(new NodesKey(values.getNodeID())); + nb.withKey(new NodesKey(values.getNodeID())); nb.setDestTp(desID); nb.setSrcTp(srcID); list.add(nb.build()); @@ -241,7 +241,7 @@ public final class ModelMappingUtils { } else if (desID == null) { desID = values.getTpID(); NodesBuilder nb = new NodesBuilder(); - nb.setKey(new NodesKey(values.getNodeID())); + nb.withKey(new NodesKey(values.getNodeID())); nb.setDestTp(desID); nb.setSrcTp(srcID); list.add(nb.build()); @@ -261,7 +261,7 @@ public final class ModelMappingUtils { } public static int[] findTheLongestSubstring(String s1, String s2) { - if (s1 == null || s2 == null) { + if ((s1 == null) || (s2 == null)) { return null; } int[][] dp = new int[s1.length() + 1][s2.length() + 1]; diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java index a9814833c..7636b26a1 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java @@ -9,7 +9,6 @@ package org.opendaylight.transportpce.renderer.openroadminterface; import java.math.BigDecimal; - import org.opendaylight.transportpce.common.mapping.PortMapping; import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException; import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces; @@ -245,7 +244,7 @@ public class OpenRoadmInterfaceFactory { interfaceBuilder.setAdministrativeState(AdminStates.InService); interfaceBuilder.setType(type); interfaceBuilder.setName(key); - interfaceBuilder.setKey(new InterfaceKey(key)); + interfaceBuilder.withKey(new InterfaceKey(key)); return interfaceBuilder; } } diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java index d0212f3d6..b9ec7e89f 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java @@ -9,7 +9,6 @@ package org.opendaylight.transportpce.renderer.provisiondevice; import com.google.common.collect.Sets; - import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -23,7 +22,6 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; @@ -208,7 +206,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { } NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder(); - nodeInterfaceBuilder.setKey(new NodeInterfaceKey(nodeId)); + nodeInterfaceBuilder.withKey(new NodeInterfaceKey(nodeId)); nodeInterfaceBuilder.setNodeId(nodeId); nodeInterfaceBuilder.setConnectionId(createdConnections); nodeInterfaceBuilder.setEthInterfaceId(createdEthInterfaces); @@ -407,7 +405,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { } } failedToRollbackList.add(new FailedToRollbackBuilder() - .setKey(new FailedToRollbackKey(nodeId)) + .withKey(new FailedToRollbackKey(nodeId)) .setNodeId(nodeId) .setInterface(failedInterfaces) .build() @@ -421,7 +419,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { private boolean alarmSuppressionNodeRegistration(ServicePathInput input) { NodelistBuilder nodeListBuilder = new NodelistBuilder(); - nodeListBuilder.setKey(new NodelistKey(input.getServiceName())); + nodeListBuilder.withKey(new NodelistKey(input.getServiceName())); nodeListBuilder.setServiceName(input.getServiceName()); List nodeList = new ArrayList<>(); @@ -493,7 +491,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { servicesBuilder = new ServicesBuilder(services.get()); } else { servicesBuilder = new ServicesBuilder(); - servicesBuilder.setKey(serviceKey); + servicesBuilder.withKey(serviceKey); } servicesBuilder.setTopology(topo); diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java index f5c35496f..0edd950b3 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java @@ -8,8 +8,7 @@ package org.opendaylight.transportpce.renderer.rpcs; -import java.util.concurrent.Future; - +import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererRollbackInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererRollbackOutput; @@ -56,13 +55,13 @@ public class DeviceRendererRPCImpl implements RendererService { * @return Result of the request */ @Override - public Future> servicePath(ServicePathInput input) { + public ListenableFuture> servicePath(ServicePathInput input) { if (input.getOperation().getIntValue() == 1) { LOG.info("Create operation request received"); - return RpcResultBuilder.success(deviceRenderer.setupServicePath(input, null)).buildFuture(); + return RpcResultBuilder.success(this.deviceRenderer.setupServicePath(input, null)).buildFuture(); } else if (input.getOperation().getIntValue() == 2) { LOG.info("Delete operation request received"); - return RpcResultBuilder.success(deviceRenderer.deleteServicePath(input)).buildFuture(); + return RpcResultBuilder.success(this.deviceRenderer.deleteServicePath(input)).buildFuture(); } return RpcResultBuilder.success(new ServicePathOutputBuilder().setResult("Invalid operation")).buildFuture(); } @@ -74,7 +73,7 @@ public class DeviceRendererRPCImpl implements RendererService { * @return Success flag and nodes which failed to rollback */ @Override - public Future> rendererRollback(RendererRollbackInput input) { - return RpcResultBuilder.success(deviceRenderer.rendererRollback(input)).buildFuture(); + public ListenableFuture> rendererRollback(RendererRollbackInput input) { + return RpcResultBuilder.success(this.deviceRenderer.rendererRollback(input)).buildFuture(); } } diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/TransportPCEServicePathRPCImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/TransportPCEServicePathRPCImpl.java index 4b3ec1074..be29295f0 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/TransportPCEServicePathRPCImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/TransportPCEServicePathRPCImpl.java @@ -7,8 +7,7 @@ */ package org.opendaylight.transportpce.renderer.rpcs; -import java.util.concurrent.Future; - +import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.transportpce.renderer.ModelMappingUtils; import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveInput; @@ -35,27 +34,27 @@ public class TransportPCEServicePathRPCImpl implements TransportpceServicepathSe } @Override - public Future> cancelResourceReserve(CancelResourceReserveInput input) { + public ListenableFuture> cancelResourceReserve(CancelResourceReserveInput input) { // TODO Auto-generated method stub return null; } @Override - public Future> serviceDelete(ServiceDeleteInput input) { + public ListenableFuture> serviceDelete(ServiceDeleteInput input) { // TODO Auto-generated method stub return null; } @Override - public Future> serviceImplementationRequest( + public ListenableFuture> serviceImplementationRequest( ServiceImplementationRequestInput input) { String serviceName = input.getServiceName(); LOG.info("Calling RPC service impl request {} {}", serviceName); - return ModelMappingUtils.createRpcResponse(rendererServiceOperations.serviceImplementation(input)); + return ModelMappingUtils.createRpcResponse(this.rendererServiceOperations.serviceImplementation(input)); } @Override - public Future> pathComputationRequest(PathComputationRequestInput input) { + public ListenableFuture> pathComputationRequest(PathComputationRequestInput input) { // TODO Auto-generated method stub return null; } diff --git a/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImplTest.java b/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImplTest.java index 8c32e76c3..47085695d 100644 --- a/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImplTest.java +++ b/renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImplTest.java @@ -161,7 +161,7 @@ public class DeviceRendererServiceImplTest extends AbstractTest { NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder(); nodeInterfaceBuilder.setNodeId("node1"); - nodeInterfaceBuilder.setKey(new NodeInterfaceKey("node1")); + nodeInterfaceBuilder.withKey(new NodeInterfaceKey("node1")); List connectionID = new ArrayList<>(); connectionID.add("node1-PP"); nodeInterfaceBuilder.setConnectionId(connectionID); diff --git a/renderer/src/test/java/org/opendaylight/transportpce/renderer/stub/OlmServiceStub.java b/renderer/src/test/java/org/opendaylight/transportpce/renderer/stub/OlmServiceStub.java index cd559929d..473088079 100644 --- a/renderer/src/test/java/org/opendaylight/transportpce/renderer/stub/OlmServiceStub.java +++ b/renderer/src/test/java/org/opendaylight/transportpce/renderer/stub/OlmServiceStub.java @@ -7,8 +7,8 @@ */ package org.opendaylight.transportpce.renderer.stub; +import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; -import java.util.concurrent.Future; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossBaseInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossBaseOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossCurrentInput; @@ -29,33 +29,33 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; public class OlmServiceStub implements OlmService { - @Override public Future> calculateSpanlossCurrent( + @Override public ListenableFuture> calculateSpanlossCurrent( CalculateSpanlossCurrentInput input) { return null; } - @Override public Future> getPm(GetPmInput input) { + @Override public ListenableFuture> getPm(GetPmInput input) { GetPmOutput output = new GetPmOutputBuilder() .setNodeId("node1").setMeasurements(new ArrayList<>()).build(); return RpcResultBuilder.success( output).buildFuture(); } - @Override public Future> servicePowerTurndown( + @Override public ListenableFuture> servicePowerTurndown( ServicePowerTurndownInput input) { return null; } - @Override public Future> calculateSpanlossBase( + @Override public ListenableFuture> calculateSpanlossBase( CalculateSpanlossBaseInput input) { return null; } - @Override public Future> servicePowerReset(ServicePowerResetInput input) { + @Override public ListenableFuture> servicePowerReset(ServicePowerResetInput input) { return null; } - @Override public Future> servicePowerSetup(ServicePowerSetupInput input) { + @Override public ListenableFuture> servicePowerSetup(ServicePowerSetupInput input) { return RpcResultBuilder.success(new ServicePowerSetupOutputBuilder().build()).buildFuture(); } } diff --git a/renderer/src/test/java/org/opendaylight/transportpce/renderer/utils/MountPointUtils.java b/renderer/src/test/java/org/opendaylight/transportpce/renderer/utils/MountPointUtils.java index 79690dce3..4a9dc7d42 100644 --- a/renderer/src/test/java/org/opendaylight/transportpce/renderer/utils/MountPointUtils.java +++ b/renderer/src/test/java/org/opendaylight/transportpce/renderer/utils/MountPointUtils.java @@ -65,7 +65,7 @@ public final class MountPointUtils { DeviceTransactionManager deviceTransactionManager) { try { MappingBuilder mappingBuilder = new MappingBuilder(); - mappingBuilder.setKey(new MappingKey(logicalConnPoint)); + mappingBuilder.withKey(new MappingKey(logicalConnPoint)); mappingBuilder.setLogicalConnectionPoint(logicalConnPoint); mappingBuilder.setSupportingOms("OMS"); mappingBuilder.setSupportingPort("8080"); diff --git a/renderer/src/test/java/org/opendaylight/transportpce/renderer/utils/ServiceDataUtils.java b/renderer/src/test/java/org/opendaylight/transportpce/renderer/utils/ServiceDataUtils.java index 39ea8650d..99c65da5d 100644 --- a/renderer/src/test/java/org/opendaylight/transportpce/renderer/utils/ServiceDataUtils.java +++ b/renderer/src/test/java/org/opendaylight/transportpce/renderer/utils/ServiceDataUtils.java @@ -51,7 +51,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer public final class ServiceDataUtils { public static Nodes createNode(String nodeId, String srcTp, String dstTp) { - return new NodesBuilder().setNodeId(nodeId).setKey(new NodesKey(nodeId)).setSrcTp(srcTp) + return new NodesBuilder().setNodeId(nodeId).withKey(new NodesKey(nodeId)).setSrcTp(srcTp) .setDestTp(dstTp).build(); } @@ -115,9 +115,9 @@ public final class ServiceDataUtils { org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource .resource.resource.Node node2 = nodesBuilder.setNodeIdentifier(new NodeIdentifierBuilder() .setNodeId("XPONDER-1-2").build()).build(); - AToZ atoZ = new AToZBuilder().setId("1").setKey(new AToZKey("1")).setResource(new ResourceBuilder() + AToZ atoZ = new AToZBuilder().setId("1").withKey(new AToZKey("1")).setResource(new ResourceBuilder() .setResource(node1).build()).build(); - AToZ atoZ2 = new AToZBuilder().setId("1").setKey(new AToZKey("1")).setResource(new ResourceBuilder() + AToZ atoZ2 = new AToZBuilder().setId("1").withKey(new AToZKey("1")).setResource(new ResourceBuilder() .setResource(node2).build()).build(); atoZList.add(atoZ); atoZList.add(atoZ2); @@ -127,9 +127,9 @@ public final class ServiceDataUtils { .setAToZ(atoZList) .build(); List ztoAList = new ArrayList(); - ZToA ztoA = new ZToABuilder().setId("1").setKey(new ZToAKey("1")).setResource(new ResourceBuilder() + ZToA ztoA = new ZToABuilder().setId("1").withKey(new ZToAKey("1")).setResource(new ResourceBuilder() .setResource(node1).build()).build(); - ZToA ztoA2 = new ZToABuilder().setId("1").setKey(new ZToAKey("1")).setResource(new ResourceBuilder() + ZToA ztoA2 = new ZToABuilder().setId("1").withKey(new ZToAKey("1")).setResource(new ResourceBuilder() .setResource(node2).build()).build(); ztoAList.add(ztoA); ztoAList.add(ztoA2); @@ -153,9 +153,9 @@ public final class ServiceDataUtils { TerminationPoint terminationPoint2 = terminationPointBuilder .setTerminationPointIdentifier(new TerminationPointIdentifierBuilder().setNodeId("XPONDER-1-2") .setTpId("XPONDER-1-2-" + tpId).build()).build(); - AToZ atoZ = new AToZBuilder().setId("1").setKey(new AToZKey("1")).setResource(new ResourceBuilder() + AToZ atoZ = new AToZBuilder().setId("1").withKey(new AToZKey("1")).setResource(new ResourceBuilder() .setResource(terminationPoint).build()).build(); - AToZ atoZ2 = new AToZBuilder().setId("2").setKey(new AToZKey("2")).setResource(new ResourceBuilder() + AToZ atoZ2 = new AToZBuilder().setId("2").withKey(new AToZKey("2")).setResource(new ResourceBuilder() .setResource(terminationPoint2).build()).build(); atoZList.add(atoZ); atoZList.add(atoZ2); @@ -165,9 +165,9 @@ public final class ServiceDataUtils { .setAToZ(atoZList) .build(); List ztoAList = new ArrayList(); - ZToA ztoA = new ZToABuilder().setId("1").setKey(new ZToAKey("1")).setResource(new ResourceBuilder() + ZToA ztoA = new ZToABuilder().setId("1").withKey(new ZToAKey("1")).setResource(new ResourceBuilder() .setResource(terminationPoint).build()).build(); - ZToA ztoA2 = new ZToABuilder().setId("2").setKey(new ZToAKey("2")).setResource(new ResourceBuilder() + ZToA ztoA2 = new ZToABuilder().setId("2").withKey(new ZToAKey("2")).setResource(new ResourceBuilder() .setResource(terminationPoint).build()).build(); ztoAList.add(ztoA); ztoAList.add(ztoA2); @@ -190,9 +190,9 @@ public final class ServiceDataUtils { .build(); Link link2 = new LinkBuilder().setLinkIdentifier(new LinkIdentifierBuilder().setLinkId("link 2").build()) .build(); - AToZ atoZ = new AToZBuilder().setId("1").setKey(new AToZKey("1")).setResource(new ResourceBuilder() + AToZ atoZ = new AToZBuilder().setId("1").withKey(new AToZKey("1")).setResource(new ResourceBuilder() .setResource(link1).build()).build(); - AToZ atoZ2 = new AToZBuilder().setId("1").setKey(new AToZKey("1")).setResource(new ResourceBuilder() + AToZ atoZ2 = new AToZBuilder().setId("1").withKey(new AToZKey("1")).setResource(new ResourceBuilder() .setResource(link2).build()).build(); atoZList.add(atoZ); atoZList.add(atoZ2); @@ -202,9 +202,9 @@ public final class ServiceDataUtils { .setAToZ(atoZList) .build(); List ztoAList = new ArrayList(); - ZToA ztoA = new ZToABuilder().setId("1").setKey(new ZToAKey("1")).setResource(new ResourceBuilder() + ZToA ztoA = new ZToABuilder().setId("1").withKey(new ZToAKey("1")).setResource(new ResourceBuilder() .setResource(link1).build()).build(); - ZToA ztoA2 = new ZToABuilder().setId("1").setKey(new ZToAKey("1")).setResource(new ResourceBuilder() + ZToA ztoA2 = new ZToABuilder().setId("1").withKey(new ZToAKey("1")).setResource(new ResourceBuilder() .setResource(link2).build()).build(); ztoAList.add(ztoA); ztoAList.add(ztoA2); diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java index 6e385ca71..e5b44c40d 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java @@ -7,9 +7,9 @@ */ package org.opendaylight.transportpce.servicehandler; +import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Future; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.path.computation.request.input.ServiceAEnd; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.path.computation.request.input.ServiceAEndBuilder; @@ -158,7 +158,7 @@ public final class ModelMappingUtils { return txDirectionBuilder.build(); } - public static Future> createDeleteServiceReply(ServiceDeleteInput input, + public static ListenableFuture> createDeleteServiceReply(ServiceDeleteInput input, String finalAck, String message, String responseCode) { ConfigurationResponseCommonBuilder builder = new ConfigurationResponseCommonBuilder() .setAckFinalIndicator(finalAck).setResponseMessage(message).setResponseCode(responseCode); @@ -173,7 +173,7 @@ public final class ModelMappingUtils { return RpcResultBuilder.success(output).buildFuture(); } - public static Future> createCreateServiceReply(ServiceCreateInput input, + public static ListenableFuture> createCreateServiceReply(ServiceCreateInput input, String finalAck, String message, String responseCode) { ResponseParametersBuilder responseParameters = new ResponseParametersBuilder(); @@ -253,8 +253,8 @@ public final class ModelMappingUtils { for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426 .path.description.atoz.direction.AToZ tmp : pathDescription.getAToZDirection().getAToZ()) { - AToZKey key = new AToZKey(tmp.getKey().getId()); - AToZ atoz = new AToZBuilder().setId(tmp.getId()).setKey(key) + AToZKey key = new AToZKey(tmp.key().getId()); + AToZ atoz = new AToZBuilder().setId(tmp.getId()).withKey(key) // .setResource(tmp.getResource()) .build(); atozList.add(atoz); @@ -263,8 +263,8 @@ public final class ModelMappingUtils { for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426 .path.description.ztoa.direction.ZToA tmp : pathDescription.getZToADirection().getZToA()) { - ZToAKey key = new ZToAKey(tmp.getKey().getId()); - ZToA ztoa = new ZToABuilder().setId(tmp.getId()).setKey(key) + ZToAKey key = new ZToAKey(tmp.key().getId()); + ZToA ztoa = new ZToABuilder().setId(tmp.getId()).withKey(key) // .setResource(tmp.getResource()) .build(); ztoaList.add(ztoa); diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java index 8ad06b26b..f4bbc718d 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java @@ -7,12 +7,12 @@ */ package org.opendaylight.transportpce.servicehandler.impl; +import com.google.common.util.concurrent.ListenableFuture; import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.Optional; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -102,7 +102,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { } @Override - public Future> serviceCreate(ServiceCreateInput input) { + public ListenableFuture> serviceCreate(ServiceCreateInput input) { LOG.info("RPC service creation received"); // Validation OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(input); @@ -181,7 +181,7 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { } @Override - public Future> serviceDelete(ServiceDeleteInput input) { + public ListenableFuture> serviceDelete(ServiceDeleteInput input) { LOG.info("RPC serviceDelete request received for {}", input.getServiceDeleteReqInfo().getServiceName()); String message = ""; @@ -242,35 +242,35 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { } @Override - public Future> serviceFeasibilityCheck( + public ListenableFuture> serviceFeasibilityCheck( ServiceFeasibilityCheckInput input) { throw new UnsupportedOperationException("Not implemented yet"); } @Override - public Future> serviceReconfigure(ServiceReconfigureInput input) { + public ListenableFuture> serviceReconfigure(ServiceReconfigureInput input) { throw new UnsupportedOperationException("Not implemented yet"); } @Override - public Future> serviceRestoration(ServiceRestorationInput input) { + public ListenableFuture> serviceRestoration(ServiceRestorationInput input) { throw new UnsupportedOperationException("Not implemented yet"); } @Override - public Future> equipmentNotification(EquipmentNotificationInput input) { + public ListenableFuture> equipmentNotification(EquipmentNotificationInput input) { // TODO Auto-generated method stub return null; } @Override - public Future> serviceRerouteConfirm(ServiceRerouteConfirmInput input) { + public ListenableFuture> serviceRerouteConfirm(ServiceRerouteConfirmInput input) { // TODO Auto-generated method stub return null; } @Override - public Future> serviceReroute(ServiceRerouteInput input) { + public ListenableFuture> serviceReroute(ServiceRerouteInput input) { InstanceIdentifier servicesIID = InstanceIdentifier.create(ServiceList.class) .child(Services.class, new ServicesKey(input.getServiceName())); ReadOnlyTransaction rtx = this.db.newReadOnlyTransaction(); @@ -330,31 +330,31 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService { } @Override - public Future> serviceReversion(ServiceReversionInput input) { + public ListenableFuture> serviceReversion(ServiceReversionInput input) { // TODO Auto-generated method stub return null; } @Override - public Future> serviceRoll(ServiceRollInput input) { + public ListenableFuture> serviceRoll(ServiceRollInput input) { // TODO Auto-generated method stub return null; } @Override - public Future> networkReOptimization(NetworkReOptimizationInput input) { + public ListenableFuture> networkReOptimization(NetworkReOptimizationInput input) { // TODO Auto-generated method stub return null; } @Override - public Future> tempServiceDelete(TempServiceDeleteInput input) { + public ListenableFuture> tempServiceDelete(TempServiceDeleteInput input) { // TODO Auto-generated method stub return null; } @Override - public Future> tempServiceCreate(TempServiceCreateInput input) { + public ListenableFuture> tempServiceCreate(TempServiceCreateInput input) { // TODO Auto-generated method stub return null; } diff --git a/test-common/src/main/java/org/opendaylight/transportpce/test/common/DataStoreContextImpl.java b/test-common/src/main/java/org/opendaylight/transportpce/test/common/DataStoreContextImpl.java index fb4c6f7b7..b9093fe63 100644 --- a/test-common/src/main/java/org/opendaylight/transportpce/test/common/DataStoreContextImpl.java +++ b/test-common/src/main/java/org/opendaylight/transportpce/test/common/DataStoreContextImpl.java @@ -7,6 +7,7 @@ */ package org.opendaylight.transportpce.test.common; +import com.google.common.collect.ClassToInstanceMap; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; @@ -17,6 +18,7 @@ import java.util.Optional; import java.util.ServiceLoader; import java.util.concurrent.Executors; import javassist.ClassPool; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.binding.api.NotificationService; @@ -37,6 +39,7 @@ import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext; import org.opendaylight.mdsal.binding.generator.util.JavassistUtils; import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider; @@ -71,8 +74,8 @@ public class DataStoreContextImpl implements DataStoreContext { this.dataBroker = createDataBroker(); this.notificationService = createNotificationService(); this.notificationPublishService = createNotificationPublishService(); - for (ListenerRegistration listener : mockedSchemaContext.listeners) { - listener.getInstance().onGlobalContextUpdated(mockedSchemaContext.schemaContext); + for (ListenerRegistration listener : this.mockedSchemaContext.listeners) { + listener.getInstance().onGlobalContextUpdated(this.mockedSchemaContext.schemaContext); } } @@ -100,26 +103,26 @@ public class DataStoreContextImpl implements DataStoreContext { @Override public SchemaContext getSchemaContext() { - return mockedSchemaContext.schemaContext; + return this.mockedSchemaContext.schemaContext; } @Override public BindingNormalizedNodeCodecRegistry getBindingToNormalizedNodeCodec() { - return mockedSchemaContext.bindingStreamCodecs; + return this.mockedSchemaContext.bindingStreamCodecs; } @Override public NotificationService getNotificationService() { - return notificationService; + return this.notificationService; } @Override public NotificationPublishService getNotificationPublishService() { - return notificationPublishService; + return this.notificationPublishService; } private DOMDataBroker createDOMDataBroker() { - return new SerializedDOMDataBroker(datastores, + return new SerializedDOMDataBroker(this.datastores, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor())); } @@ -164,13 +167,13 @@ public class DataStoreContextImpl implements DataStoreContext { this.listeners = ListenerRegistry.create(); this.bindingStreamCodecs = createBindingRegistry(); GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(); - this.bindingToNormalized = new BindingToNormalizedNodeCodec(loading, bindingStreamCodecs); + this.bindingToNormalized = new BindingToNormalizedNodeCodec(loading, this.bindingStreamCodecs); registerSchemaContextListener(this.bindingToNormalized); } @Override public SchemaContext getSchemaContext() { - return schemaContext; + return this.schemaContext; } /** @@ -180,9 +183,9 @@ public class DataStoreContextImpl implements DataStoreContext { * @return SchemaContext a schema context */ private SchemaContext getSchemaContext(List moduleInfos) { - moduleInfoBackedCntxt.addModuleInfos(moduleInfos); + this.moduleInfoBackedCntxt.addModuleInfos(moduleInfos); Optional tryToCreateSchemaContext = - moduleInfoBackedCntxt.tryToCreateSchemaContext().toJavaUtil(); + this.moduleInfoBackedCntxt.tryToCreateSchemaContext().toJavaUtil(); if (!tryToCreateSchemaContext.isPresent()) { LOG.error("Could not create the initial schema context. Schema context is empty"); throw new IllegalStateException(); @@ -192,18 +195,18 @@ public class DataStoreContextImpl implements DataStoreContext { @Override public SchemaContext getGlobalContext() { - return schemaContext; + return this.schemaContext; } @Override public SchemaContext getSessionContext() { - return schemaContext; + return this.schemaContext; } @Override public ListenerRegistration registerSchemaContextListener( SchemaContextListener listener) { - return listeners.register(listener); + return this.listeners.register(listener); } /** @@ -228,12 +231,21 @@ public class DataStoreContextImpl implements DataStoreContext { * @return BindingNormalizedNodeCodecRegistry the resulting binding registry */ private BindingNormalizedNodeCodecRegistry createBindingRegistry() { - BindingRuntimeContext bindingContext = BindingRuntimeContext.create(moduleInfoBackedCntxt, schemaContext); + BindingRuntimeContext bindingContext = BindingRuntimeContext.create(this.moduleInfoBackedCntxt, this.schemaContext); BindingNormalizedNodeCodecRegistry bindingNormalizedNodeCodecRegistry = new BindingNormalizedNodeCodecRegistry( StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))); bindingNormalizedNodeCodecRegistry.onBindingRuntimeContextUpdated(bindingContext); return bindingNormalizedNodeCodecRegistry; } + + /* (non-Javadoc) + * @see org.opendaylight.mdsal.dom.api.DOMExtensibleService#getExtensions() + */ + @Override + public @NonNull ClassToInstanceMap getExtensions() { + // TODO Auto-generated method stub + return null; + } } } diff --git a/tests/stubpce/pom.xml b/tests/stubpce/pom.xml index 755a4a0f3..fb612a0f6 100644 --- a/tests/stubpce/pom.xml +++ b/tests/stubpce/pom.xml @@ -40,6 +40,25 @@ Author: Martial Coulibaly on behalf of Orange + + + + + org.opendaylight.controller + mdsal-artifacts + 1.8.0-SNAPSHOT + import + pom + + + org.opendaylight.netconf + netconf-artifacts + 1.5.0-SNAPSHOT + import + pom + + + @@ -72,6 +91,22 @@ Author: Martial Coulibaly on behalf of Orange transportpce-stubmodels ${project.version} + + org.opendaylight.controller.model + model-topology + + + org.opendaylight.netconf + sal-netconf-connector + + + org.osgi + org.osgi.core + + + org.apache.commons + commons-lang3 + diff --git a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/TpNodeTp.java b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/TpNodeTp.java index 76e40b79a..ab7304b36 100644 --- a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/TpNodeTp.java +++ b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/TpNodeTp.java @@ -10,7 +10,6 @@ package org.opendaylight.transportpce.stubpce; import java.util.ArrayList; import java.util.List; - import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZ; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZKey; @@ -51,10 +50,10 @@ public class TpNodeTp { this.tpOut = out; this.tpIn = in; this.node = node; - resources = new ArrayList(); - atoz = new ArrayList(); - ztoa = new ArrayList(); - ids = new ArrayList(); + this.resources = new ArrayList(); + this.atoz = new ArrayList(); + this.ztoa = new ArrayList(); + this.ids = new ArrayList(); } @@ -62,19 +61,19 @@ public class TpNodeTp { * create resource List. */ public void createListResource() { - ids.clear(); - resources.clear(); - atoz.clear(); - ztoa.clear(); - - resources.add(new ResourceBuilder().setResource(tpIn).build()); - ids.add(tpIn.getTerminationPointIdentifier().getNodeId().concat("-") - .concat(tpIn.getTerminationPointIdentifier().getTpId())); - resources.add(new ResourceBuilder().setResource(node).build()); - ids.add(node.getNodeIdentifier().getNodeId()); - resources.add(new ResourceBuilder().setResource(tpOut).build()); - ids.add(tpOut.getTerminationPointIdentifier().getNodeId().concat("-") - .concat(tpOut.getTerminationPointIdentifier().getTpId())); + this.ids.clear(); + this.resources.clear(); + this.atoz.clear(); + this.ztoa.clear(); + + this.resources.add(new ResourceBuilder().setResource(this.tpIn).build()); + this.ids.add(this.tpIn.getTerminationPointIdentifier().getNodeId().concat("-") + .concat(this.tpIn.getTerminationPointIdentifier().getTpId())); + this.resources.add(new ResourceBuilder().setResource(this.node).build()); + this.ids.add(this.node.getNodeIdentifier().getNodeId()); + this.resources.add(new ResourceBuilder().setResource(this.tpOut).build()); + this.ids.add(this.tpOut.getTerminationPointIdentifier().getNodeId().concat("-") + .concat(this.tpOut.getTerminationPointIdentifier().getTpId())); } /** @@ -85,14 +84,14 @@ public class TpNodeTp { AToZ hop = null; AToZKey atozKey = null; createListResource(); - for (Resource resource : resources) { + for (Resource resource : this.resources) { atozKey = new AToZKey(Integer.toString(odr)); resource = new ResourceBuilder().setResource(resource.getResource()).build(); hop = new AToZBuilder() - .setKey(atozKey) + .withKey(atozKey) .setResource(resource) .build(); - atoz.add(hop); + this.atoz.add(hop); odr++; } } @@ -105,50 +104,50 @@ public class TpNodeTp { ZToA hop = null; ZToAKey ztoaKey = null; createListResource(); - for (Resource resource : resources) { + for (Resource resource : this.resources) { ztoaKey = new ZToAKey(Integer.toString(odr)); resource = new ResourceBuilder().setResource(resource.getResource()).build(); hop = new ZToABuilder() - .setKey(ztoaKey) + .withKey(ztoaKey) .setResource(resource) .build(); - ztoa.add(hop); + this.ztoa.add(hop); odr++; } } public TpNodeTp reverse() { - return new TpNodeTp(tpOut, tpIn, node); + return new TpNodeTp(this.tpOut, this.tpIn, this.node); } @Override public String toString() { StringBuilder result = new StringBuilder("[ "); - result.append("tpIn : " + tpIn.getTerminationPointIdentifier().getTpId()); - result.append(" - Node : " + node.getNodeIdentifier().getNodeId()); - result.append(" - tpOut : " + tpOut.getTerminationPointIdentifier().getTpId()); + result.append("tpIn : " + this.tpIn.getTerminationPointIdentifier().getTpId()); + result.append(" - Node : " + this.node.getNodeIdentifier().getNodeId()); + result.append(" - tpOut : " + this.tpOut.getTerminationPointIdentifier().getTpId()); result.append(" ]"); return result.toString(); } public List getAToZ() { - return atoz; + return this.atoz; } public List getZToA() { - return ztoa; + return this.ztoa; } public Node getNode() { - return node; + return this.node; } public TerminationPoint getTpIn() { - return tpIn; + return this.tpIn; } public TerminationPoint getTpOut() { - return tpOut; + return this.tpOut; } } diff --git a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/impl/StubpceImpl.java b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/impl/StubpceImpl.java index f8a63c269..a32b6d2fe 100644 --- a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/impl/StubpceImpl.java +++ b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/impl/StubpceImpl.java @@ -14,13 +14,11 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; - import java.util.Iterator; import java.util.SortedSet; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import java.util.concurrent.Future; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; @@ -94,7 +92,7 @@ public class StubpceImpl implements StubpceService { public StubpceImpl(NotificationPublishService notificationPublishService, DataBroker databroker) { this.notificationPublishService = notificationPublishService; this.db = databroker; - pathDescriptionBuilder = null; + this.pathDescriptionBuilder = null; if (initializePathDescriptionList(databroker)) { fillPathDesciptionList(); } @@ -105,7 +103,7 @@ public class StubpceImpl implements StubpceService { } @Override - public Future> cancelResourceReserve(CancelResourceReserveInput input) { + public ListenableFuture> cancelResourceReserve(CancelResourceReserveInput input) { LOG.info("RPC cancelResourceReserve request received"); String message = ""; String responseCode = ""; @@ -113,7 +111,7 @@ public class StubpceImpl implements StubpceService { String serviceName = input.getServiceName(); LOG.info("serviceName : {}", serviceName); if (serviceName != null) { - sendingPCE = new SendingPceRPCs(input,db,executor); + this.sendingPCE = new SendingPceRPCs(input,this.db,this.executor); FutureCallback pceCallback = new FutureCallback() { String message = ""; ServicePathRpcResult notification = null; @@ -121,12 +119,12 @@ public class StubpceImpl implements StubpceService { @Override public void onFailure(Throwable arg0) { LOG.error("Cancel resource failed : {}", arg0); - notification = new ServicePathRpcResultBuilder() + this.notification = new ServicePathRpcResultBuilder() .setNotificationType(ServicePathNotificationTypes.CancelResourceReserve) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) .setStatusMessage("Cancel resource request failed : " + arg0.getMessage()).build(); try { - notificationPublishService.putNotification(notification); + StubpceImpl.this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } @@ -136,32 +134,32 @@ public class StubpceImpl implements StubpceService { public void onSuccess(Boolean response) { LOG.info("response : {}", response); if (response) { - message = "Resource cancelled !"; - notification = new ServicePathRpcResultBuilder() + this.message = "Resource cancelled !"; + this.notification = new ServicePathRpcResultBuilder() .setNotificationType(ServicePathNotificationTypes.CancelResourceReserve) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Successful) - .setStatusMessage(message) + .setStatusMessage(this.message) .build(); } else { - message = sendingPCE.getError(); - notification = new ServicePathRpcResultBuilder() + this.message = StubpceImpl.this.sendingPCE.getError(); + this.notification = new ServicePathRpcResultBuilder() .setNotificationType(ServicePathNotificationTypes.CancelResourceReserve) .setServiceName("") - .setStatus(RpcStatusEx.Failed).setStatusMessage(message) + .setStatus(RpcStatusEx.Failed).setStatusMessage(this.message) .build(); - message = "Cancel request failed !"; + this.message = "Cancel request failed !"; } - LOG.info(notification.toString()); + LOG.info(this.notification.toString()); try { - notificationPublishService.putNotification(notification); + StubpceImpl.this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } - LOG.info(message); + LOG.info(this.message); } }; - ListenableFuture pce = sendingPCE.cancelResourceReserve(); - Futures.addCallback(pce, pceCallback, executor); + ListenableFuture pce = this.sendingPCE.cancelResourceReserve(); + Futures.addCallback(pce, pceCallback, this.executor); LOG.info("Cancel Resource Request in progress ..."); configurationResponseCommon = new ConfigurationResponseCommonBuilder() .setAckFinalIndicator("No") @@ -175,12 +173,12 @@ public class StubpceImpl implements StubpceService { } else { message = "serviceName / requestId is not correct !"; responseCode = "500"; - notification = new ServicePathRpcResultBuilder() + this.notification = new ServicePathRpcResultBuilder() .setNotificationType(ServicePathNotificationTypes.CancelResourceReserve) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) .setStatusMessage(message).build(); try { - notificationPublishService.putNotification(notification); + this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } @@ -196,15 +194,15 @@ public class StubpceImpl implements StubpceService { } @Override - public Future> pathComputationRequest(PathComputationRequestInput input) { + public ListenableFuture> pathComputationRequest(PathComputationRequestInput input) { LOG.info("RPC pathcomputation request received"); String message = ""; String responseCode = ""; boolean coherencyHardSoft = false; boolean commonId = true; ConfigurationResponseCommonBuilder configurationResponseCommon = null; - compliancyCheck = new StubpceCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader()); - if (compliancyCheck.check(false, true)) { + this.compliancyCheck = new StubpceCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader()); + if (this.compliancyCheck.check(false, true)) { LOG.info("Service compliant !"); /** * If compliant, service-request parameters are verified in order to @@ -212,12 +210,12 @@ public class StubpceImpl implements StubpceService { * a path and implement a service. */ LOG.info("checking Tx/Rx Info for AEnd ..."); - txrxCheck = new StubpceTxRxCheck(input.getServiceAEnd(), 1); - if (txrxCheck.check()) { + this.txrxCheck = new StubpceTxRxCheck(input.getServiceAEnd(), 1); + if (this.txrxCheck.check()) { LOG.info("Tx/Rx Info for AEnd checked !"); LOG.info("checking Tx/Rx Info for ZEnd ..."); - txrxCheck = new StubpceTxRxCheck(input.getServiceZEnd(), 2); - if (txrxCheck.check()) { + this.txrxCheck = new StubpceTxRxCheck(input.getServiceZEnd(), 2); + if (this.txrxCheck.check()) { LOG.info("Tx/Rx Info for ZEnd checked !"); /** * If OK, common-id is verified in order to see if there is @@ -226,11 +224,11 @@ public class StubpceImpl implements StubpceService { * with hard/soft constraints provided in the input of the * RPC. */ - if (input.getHardConstraints() != null || input.getSoftConstraints() != null) { + if ((input.getHardConstraints() != null) || (input.getSoftConstraints() != null)) { LOG.info("Constraints specified !"); - checkCoherencyHardSoft = new CheckCoherencyHardSoft(input.getHardConstraints(), + this.checkCoherencyHardSoft = new CheckCoherencyHardSoft(input.getHardConstraints(), input.getSoftConstraints()); - if (checkCoherencyHardSoft.check()) { + if (this.checkCoherencyHardSoft.check()) { LOG.info("hard/soft constraints coherent !"); coherencyHardSoft = true; } else { @@ -242,16 +240,16 @@ public class StubpceImpl implements StubpceService { commonId = false; } if (!commonId || (commonId && coherencyHardSoft)) { - notification = new ServicePathRpcResultBuilder() + this.notification = new ServicePathRpcResultBuilder() .setNotificationType(ServicePathNotificationTypes.PathComputationRequest) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) .setStatusMessage("Service compliant, submitting pathComputation Request ...").build(); try { - notificationPublishService.putNotification(notification); + this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } - sendingPCE = new SendingPceRPCs(input,db,executor); + this.sendingPCE = new SendingPceRPCs(input,this.db,this.executor); FutureCallback pceCallback = new FutureCallback() { String message = ""; ServicePathRpcResult notification = null; @@ -260,11 +258,11 @@ public class StubpceImpl implements StubpceService { public void onFailure(Throwable arg0) { LOG.error("Failure message : {}", arg0.toString()); LOG.error("Path calculation failed !"); - notification = new ServicePathRpcResultBuilder() + this.notification = new ServicePathRpcResultBuilder() .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) .setStatusMessage("PCR Request failed : " + arg0.getMessage()).build(); try { - notificationPublishService.putNotification(notification); + StubpceImpl.this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } @@ -274,44 +272,44 @@ public class StubpceImpl implements StubpceService { public void onSuccess(Boolean response) { LOG.info("response : {}", response); if (response) { - message = "Path Computated !"; + this.message = "Path Computated !"; ServicePathRpcResultBuilder tmp = new ServicePathRpcResultBuilder() .setNotificationType(ServicePathNotificationTypes.PathComputationRequest) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Successful) - .setStatusMessage(message); - pathDescriptionBuilder = sendingPCE.getPathDescription(); - if (pathDescriptionBuilder != null) { + .setStatusMessage(this.message); + StubpceImpl.this.pathDescriptionBuilder = StubpceImpl.this.sendingPCE.getPathDescription(); + if (StubpceImpl.this.pathDescriptionBuilder != null) { PathDescription pathDescription = new org.opendaylight.yang.gen.v1.http.org .transportpce.b.c._interface.servicepath.rev170426.service.path .rpc.result.PathDescriptionBuilder() - .setAToZDirection(pathDescriptionBuilder.getAToZDirection()) - .setZToADirection(pathDescriptionBuilder.getZToADirection()) + .setAToZDirection(StubpceImpl.this.pathDescriptionBuilder.getAToZDirection()) + .setZToADirection(StubpceImpl.this.pathDescriptionBuilder.getZToADirection()) .build(); tmp.setPathDescription(new PathDescriptionBuilder() .setAToZDirection(pathDescription.getAToZDirection()) .setZToADirection(pathDescription.getZToADirection()) .build()); } - notification = tmp.build(); + this.notification = tmp.build(); } else { - message = sendingPCE.getError(); - notification = new ServicePathRpcResultBuilder() + this.message = StubpceImpl.this.sendingPCE.getError(); + this.notification = new ServicePathRpcResultBuilder() .setNotificationType(ServicePathNotificationTypes.PathComputationRequest) .setServiceName("") - .setStatus(RpcStatusEx.Failed).setStatusMessage(message) + .setStatus(RpcStatusEx.Failed).setStatusMessage(this.message) .build(); - message = "Path not calculated!"; + this.message = "Path not calculated!"; } try { - notificationPublishService.putNotification(notification); + StubpceImpl.this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } - LOG.info(message); + LOG.info(this.message); } }; - ListenableFuture pce = sendingPCE.pathComputation(); - Futures.addCallback(pce, pceCallback, executor); + ListenableFuture pce = this.sendingPCE.pathComputation(); + Futures.addCallback(pce, pceCallback, this.executor); LOG.info("PathComputation Request in progress ..."); configurationResponseCommon = new ConfigurationResponseCommonBuilder() .setAckFinalIndicator("No") @@ -325,22 +323,22 @@ public class StubpceImpl implements StubpceService { } } else { - message = txrxCheck.getMessage(); + message = this.txrxCheck.getMessage(); responseCode = "500"; } } else { - message = txrxCheck.getMessage(); + message = this.txrxCheck.getMessage(); responseCode = "500"; } } else { - message = compliancyCheck.getMessage(); + message = this.compliancyCheck.getMessage(); responseCode = "500"; - notification = new ServicePathRpcResultBuilder() + this.notification = new ServicePathRpcResultBuilder() .setNotificationType(ServicePathNotificationTypes.PathComputationRequest) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) .setStatusMessage("Service not compliant : " + message).build(); try { - notificationPublishService.putNotification(notification); + this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } @@ -438,7 +436,7 @@ public class StubpceImpl implements StubpceService { if (pathDesc != null) { iid = InstanceIdentifier.create(PathDescriptionList.class) .child(PathDescriptions.class, new PathDescriptionsKey(pathDesc.getPathName())); - writeTx = db.newWriteOnlyTransaction(); + writeTx = this.db.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, pathDesc); future = writeTx.submit(); try { @@ -466,7 +464,7 @@ public class StubpceImpl implements StubpceService { @SuppressWarnings("unused") private Services readServiceList(String serviceName) { Services result = null; - ReadOnlyTransaction readTx = db.newReadOnlyTransaction(); + ReadOnlyTransaction readTx = this.db.newReadOnlyTransaction(); InstanceIdentifier iid = InstanceIdentifier.create(ServiceList.class).child(Services.class, new ServicesKey(serviceName)); Future> future = readTx.read(LogicalDatastoreType.OPERATIONAL,iid); @@ -494,7 +492,7 @@ public class StubpceImpl implements StubpceService { @SuppressWarnings("unused") private ServicePaths readServicePathList(String serviceName) { ServicePaths result = null; - ReadOnlyTransaction readTx = db.newReadOnlyTransaction(); + ReadOnlyTransaction readTx = this.db.newReadOnlyTransaction(); InstanceIdentifier iid = InstanceIdentifier.create(ServicePathList.class) .child(ServicePaths.class, new ServicePathsKey(serviceName)); Future> future = readTx.read(LogicalDatastoreType.OPERATIONAL,iid); @@ -522,7 +520,7 @@ public class StubpceImpl implements StubpceService { @SuppressWarnings("unused") private PathDescriptions readPathDescriptionList(String pathName) { PathDescriptions result = null; - ReadOnlyTransaction readTx = db.newReadOnlyTransaction(); + ReadOnlyTransaction readTx = this.db.newReadOnlyTransaction(); InstanceIdentifier iid = InstanceIdentifier.create(PathDescriptionList.class) .child(PathDescriptions.class, new PathDescriptionsKey(pathName)); Future> future = readTx.read(LogicalDatastoreType.OPERATIONAL,iid); @@ -559,12 +557,12 @@ public class StubpceImpl implements StubpceService { org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service .path.PathDescriptionBuilder path = new org.opendaylight.yang.gen.v1.http.org.transportpce .b.c._interface.service.types.rev170426.service.path.PathDescriptionBuilder(); - path.setAToZDirection(pathDescriptionBuilder.getAToZDirection()); - path.setZToADirection(pathDescriptionBuilder.getZToADirection()); + path.setAToZDirection(this.pathDescriptionBuilder.getAToZDirection()); + path.setZToADirection(this.pathDescriptionBuilder.getZToADirection()); ServicePaths service = new ServicePathsBuilder().setServicePathName(input.getServiceName()) .setSoftConstraints(input.getSoftConstraints()).setHardConstraints(input.getHardConstraints()) .setPathDescription(path.build()).build(); - WriteTransaction writeTx = db.newWriteOnlyTransaction(); + WriteTransaction writeTx = this.db.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, service); Future future = writeTx.submit(); try { @@ -578,7 +576,7 @@ public class StubpceImpl implements StubpceService { } public PathDescriptionBuilder getPathDescriptionBuilder() { - return pathDescriptionBuilder; + return this.pathDescriptionBuilder; } public void setPathDescriptionBuilder(PathDescriptionBuilder pathDescriptionBuilder) { diff --git a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/InterNodePath.java b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/InterNodePath.java index f5a18634e..0df5603c5 100644 --- a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/InterNodePath.java +++ b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/InterNodePath.java @@ -10,11 +10,9 @@ package org.opendaylight.transportpce.stubpce.topology; import com.google.common.collect.Lists; - import java.util.ArrayList; import java.util.List; import java.util.ListIterator; - import org.opendaylight.transportpce.stubpce.TpNodeTp; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirection; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirectionBuilder; @@ -83,12 +81,12 @@ public class InterNodePath { Link link = path.getLink(); AToZKey atozKey = new AToZKey(Integer.toString(order)); Resource resource = new ResourceBuilder().setResource(link).build(); - AToZ hop = new AToZBuilder().setId(atozKey.getId()).setKey(atozKey).setResource(resource).build(); + AToZ hop = new AToZBuilder().setId(atozKey.getId()).withKey(atozKey).setResource(resource).build(); atozList.add(hop); order++; } atozDirection.setRate((long) 100).setAToZWavelengthNumber((long) 200).setAToZ(atozList); - atoz.add(atozDirection.build()); + this.atoz.add(atozDirection.build()); } /** @@ -111,12 +109,12 @@ public class InterNodePath { Link link = path.getLink(); ZToAKey ztoaKey = new ZToAKey(Integer.toString(order)); Resource resource = new ResourceBuilder().setResource(link).build(); - ZToA hop = new ZToABuilder().setId(ztoaKey.getId()).setKey(ztoaKey).setResource(resource).build(); + ZToA hop = new ZToABuilder().setId(ztoaKey.getId()).withKey(ztoaKey).setResource(resource).build(); ztoaList.add(hop); order++; } ztoaDirection.setRate((long) 100).setZToAWavelengthNumber((long) 200).setZToA(ztoaList); - ztoa.add(ztoaDirection.build()); + this.ztoa.add(ztoaDirection.build()); } /** @@ -141,7 +139,7 @@ public class InterNodePath { NodePath srg = null; NodePath deg1 = null; NodePath deg2 = null; - for (NodePath node : nodepaths) { + for (NodePath node : this.nodepaths) { //LOG.info(node.toString()); String id = node.getNodeId(); if (id.contains("XPDR")) { @@ -172,7 +170,7 @@ public class InterNodePath { LOG.info("buildDegToDeg ..."); NodePath deg1 = null; NodePath deg2 = null; - for (NodePath node : nodepaths) { + for (NodePath node : this.nodepaths) { //LOG.info(node.toString()); String nodeId = node.getNodeId(); if (nodeId.contains("DEG1")) { @@ -182,7 +180,7 @@ public class InterNodePath { deg2 = node; } } - if (deg1 != null && deg2 != null) { + if ((deg1 != null) && (deg2 != null)) { List result = new ArrayList(); NodePath deb = deg1; NodePath end = deg2; @@ -268,7 +266,7 @@ public class InterNodePath { */ private void buildDegToSrgToXpdr(NodePath xpdr,NodePath srg,NodePath deg1,NodePath deg2,boolean reverse) { LOG.info("buildDegToSrgToXpr ..."); - if (xpdr != null && srg != null && deg1 != null && deg2 != null) { + if ((xpdr != null) && (srg != null) && (deg1 != null) && (deg2 != null)) { buildDeg(xpdr, srg, deg1, reverse); buildDeg(xpdr, srg, deg2, reverse); } else { @@ -289,7 +287,7 @@ public class InterNodePath { */ private void buildXpdrToSrgToDeg(NodePath xpdr,NodePath srg,NodePath deg1,NodePath deg2,boolean reverse) { LOG.info("buildXpdrToSrgToDeg ..."); - if (xpdr != null && srg != null && deg1 != null && deg2 != null) { + if ((xpdr != null) && (srg != null) && (deg1 != null) && (deg2 != null)) { List result = new ArrayList(); for (Path xpdrPath : xpdr.getPath()) { TpNodeTp tmpxpdr = xpdrPath.getTpNodeTp(); @@ -361,7 +359,7 @@ public class InterNodePath { case 1: //last link if (res instanceof Link) { Link tp = (Link) res; - if (tp != null && tp.getLinkIdentifier().getLinkId().contains(endBy)) { + if ((tp != null) && tp.getLinkIdentifier().getLinkId().contains(endBy)) { result.add(tmp); } } @@ -370,7 +368,7 @@ public class InterNodePath { case 2: //last tp if (res instanceof TerminationPoint) { TerminationPoint tp = (TerminationPoint) res; - if (tp != null && tp.getTerminationPointIdentifier().getTpId() + if ((tp != null) && tp.getTerminationPointIdentifier().getTpId() .contains(endBy)) { result.add(tmp); } @@ -426,17 +424,17 @@ public class InterNodePath { if (atoz.getId().compareTo(id) == 0) { org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription .rev170426.pce.resource.resource.Resource res = atoz.getResource().getResource(); - if (res != null && res instanceof Link) { + if ((res != null) && (res instanceof Link)) { Link link = new LinkBuilder() .setLinkIdentifier(new LinkIdentifierBuilder() .setLinkId(atozLink) .build()) .build(); - AToZKey atozKey = new AToZKey(atoz.getKey()); + AToZKey atozKey = new AToZKey(atoz.key()); org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface .pathdescription.rev170426.pce.resource.Resource resource = new ResourceBuilder() .setResource(link).build(); - AToZ hop = new AToZBuilder().setId(atozKey.getId()).setKey(atozKey) + AToZ hop = new AToZBuilder().setId(atozKey.getId()).withKey(atozKey) .setResource(resource).build(); it.remove(); if (!remove) { @@ -474,9 +472,9 @@ public class InterNodePath { if (atoz.getId().compareTo(id) == 0) { org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription .rev170426.pce.resource.resource.Resource res = atoz.getResource().getResource(); - if (res != null && res instanceof TerminationPoint) { + if ((res != null) && (res instanceof TerminationPoint)) { TerminationPoint tp = (TerminationPoint) res; - if (tp != null && tp.getTerminationPointIdentifier().getTpId().contains(beginBy)) { + if ((tp != null) && tp.getTerminationPointIdentifier().getTpId().contains(beginBy)) { LOG.info("tmp : {}", tmp.toString()); result.add(tmp); } @@ -499,14 +497,14 @@ public class InterNodePath { * @param zend path zend Supernode nodeId */ public void buildPath(String zend) { - if (superNode != null) { - for (org.opendaylight.transportpce.stubpce.topology.Resource res : superNode.getResources()) { - NodePath path = new NodePath(res, superNode.getSuperNodeId(), superNode.isXpdrSrgAbsent()); + if (this.superNode != null) { + for (org.opendaylight.transportpce.stubpce.topology.Resource res : this.superNode.getResources()) { + NodePath path = new NodePath(res, this.superNode.getSuperNodeId(), this.superNode.isXpdrSrgAbsent()); path.fill(); - nodepaths.add(path); + this.nodepaths.add(path); } - LOG.info("nodepaths size : {}", nodepaths.size()); - build(superNode.isXpdrSrgAbsent(),superNode.getSuperNodeId(), zend); + LOG.info("nodepaths size : {}", this.nodepaths.size()); + build(this.superNode.isXpdrSrgAbsent(),this.superNode.getSuperNodeId(), zend); } } @@ -524,7 +522,7 @@ public class InterNodePath { } public SuperNode getSuperNode() { - return superNode; + return this.superNode; } public void setSuperNode(SuperNode superNode) { @@ -532,7 +530,7 @@ public class InterNodePath { } public List getAtoz() { - return atoz; + return this.atoz; } public void setAtoz(List atoz) { @@ -540,7 +538,7 @@ public class InterNodePath { } public List getZtoa() { - return ztoa; + return this.ztoa; } public void setZtoa(List ztoa) { @@ -548,7 +546,7 @@ public class InterNodePath { } public List getNodepaths() { - return nodepaths; + return this.nodepaths; } public void setNodepaths(List nodepaths) { diff --git a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/SuperNodePath.java b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/SuperNodePath.java index d6d3b0a4c..5c8e66ab3 100644 --- a/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/SuperNodePath.java +++ b/tests/stubpce/src/main/java/org/opendaylight/transportpce/stubpce/topology/SuperNodePath.java @@ -9,13 +9,11 @@ package org.opendaylight.transportpce.stubpce.topology; import com.google.common.collect.Lists; - import java.util.ArrayList; import java.util.List; import java.util.ListIterator; import java.util.SortedSet; import java.util.TreeSet; - import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.description.list.PathDescriptionsBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirection; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirectionBuilder; @@ -71,7 +69,7 @@ public class SuperNodePath { */ private Boolean endNode(String end, List supernodes) { Boolean result = false; - if (end != null && end.compareTo(" ") != 0) { + if ((end != null) && (end.compareTo(" ") != 0)) { for (String node : supernodes) { if (node.compareTo(end) == 0) { result = true; @@ -91,8 +89,8 @@ public class SuperNodePath { */ public SuperNode getSuperNode(String nodeId) { SuperNode result = null; - if (network != null) { - for (SuperNode tmp : network.getSuperNodes()) { + if (this.network != null) { + for (SuperNode tmp : this.network.getSuperNodes()) { if (tmp.getSuperNodeId().compareTo(nodeId) == 0) { result = tmp; break; @@ -129,7 +127,7 @@ public class SuperNodePath { if (tmp.startsWith(zend)) { ztoalink = tmp; } - if (atozlink != null && ztoalink != null) { + if ((atozlink != null) && (ztoalink != null)) { result.add(atozlink.concat("/").concat(ztoalink)); atozlink = null; ztoalink = null; @@ -173,8 +171,8 @@ public class SuperNodePath { */ private List getSuperNodeId() { List result = new ArrayList(); - if (network.getSuperNodes().size() > 0) { - for (SuperNode tmp : network.getSuperNodes()) { + if (this.network.getSuperNodes().size() > 0) { + for (SuperNode tmp : this.network.getSuperNodes()) { result.add(tmp.getSuperNodeId()); } } @@ -189,8 +187,8 @@ public class SuperNodePath { */ private List getRoadmLinks() { List result = new ArrayList(); - if (network.getRoadmToroadm().getLinks().size() > 0) { - for (String tmp : network.getRoadmToroadm().getLinks()) { + if (this.network.getRoadmToroadm().getLinks().size() > 0) { + for (String tmp : this.network.getRoadmToroadm().getLinks()) { result.add(tmp); } } @@ -221,9 +219,9 @@ public class SuperNodePath { ztoa.add(split[1]); } } - if (!atoz.isEmpty() && atoz.size() == ztoa.size()) { + if (!atoz.isEmpty() && (atoz.size() == ztoa.size())) { NodeLinkNode node = new NodeLinkNode(aend, zend, atoz,ztoa,direct); - paths.add(node); + this.paths.add(node); } } else { @@ -239,10 +237,10 @@ public class SuperNodePath { * @param zend ending extremity path */ public void run(String aend, String zend) { - if (network != null) { + if (this.network != null) { List supernodes = getSuperNodeId(); List roadmLinks = getRoadmLinks(); - if (aend != null && zend != null) { + if ((aend != null) && (zend != null)) { int size = supernodes.size(); String hop = null; List links = null; @@ -298,12 +296,12 @@ public class SuperNodePath { AToZ atoz = it.next(); org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription .rev170426.pce.resource.resource.Resource res = atoz.getResource().getResource(); - int tmpkey = order + Integer.parseInt(atoz.getKey().getId()); + int tmpkey = order + Integer.parseInt(atoz.key().getId()); AToZKey atozKey = new AToZKey(Integer.toString(tmpkey)); org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface .pathdescription.rev170426.pce.resource.Resource resource = new ResourceBuilder() .setResource(res).build(); - AToZ hop = new AToZBuilder().setId(atozKey.getId()).setKey(atozKey).setResource(resource).build(); + AToZ hop = new AToZBuilder().setId(atozKey.getId()).withKey(atozKey).setResource(resource).build(); it.remove(); it.add(hop); tmpkey++; @@ -375,7 +373,7 @@ public class SuperNodePath { */ public List getDeg(String atozLink, String ztoaLink) { List result = new ArrayList(); - if (atozLink != null && ztoaLink != null) { + if ((atozLink != null) && (ztoaLink != null)) { String [] split = atozLink.split("-", 4); if (split.length == 4) { result = Lists.newArrayList(split[1],split[3]); @@ -470,7 +468,7 @@ public class SuperNodePath { } if (resource != null) { hop = new ZToABuilder() - .setKey(ztoaKey) + .withKey(ztoaKey) .setResource(resource) .build(); ztoaList.add(hop); @@ -511,7 +509,7 @@ public class SuperNodePath { ztoadirList.add(ztodir); } } - if (!ztoadirList.isEmpty() && size == ztoadirList.size()) { + if (!ztoadirList.isEmpty() && (size == ztoadirList.size())) { LOG.info("building PathDescriptions ..."); int index = 1; String pathName = null; @@ -547,11 +545,11 @@ public class SuperNodePath { if (split.length == 4) { String aend = split[0].replaceAll("ROADM", "Node"); String zend = split[2].replaceAll("ROADM", "Node"); - if (aend != null && zend != null) { + if ((aend != null) && (zend != null)) { LOG.info("getting super node for : {} and {}", aend, zend); SuperNode aendSp = getSuperNode(aend); SuperNode zendSp = getSuperNode(zend); - if (aendSp != null && zendSp != null) { + if ((aendSp != null) && (zendSp != null)) { result.add(aendSp); result.add(zendSp); } @@ -582,7 +580,7 @@ public class SuperNodePath { String ztoaLink = null; atozLink = tmp.getAtozLink().get(0); ztoaLink = tmp.getZtoaLink().get(0); - if (atozLink != null && ztoaLink != null) { + if ((atozLink != null) && (ztoaLink != null)) { LOG.info("atozlink : {}", atozLink); LOG.info("ztoalink : {}", ztoaLink); InterNodePath interAend = new InterNodePath(aendSp); @@ -654,7 +652,7 @@ public class SuperNodePath { int loop = 0; while (loop < 2) { List hop = getSuperNodeEndLink(atozLinks.get(loop)); - if (!hop.isEmpty() && hop.size() == 2) { + if (!hop.isEmpty() && (hop.size() == 2)) { aendSp = hop.get(0); zendSp = hop.get(1); InterNodePath interAend = new InterNodePath(aendSp); @@ -665,7 +663,7 @@ public class SuperNodePath { LOG.info("interZend : {}", interZend.getAtoz().toString()); List deg1 = getDeg(atozLinks.get(loop),ztoaLinks.get(loop)); LOG.info("deg1 : {}", deg1.toString()); - if (!deg1.isEmpty() && deg1.size() == 2) { + if (!deg1.isEmpty() && (deg1.size() == 2)) { List cleanInterA = null; List cleanInterZ = null; if (zendSp.getSuperNodeId().compareTo(zend) == 0) { @@ -724,7 +722,7 @@ public class SuperNodePath { } public List getPaths() { - return paths; + return this.paths; } public void setPaths(List paths) { diff --git a/tests/stubrenderer/pom.xml b/tests/stubrenderer/pom.xml index aa6e9eabc..56b4b33b5 100644 --- a/tests/stubrenderer/pom.xml +++ b/tests/stubrenderer/pom.xml @@ -24,6 +24,25 @@ Author: Martial Coulibaly on behalf of Orange 0.2.0-SNAPSHOT bundle + + + + org.opendaylight.controller + mdsal-artifacts + 1.8.0-SNAPSHOT + import + pom + + + org.opendaylight.netconf + netconf-artifacts + 1.5.0-SNAPSHOT + import + pom + + + + ${project.groupId} @@ -55,6 +74,14 @@ Author: Martial Coulibaly on behalf of Orange transportpce-stubmodels ${project.version} + + org.opendaylight.controller.model + model-topology + + + org.opendaylight.netconf + sal-netconf-connector + diff --git a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java index 23ae97628..6e197d5da 100644 --- a/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java +++ b/tests/stubrenderer/src/main/java/org/opendaylight/transportpce/stubrenderer/impl/StubrendererImpl.java @@ -14,10 +14,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; - import java.util.concurrent.Executors; -import java.util.concurrent.Future; - import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.transportpce.stubrenderer.SendingRendererRPCs; import org.opendaylight.transportpce.stubrenderer.StubrendererCompliancyCheck; @@ -64,15 +61,15 @@ public class StubrendererImpl implements StubrendererService { } @Override - public Future> serviceImplementationRequest( + public ListenableFuture> serviceImplementationRequest( ServiceImplementationRequestInput input) { LOG.info("RPC serviceImplementationRequest request received"); String responseCode = ""; String message = ""; ConfigurationResponseCommonBuilder configurationResponseCommon = null; - compliancyCheck = new StubrendererCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader()); - if (compliancyCheck.check(false, true)) { + this.compliancyCheck = new StubrendererCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader()); + if (this.compliancyCheck.check(false, true)) { LOG.info("Service compliant !"); /** * If compliant, service-request parameters are verified in order to @@ -80,19 +77,19 @@ public class StubrendererImpl implements StubrendererService { * a path and implement a service. */ - notification = new ServiceRpcResultSpBuilder() + this.notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest) .setServiceName(input.getServiceName()) .setStatus(RpcStatusEx.Pending) .setStatusMessage("Service compliant, submitting serviceImplementation Request ...") .build(); try { - notificationPublishService.putNotification(notification); + this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } - SendingRendererRPCs sendingRenderer = new SendingRendererRPCs(executor); + SendingRendererRPCs sendingRenderer = new SendingRendererRPCs(this.executor); FutureCallback rendererCallback = new FutureCallback() { String message = ""; @@ -102,12 +99,12 @@ public class StubrendererImpl implements StubrendererService { public void onFailure(Throwable arg0) { LOG.error("Failure message : {}", arg0.toString()); LOG.error("Service implementation failed !"); - notification = new ServiceRpcResultSpBuilder() + this.notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) .setStatusMessage("PCR Request failed : {}" + arg0.getMessage()).build(); try { - notificationPublishService.putNotification(notification); + StubrendererImpl.this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } @@ -117,13 +114,13 @@ public class StubrendererImpl implements StubrendererService { public void onSuccess(Boolean response) { LOG.info("response : {}", response); if (response) { - message = "Service implemented !"; + this.message = "Service implemented !"; TopologyBuilder topo = sendingRenderer.getTopology(); ServiceRpcResultSpBuilder tmp = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest) .setServiceName(input.getServiceName()) .setStatus(RpcStatusEx.Successful) - .setStatusMessage(message); + .setStatusMessage(this.message); if (topo != null) { PathTopology value = new PathTopologyBuilder() .setAToZ(topo.getAToZ()) @@ -131,26 +128,26 @@ public class StubrendererImpl implements StubrendererService { .build(); tmp.setPathTopology(value); } - notification = tmp.build(); + this.notification = tmp.build(); } else { - message = "Service implementation failed : " + sendingRenderer.getError(); - notification = new ServiceRpcResultSpBuilder() + this.message = "Service implementation failed : " + sendingRenderer.getError(); + this.notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceImplementationRequest) .setServiceName("") - .setStatus(RpcStatusEx.Failed).setStatusMessage(message) + .setStatus(RpcStatusEx.Failed).setStatusMessage(this.message) .build(); } - LOG.info(notification.toString()); + LOG.info(this.notification.toString()); try { - notificationPublishService.putNotification(notification); + StubrendererImpl.this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } - LOG.info(message); + LOG.info(this.message); } }; ListenableFuture renderer = sendingRenderer.serviceImplementation(); - Futures.addCallback(renderer, rendererCallback, executor); + Futures.addCallback(renderer, rendererCallback, this.executor); LOG.info("Service implmentation Request in progress "); configurationResponseCommon = new ConfigurationResponseCommonBuilder() .setAckFinalIndicator("Yes") @@ -163,16 +160,16 @@ public class StubrendererImpl implements StubrendererService { .build(); return RpcResultBuilder.success(output).buildFuture(); } else { - message = compliancyCheck.getMessage(); + message = this.compliancyCheck.getMessage(); responseCode = "500"; LOG.info("Service not compliant caused by : {}", message); - notification = new ServiceRpcResultSpBuilder() + this.notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceDelete) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) .setStatusMessage("Service not compliant caused by : " + message) .build(); try { - notificationPublishService.putNotification(notification); + this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } @@ -190,13 +187,13 @@ public class StubrendererImpl implements StubrendererService { } @Override - public Future> serviceDelete(ServiceDeleteInput input) { + public ListenableFuture> serviceDelete(ServiceDeleteInput input) { String message = ""; LOG.info("RPC serviceDelete request received"); String responseCode = ""; ConfigurationResponseCommonBuilder configurationResponseCommon = null; - compliancyCheck = new StubrendererCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader()); - if (compliancyCheck.check(false, true)) { + this.compliancyCheck = new StubrendererCompliancyCheck(input.getServiceName(), input.getServiceHandlerHeader()); + if (this.compliancyCheck.check(false, true)) { LOG.info("Service compliant !"); /** * If compliant, service-request parameters are verified in order to @@ -204,18 +201,18 @@ public class StubrendererImpl implements StubrendererService { * a path and implement a service. */ - notification = new ServiceRpcResultSpBuilder() + this.notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceDelete) .setServiceName(input.getServiceName()) .setStatus(RpcStatusEx.Pending) .setStatusMessage("Service compliant, submitting serviceDelete Request ...") .build(); try { - notificationPublishService.putNotification(notification); + this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } - SendingRendererRPCs sendingRenderer = new SendingRendererRPCs(executor); + SendingRendererRPCs sendingRenderer = new SendingRendererRPCs(this.executor); FutureCallback rendererCallback = new FutureCallback() { String message = ""; ServiceRpcResultSp notification = null; @@ -224,12 +221,12 @@ public class StubrendererImpl implements StubrendererService { public void onFailure(Throwable arg0) { LOG.error("Failure message : {}", arg0.toString()); LOG.error("Service delete failed !"); - notification = new ServiceRpcResultSpBuilder() + this.notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceDelete) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) .setStatusMessage("PCR Request failed : " + arg0.getMessage()).build(); try { - notificationPublishService.putNotification(notification); + StubrendererImpl.this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } @@ -239,30 +236,30 @@ public class StubrendererImpl implements StubrendererService { public void onSuccess(Boolean response) { LOG.info("response : {}", response); if (response) { - message = "Service deleted !"; - notification = new ServiceRpcResultSpBuilder() + this.message = "Service deleted !"; + this.notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceDelete) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Successful) - .setStatusMessage(message).build(); + .setStatusMessage(this.message).build(); } else { - message = "Service delete failed : " + sendingRenderer.getError(); - notification = new ServiceRpcResultSpBuilder() + this.message = "Service delete failed : " + sendingRenderer.getError(); + this.notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceDelete) .setServiceName("") - .setStatus(RpcStatusEx.Failed).setStatusMessage(message) + .setStatus(RpcStatusEx.Failed).setStatusMessage(this.message) .build(); } - LOG.info(notification.toString()); + LOG.info(this.notification.toString()); try { - notificationPublishService.putNotification(notification); + StubrendererImpl.this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } - LOG.info(message); + LOG.info(this.message); } }; ListenableFuture renderer = sendingRenderer.serviceDelete(); - Futures.addCallback(renderer, rendererCallback, executor); + Futures.addCallback(renderer, rendererCallback, this.executor); message = "Service delete Request in progress ..."; LOG.info(message); configurationResponseCommon = new ConfigurationResponseCommonBuilder() @@ -275,16 +272,16 @@ public class StubrendererImpl implements StubrendererService { .build(); return RpcResultBuilder.success(output).buildFuture(); } else { - message = compliancyCheck.getMessage(); + message = this.compliancyCheck.getMessage(); LOG.info("Service not compliant caused by : {}", message); responseCode = "500"; - notification = new ServiceRpcResultSpBuilder() + this.notification = new ServiceRpcResultSpBuilder() .setNotificationType(ServicePathNotificationTypes.ServiceDelete) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) .setStatusMessage("Service not compliant caused by : " + message) .build(); try { - notificationPublishService.putNotification(notification); + this.notificationPublishService.putNotification(this.notification); } catch (InterruptedException e) { LOG.info("notification offer rejected : {}", e); } -- 2.36.6