<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-api</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-common</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencyManagement>
project_cfg: opendaylight
project: Transport PCE
-version: Magnesium
-
+version: Aluminium
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>odl-transportpce-inventory</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>feature</packaging>
<name>OpenDaylight :: transportpce :: Inventory</name>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>odl-transportpce-tapi</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>feature</packaging>
<name>OpenDaylight :: transportpce :: tapi</name>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>odl-transportpce</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>feature</packaging>
<name>OpenDaylight :: transportpce</name>
<netconf.version>1.8.0-SNAPSHOT</netconf.version>
<restconf.version>1.11.0-SNAPSHOT</restconf.version>
<configfile.directory>etc/opendaylight/karaf</configfile.directory>
- <maven.deploy.skip>true</maven.deploy.skip>
- <maven.install.skip>true</maven.install.skip>
</properties>
<dependencies>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>features-aggregator</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<packaging>pom</packaging>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-inventory</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-karaf</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<application.main.class>io.lighty.controllers.tpce.Main</application.main.class>
<application.attach.zip>true</application.attach.zip>
<maven.deploy.skip>true</maven.deploy.skip>
- <transportpce.version>1.0.0-SNAPSHOT</transportpce.version>
+ <transportpce.version>2.0.0-SNAPSHOT</transportpce.version>
</properties>
<dependencies>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-networkmodel</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-olm</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<groupId>org.opendaylight.transportpce.ordmodels</groupId>
<artifactId>transportpce-ordmodels-common</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<groupId>org.opendaylight.transportpce.ordmodels</groupId>
<artifactId>transportpce-ordmodels-device</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencyManagement>
<groupId>org.opendaylight.transportpce.ordmodels</groupId>
<artifactId>transportpce-ordmodels-network</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-ordmodels</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<groupId>org.opendaylight.transportpce.ordmodels</groupId>
<artifactId>transportpce-ordmodels-service</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-pce</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
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.transportpce.pce.networkanalyzer.PceLink;
import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
private static final Logger LOG = LoggerFactory.getLogger(PcePathDescription.class);
private List<PceLink> pathAtoZ = null;
+ private List<PceLink> pathZtoA = null;
private PceResult rc;
-
- public PceResult getReturnStructure() {
- return rc;
- }
-
private Map<LinkId, PceLink> allPceLinks = null;
- private List<PceLink> pathZtoA = null;
-
public PcePathDescription(List<PceLink> pathAtoZ, Map<LinkId, PceLink> allPceLinks, PceResult rc) {
super();
this.allPceLinks = allPceLinks;
}
public PceResult buildDescriptions() {
- LOG.info("In buildDescriptions: AtoZ = {}", pathAtoZ.toString());
- List<AToZ> atozList = new ArrayList<AToZ>();
+ LOG.info("In buildDescriptions: AtoZ = {}", pathAtoZ);
+ List<AToZ> atozList = new ArrayList<>();
if (pathAtoZ == null) {
rc.setRC(ResponseCodes.RESPONSE_FAILED);
LOG.error("In buildDescriptions: there is empty AtoZ path");
}
rc.setAtoZDirection(atoZDirectionBldr.build());
pathZtoA = ImmutableList.copyOf(pathAtoZ).reverse();
- LOG.info("In buildDescriptions: ZtoA {}", pathZtoA.toString());
+ LOG.info("In buildDescriptions: ZtoA {}", pathZtoA);
- List<ZToA> ztoaList = new ArrayList<ZToA>();
+ List<ZToA> ztoaList = new ArrayList<>();
if (pathZtoA == null) {
rc.setRC(ResponseCodes.RESPONSE_FAILED);
LOG.error("In buildDescriptions: there is empty ZtoA path");
Resource clientResource = new ResourceBuilder().setResource(stp).build();
AToZ firstResource = new AToZBuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
etoeList.add(firstResource);
- index++;
+ index += 1;
for (PceLink pcelink : path) {
String srcName = pcelink.getSourceId().getValue();
// Nodes
AToZKey sourceKey = new AToZKey(index.toString());
Resource nodeResource1 = new ResourceBuilder().setResource(sourceNode).build();
AToZ srcResource = new AToZBuilder().setId(srcName).withKey(sourceKey).setResource(nodeResource1).build();
- index++;
+ index += 1;
etoeList.add(srcResource);
// source TP
AToZKey srcTPKey = new AToZKey(index.toString());
Resource tpResource1 = new ResourceBuilder().setResource(stp).build();
AToZ stpResource = new AToZBuilder().setId(tpName).withKey(srcTPKey).setResource(tpResource1).build();
- index++;
+ index += 1;
etoeList.add(stpResource);
String linkName = pcelink.getLinkId().getValue();
AToZKey linkKey = new AToZKey(index.toString());
Resource nodeResource2 = new ResourceBuilder().setResource(atozLink).build();
AToZ linkResource = new AToZBuilder().setId(linkName).withKey(linkKey).setResource(nodeResource2).build();
- index++;
+ index += 1;
etoeList.add(linkResource);
String destName = pcelink.getDestId().getValue();
AToZKey destTPKey = new AToZKey(index.toString());
Resource tpResource2 = new ResourceBuilder().setResource(dtp).build();
AToZ ttpResource = new AToZBuilder().setId(tpName).withKey(destTPKey).setResource(tpResource2).build();
- index++;
+ index += 1;
etoeList.add(ttpResource);
org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
.setTpNodeId(xname).setTpId(tpName)
.build();
-
- index++;
+ index += 1;
clientKey = new AToZKey(index.toString());
clientResource = new ResourceBuilder().setResource(stp).build();
lastResource = new AToZBuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
Resource clientResource = new ResourceBuilder().setResource(stp).build();
ZToA firstResource = new ZToABuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
etoelist.add(firstResource);
- index++;
+ index += 1;
for (PceLink pcelinkAtoZ : path) {
pcelink = this.allPceLinks.get(pcelinkAtoZ.getOppositeLink());
- LOG.debug("link to oppsite: {} to {}", pcelinkAtoZ.toString(), pcelink.toString());
+ LOG.debug("link to oppsite: {} to {}", pcelinkAtoZ, pcelink);
String srcName = pcelink.getSourceId().getValue();
ZToAKey sourceKey = new ZToAKey(index.toString());
Resource nodeResource1 = new ResourceBuilder().setResource(sourceNode).build();
ZToA srcResource = new ZToABuilder().setId(srcName).withKey(sourceKey).setResource(nodeResource1).build();
- index++;
+ index += 1;
etoelist.add(srcResource);
// source TP
ZToAKey srcTPKey = new ZToAKey(index.toString());
Resource tpResource1 = new ResourceBuilder().setResource(stp).build();
ZToA stpResource = new ZToABuilder().setId(tpName).withKey(srcTPKey).setResource(tpResource1).build();
- index++;
+ index += 1;
etoelist.add(stpResource);
String linkName = pcelink.getLinkId().getValue();
ZToAKey linkKey = new ZToAKey(index.toString());
Resource nodeResource2 = new ResourceBuilder().setResource(ztoaLink).build();
ZToA linkResource = new ZToABuilder().setId(linkName).withKey(linkKey).setResource(nodeResource2).build();
- index++;
+ index += 1;
etoelist.add(linkResource);
String destName = pcelink.getDestId().getValue();
ZToAKey destTPKey = new ZToAKey(index.toString());
Resource tpResource2 = new ResourceBuilder().setResource(ttp).build();
ZToA ttpResource = new ZToABuilder().setId(tpName).withKey(destTPKey).setResource(tpResource2).build();
- index++;
+ index += 1;
etoelist.add(ttpResource);
stp = new TerminationPointBuilder()
.setTpNodeId(xname).setTpId(tpName).build();
-
- index++;
+ index += 1;
clientKey = new ZToAKey(index.toString());
clientResource = new ResourceBuilder().setResource(stp).build();
lastResource = new ZToABuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
etoelist.add(lastResource);
-
}
+ public PceResult getReturnStructure() {
+ return rc;
+ }
}
// sleep for 10s
Thread.sleep(10000);
} catch (InterruptedException e) {
- LOG.error(e.toString());
+ LOG.error("in PCESendingPceRPC: ",e);
}
success = true;
LOG.info("cancelResourceReserve ...");
rc = nwAnalizer.getReturnStructure();
String serviceType = nwAnalizer.getServiceType();
if (!rc.getStatus()) {
- LOG.error("In pathComputationWithConstraints, nwAnalizer: result = {}", rc.toString());
+ LOG.error("In pathComputationWithConstraints, nwAnalizer: result = {}", rc);
return;
}
LOG.info("PceGraph ...");
}
if (!rc.getStatus()) {
- LOG.error("In pathComputationWithConstraints, graph.calcPath: result = {}", rc.toString());
+ LOG.error("In pathComputationWithConstraints, graph.calcPath: result = {}", rc);
return;
}
}
description.buildDescriptions();
rc = description.getReturnStructure();
if (!rc.getStatus()) {
- LOG.error("In pathComputationWithConstraints, description: result = {}", rc.toString());
- return;
+ LOG.error("In pathComputationWithConstraints, description: result = {}", rc);
}
}
callGnpyToComputeNewPath(gnpy);
} else {
setPathDescription(new PathDescriptionBuilder().setAToZDirection(atoz).setZToADirection(ztoa));
- return;
}
}
catch (GnpyException e) {
LOG.error("Exception raised by GNPy {}",e.getMessage());
setPathDescription(new PathDescriptionBuilder().setAToZDirection(atoz).setZToADirection(ztoa));
- return;
}
- return;
}
private boolean gnpyToCheckFeasiblity(AToZDirection atoz, ZToADirection ztoa, GnpyUtilitiesImpl gnpy)
//Call GNPy in the case of non feasibility
LOG.info("In pceSendingPceRPC: the path is not feasible according to Gnpy");
HardConstraints gnpyPathAsHC = null;
- gnpyPathAsHC = gnpy.askNewPathFromGnpy(gnpyPathAsHC, pceHardConstraints);
+ gnpyPathAsHC = gnpy.askNewPathFromGnpy(pceHardConstraints);
if (gnpyPathAsHC == null) {
LOG.info("In pceSendingPceRPC: GNPy failed to find another path");
this.success = false;
*/
package org.opendaylight.transportpce.pce;
+import java.io.Serializable;
import java.util.Comparator;
/**
* @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
*
*/
-public class SortPortsByName implements Comparator<String> {
+public class SortPortsByName implements Comparator<String>, Serializable {
+
+ private static final long serialVersionUID = 1L;
@Override
public int compare(String port1, String port2) {
// TODO. for now metrics are set into hard structure
private RoutingConstraintsSp.PceMetric pceMetrics = RoutingConstraintsSp.PceMetric.HopCount;
- private Long maxLatency = (long) -1;
+ private Long maxLatency = -1L;
// Structure related to EXCLUDE constraints
// Nodes/CLLI/SRLG lists might consist of two types of elements : (1)from diversity constraints (2)from exclude list
// e.g.: nodesToExclude - topo-level nodes IDs - comes from diversity constraints
// : supNodesToExclude - supporting nodes IDs - comes from exclude list
// "mapConstraints" class converts diversity elements into correct names
- private List<String> nodesToExclude = new ArrayList<String>();
- private List<String> supNodesToExclude = new ArrayList<String>();
+ private List<String> nodesToExclude = new ArrayList<>();
+ private List<String> supNodesToExclude = new ArrayList<>();
- private List<Long> srlgToExclude = new ArrayList<Long>();
- private List<String> srlgLinksToExclude = new ArrayList<String>();
+ private List<Long> srlgToExclude = new ArrayList<>();
+ private List<String> srlgLinksToExclude = new ArrayList<>();
- private List<String> clliToExclude = new ArrayList<String>();
- private List<String> clliNodesToExclude = new ArrayList<String>();
+ private List<String> clliToExclude = new ArrayList<>();
+ private List<String> clliNodesToExclude = new ArrayList<>();
///Structures related to INCLUDE constraints
- private List<String> nodesToInclude = new ArrayList<String>();
- private List<PceOpticalNode> pceNodesToInclude = new ArrayList<PceOpticalNode>();
- private List<ResourcePair> listToInclude = new ArrayList<ResourcePair>();
+ private List<String> nodesToInclude = new ArrayList<>();
+ private List<PceOpticalNode> pceNodesToInclude = new ArrayList<>();
+ private List<ResourcePair> listToInclude = new ArrayList<>();
- private List<String> srlgNames = new ArrayList<String>();
+ private List<String> srlgNames = new ArrayList<>();
public enum ResourceType {
NONE, NODE, SRLG, CLLI;
}
public void setIncludePceNode(PceOpticalNode node) {
- LOG.info("in Pceconstraints setIncludePceNode new node = {}", node.toString());
+ LOG.info("in Pceconstraints setIncludePceNode new node = {}", node);
this.pceNodesToInclude.add(node);
}
- public class ResourcePair {
+ public static class ResourcePair {
+
public ResourcePair(ResourceType type, String name) {
super();
this.type = type;
}
private ResourceType type = ResourceType.NODE;
-
private String name = "";
public ResourceType getType() {
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
+
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.transportpce.common.Timeouts;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePathsKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
this.networkTransactionService = networkTransactionService;
// TODO. for now metrics are set into hard structure
- LOG.info("In PceConstraintsCalc: read PceMetric {}", pceMetrics.toString());
+ LOG.info("In PceConstraintsCalc: read PceMetric {}", pceMetrics);
pceHardConstraints.setPceMetrics(pceMetrics);
calcHardconstraints(input);
CoRouting tmpCoRouting = null;
if (coRoutingOrGeneral instanceof General) {
- LOG.info("In readconstraints General {}", coRoutingOrGeneral.toString());
+ LOG.info("In readconstraints General {}", coRoutingOrGeneral);
tmpGeneral = (General) coRoutingOrGeneral;
readGeneralContrains(tmpGeneral, constraints);
return;
}
if (coRoutingOrGeneral instanceof CoRouting) {
- LOG.info("In readconstraints CoRouting {}", coRoutingOrGeneral.toString());
+ LOG.info("In readconstraints CoRouting {}", coRoutingOrGeneral);
tmpCoRouting = (CoRouting) coRoutingOrGeneral;
readCoRoutingContrains(tmpCoRouting, constraints);
- return;
}
-
- return;
-
}
private void readGeneralContrains(General tmpGeneral, PceConstraints constraints) {
Latency latency = tmpGeneral.getLatency();
if (latency != null) {
constraints.setMaxLatency(latency.getMaxLatency().toJava());
- LOG.info("In readGeneralContrains: read latency {}", latency.toString());
+ LOG.info("In readGeneralContrains: read latency {}", latency);
}
Exclude exclude = tmpGeneral.getExclude();
elementsToExclude = exclude.getSRLG();
if (elementsToExclude != null) {
- List<Long> srlgToExclude = new ArrayList<Long>();
+ List<Long> srlgToExclude = new ArrayList<>();
for (String str : elementsToExclude) {
srlgToExclude.add(Long.parseLong(str));
}
if (listHops != null) {
readIncludeNodes(listHops, constraints);
}
- LOG.debug("in readGeneralContrains INCLUDE {} ", include.toString());
+ LOG.debug("in readGeneralContrains INCLUDE {} ", include);
}
Diversity diversity = tmpGeneral.getDiversity();
if (temp == null) {
return;
}
- if (temp.isNode()) {
+ if (Boolean.TRUE.equals(temp.isNode())) {
rt = PceConstraints.ResourceType.NODE;
}
- if (temp.isSrlg()) {
+ if (Boolean.TRUE.equals(temp.isSrlg())) {
rt = PceConstraints.ResourceType.SRLG;
}
- if (temp.isClli()) {
+ if (Boolean.TRUE.equals(temp.isClli())) {
rt = PceConstraints.ResourceType.CLLI;
}
- LOG.info("in readGeneralContrains {} list is :{}", rt, diversity.toString());
+ LOG.info("in readGeneralContrains {} list is :{}", rt, diversity);
readDiversity(diversity.getExistingService(), constraints, rt);
}
.rev171017.ordered.constraints.sp.hop.type.hop.type.Node
node = (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing
.constraints.rev171017.ordered.constraints.sp.hop.type.hop.type.Node) hoptype;
- constraints.setListToInclude(constraints.new ResourcePair(PceConstraints.ResourceType.NODE,
+ constraints.setListToInclude(new PceConstraints.ResourcePair(PceConstraints.ResourceType.NODE,
node.getNodeId()));
break;
case "SRLG":
.rev171017.ordered.constraints.sp.hop.type.hop.type.SRLG
srlg = (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing
.constraints.rev171017.ordered.constraints.sp.hop.type.hop.type.SRLG) hoptype;
- constraints.setListToInclude(constraints.new ResourcePair(PceConstraints.ResourceType.SRLG,
+ constraints.setListToInclude(new PceConstraints.ResourcePair(PceConstraints.ResourceType.SRLG,
srlg.getSRLG()));
break;
case "Clli":
.rev171017.ordered.constraints.sp.hop.type.hop.type.Clli
clli = (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing
.constraints.rev171017.ordered.constraints.sp.hop.type.hop.type.Clli) hoptype;
- constraints.setListToInclude(constraints.new ResourcePair(PceConstraints.ResourceType.CLLI,
+ constraints.setListToInclude(new PceConstraints.ResourcePair(PceConstraints.ResourceType.CLLI,
clli.getClli()));
break;
default:
private void readDiversity(List<String> srvList, PceConstraints constraints, PceConstraints.ResourceType rt) {
- List<String> elementsToExclude = new ArrayList<String>();
- LOG.info("in readDiversity {}", srvList.toString());
+ List<String> elementsToExclude = new ArrayList<>();
+ LOG.info("in readDiversity {}", srvList);
for (String srv : srvList) {
Optional<PathDescription> service = getPathDescriptionFromDatastore(srv);
if (service.isPresent()) {
- LOG.info("in readDiversity service list {}", service.toString());
+ LOG.info("in readDiversity service list {}", service);
switch (rt) {
case NODE:
- elementsToExclude
- .addAll(getAToZNodeList(service.get()));
+ elementsToExclude.addAll(getAToZNodeList(service.get()));
LOG.info("readDiversity NODE : {}", elementsToExclude);
if (elementsToExclude != null) {
constraints.setExcludeNodes(elementsToExclude);
}
break;
case SRLG:
- elementsToExclude
- .addAll(getSRLGList(service.get()));
+ elementsToExclude.addAll(getSRLGList(service.get()));
LOG.info("readDiversity SRLG : {}", elementsToExclude);
if (elementsToExclude != null) {
constraints.setExcludeSrlgLinks(elementsToExclude);
case CLLI:
/// Retrieve nodes into dedicated CLLI list
/// during node validation check their CLLI and build CLLI exclude list
- elementsToExclude
- .addAll(getAToZNodeList(service.get()));
+ elementsToExclude.addAll(getAToZNodeList(service.get()));
LOG.info("readDiversity CLLI : {}", elementsToExclude);
if (elementsToExclude != null) {
constraints.setExcludeClliNodes(elementsToExclude);
if (tmpcoRouting == null) {
LOG.info("In readCoRoutingContrains: no General constraints.");
- return;
}
}
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(ConnectToGnpyServer.class);
static final String URL_GNPY = "http://127.0.0.1:8008/gnpy/api/v1.0/files";
+ static final String USER_CRED = "gnpy:gnpy";
- public String gnpyCnx(String jsonTxt) throws GnpyException {
+ public String returnGnpyResponse(String jsonTxt) throws GnpyException {
String jsonRespTxt = null;
try {
- URL url = new URL(URL_GNPY);
- String userCredentials = "gnpy:gnpy";
- String basicAuth = "Basic " + new String(java.util.Base64.getEncoder().encode(userCredentials.getBytes()));
-
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setDoOutput(true);
- conn.setRequestMethod("POST");
- conn.setRequestProperty("Authorization", basicAuth);
- conn.setRequestProperty("Content-Type", "application/json");
-
// Send the request to the GNPy
+ HttpURLConnection conn = connectToGNPy("POST");
OutputStream os = conn.getOutputStream();
- os.write(jsonTxt.getBytes());
+ os.write(jsonTxt.getBytes(StandardCharsets.UTF_8));
os.flush();
if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) {
throw new GnpyException(String.format(
"In connectToGnpyServer: could not connect to GNPy - response code: %s",conn.getResponseCode()));
}
- InputStreamReader response = new InputStreamReader((conn.getInputStream()));
- if (response != null) {
+ InputStreamReader response = new InputStreamReader((conn.getInputStream()),StandardCharsets.UTF_8);
+ if (response.ready()) {
jsonRespTxt = CharStreams.toString(response);
}
conn.disconnect();
public boolean isGnpyURLExist() {
boolean exist = false;
try {
- URL url = new URL(URL_GNPY);
- String userCredentials = "gnpy:gnpy";
- String basicAuth = "Basic " + new String(java.util.Base64.getEncoder().encode(userCredentials.getBytes()));
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setDoOutput(true);
- conn.setRequestMethod("HEAD");
- conn.setRequestProperty("Authorization", basicAuth);
- conn.setRequestProperty("Content-Type", "application/json");
+ HttpURLConnection conn = connectToGNPy("HEAD");
conn.connect();
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
LOG.info("In connectToGnpyServer: Gnpy instance is connected to T-PCE");
return exist;
}
+ private HttpURLConnection connectToGNPy(String action) throws IOException {
+ URL url = new URL(URL_GNPY);
+ String basicAuth = "Basic " + new String(java.util.Base64.getEncoder()
+ .encode(USER_CRED.getBytes(StandardCharsets.UTF_8)),StandardCharsets.UTF_8);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setDoOutput(true);
+ conn.setRequestMethod(action);
+ conn.setRequestProperty("Authorization", basicAuth);
+ conn.setRequestProperty("Content-Type", "application/json");
+ conn.connect();
+ return conn;
+ }
+
public String readResponse(InputStreamReader response) throws GnpyException {
String output = null;
BufferedReader br = new BufferedReader(response);
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
-import java.util.Set;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(GnpyResult.class);
private Response response = null;
- private Map<String, IpAddress> mapNodeRefIp = new HashMap<String, IpAddress>();
- //private Map<String, IpAddress> mapFiberIp = new HashMap<String, IpAddress>();
+ private Map<String, IpAddress> mapNodeRefIp = new HashMap<>();
public GnpyResult(String gnpyResponseString, GnpyTopoImpl gnpyTopo) throws GnpyException, Exception {
this.mapNodeRefIp = gnpyTopo.getMapNodeRefIp();
moduleInfos = Collections.singleton(BindingReflections.getModuleInfo(Result.class));
moduleContext.addModuleInfos(moduleInfos);
-
SchemaContext schemaContext = moduleContext.tryToCreateSchemaContext().get();
// Create the binding binding normalized node codec registry
// Create the data object
QName pathQname = QName.create("gnpy:path", "2020-02-02", "result");
- LOG.debug("the Qname is {} / namesapce {} ; module {}; ", pathQname.toString(), pathQname.getNamespace(),
+ LOG.debug("the Qname is {} / namesapce {} ; module {}; ", pathQname, pathQname.getNamespace(),
pathQname.getModule());
YangInstanceIdentifier yangId = YangInstanceIdentifier.of(pathQname);
DataObject dataObject = null;
// Create the object response
InputStream streamGnpyRespnse = new ByteArrayInputStream(gnpyResponseString.getBytes(StandardCharsets.UTF_8));
- InputStreamReader gnpyResultReader = new InputStreamReader(streamGnpyRespnse);
+ InputStreamReader gnpyResultReader = new InputStreamReader(streamGnpyRespnse,StandardCharsets.UTF_8);
JsonReader jsonReader = new JsonReader(gnpyResultReader);
Optional<NormalizedNode<? extends PathArgument, ?>> transformIntoNormalizedNode = parseInputJSON(jsonReader,
Result.class);
+ if (!transformIntoNormalizedNode.isPresent()) {
+ throw new GnpyException("In GnpyResult: the Normalized Node is not present");
+ }
NormalizedNode<? extends PathArgument, ?> normalizedNode = transformIntoNormalizedNode.get();
+
if (codecRegistry.fromNormalizedNode(yangId, normalizedNode) != null) {
dataObject = codecRegistry.fromNormalizedNode(yangId, normalizedNode).getValue();
} else {
- throw new GnpyException("In GnpyResult: the codec registry from the normalized node is null!");
+ throw new GnpyException("In GnpyResult: the codec registry from the normalized node is null");
}
List<Response> responses = null;
responses = ((Result) dataObject).getResponse();
boolean isFeasible = false;
if (response != null) {
if (response.getResponseType() instanceof NoPathCase) {
- isFeasible = false;
LOG.info("In GnpyResult: The path is not feasible ");
} else if (response.getResponseType() instanceof PathCase) {
isFeasible = true;
}
private String findOrdNetworkNodeId(IpAddress nodeIpAddress) {
- String nodeId;
- Set<String> keySet = this.mapNodeRefIp.keySet();
- Iterator<String> it = keySet.iterator();
+ Iterator<Map.Entry<String,IpAddress>> it = this.mapNodeRefIp.entrySet().iterator();
while (it.hasNext()) {
- nodeId = it.next();
- if (this.mapNodeRefIp.get(nodeId).equals(nodeIpAddress)) {
- return nodeId;
+ Entry<String, IpAddress> entry = it.next();
+ if (entry.getValue().equals(nodeIpAddress)) {
+ return entry.getKey();
}
}
return null;
public <T extends DataObject> Optional<T> getDataObject(@Nonnull NormalizedNode<?, ?> normalizedNode,
@Nonnull QName rootNode, BindingNormalizedNodeSerializer codecRegistry) {
if (normalizedNode != null) {
- LOG.debug("GNPy: The codecRegistry is {}", codecRegistry.toString());
+ LOG.debug("GNPy: The codecRegistry is {}", codecRegistry);
} else {
LOG.warn("GNPy: The codecRegistry is null");
}
LOG.debug("GNPy: the normalized node is {}", normalizedNode.getNodeType());
}
YangInstanceIdentifier rootNodeYangInstanceIdentifier = YangInstanceIdentifier.of(rootNode);
- LOG.debug("GNPy: the root Node Yang Instance Identifier is {}", rootNodeYangInstanceIdentifier.toString());
+ LOG.debug("GNPy: the root Node Yang Instance Identifier is {}", rootNodeYangInstanceIdentifier);
Map.Entry<?, ?> bindingNodeEntry = codecRegistry.fromNormalizedNode(rootNodeYangInstanceIdentifier,
normalizedNode);
if (bindingNodeEntry == null) {
package org.opendaylight.transportpce.pce.gnpy;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
public class GnpyServiceImpl {
private static final Logger LOG = LoggerFactory.getLogger(GnpyServiceImpl.class);
- private static final double FIX_CH = 0.05; //Fix-grid channel width (THz)
- private static final int NB_SLOT_BW = 4; //Number of slot in 50GHz channel (THz)
- private static final double SLOT_BW = 0.00625; //Nominal central frequency granularity (THz)
- private static final double MAX_CENTRAL_FREQ = 196.1; //Minimum channel center frequency (openRoadm spec) (THz)
- private static final double FLEX_CENTRAL_FREQ = 193.1; //Flex-grid reference channel frequency (THz)
- private static final double CONVERT_TH_HZ = 1e12; //Convert THz to Hz
+ //Fix-grid channel width (THz)
+ private static final double FIX_CH = 0.05;
+ //Number of slot in 50GHz channel (THz)
+ private static final int NB_SLOT_BW = 4;
+ //Nominal central frequency granularity (THz)
+ private static final double SLOT_BW = 0.00625;
+ //Minimum channel center frequency (openRoadm spec) (THz)
+ private static final double MAX_CENTRAL_FREQ = 196.1;
+ //Flex-grid reference channel frequency (THz)
+ private static final double FLEX_CENTRAL_FREQ = 193.1;
+ //Convert THz to Hz
+ private static final double CONVERT_TH_HZ = 1e12;
private List<PathRequest> pathRequest = new ArrayList<>();
private List<Synchronization> synchronization = new ArrayList<>();
- private Map<String, String> mapDisgNodeRefNode = new HashMap<String, String>();
- private Map<String, IpAddress> mapNodeRefIp = new HashMap<String, IpAddress>();
- private Map<String, List<String>> mapLinkFiber = new HashMap<String, List<String>>();
- private Map<String, IpAddress> mapFiberIp = new HashMap<String, IpAddress>();
+ private Map<String, String> mapDisgNodeRefNode = new HashMap<>();
+ private Map<String, IpAddress> mapNodeRefIp = new HashMap<>();
+ private Map<String, List<String>> mapLinkFiber = new HashMap<>();
+ private Map<String, IpAddress> mapFiberIp = new HashMap<>();
private List<String> trxList = new ArrayList<>();
private List<Elements> elements = new ArrayList<>();
private List<RouteObjectIncludeExclude> routeObjectIncludeExcludes = new ArrayList<>();
- private Long index = (long) 0; //index of the element in the path
private IpAddress currentNodeIpAddress = null;
/*
List<PathRequest> pathRequestList = new ArrayList<>();
PathRequest pathRequestEl = new PathRequestBuilder().setRequestId(requestId)
.setSource(this.mapNodeRefIp.get(sourceNode)).setDestination(this.mapNodeRefIp.get(destNode))
- .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes())
+ .setSrcTpId("srcTpId".getBytes(StandardCharsets.UTF_8))
+ .setDstTpId("dstTpId".getBytes(StandardCharsets.UTF_8))
.setBidirectional(false).setPathConstraints(pathConstraints).setPathConstraints(pathConstraints)
.setExplicitRouteObjects(explicitRouteObjects).build();
pathRequestList.add(pathRequestEl);
List<PathRequest> pathRequestList = new ArrayList<>();
PathRequest pathRequestEl = new PathRequestBuilder().setRequestId(requestId)
.setSource(this.mapNodeRefIp.get(sourceNode)).setDestination(this.mapNodeRefIp.get(destNode))
- .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes())
+ .setSrcTpId("srcTpId".getBytes(StandardCharsets.UTF_8))
+ .setDstTpId("dstTpId".getBytes(StandardCharsets.UTF_8))
.setBidirectional(false).setPathConstraints(pathConstraints)
.setExplicitRouteObjects(explicitRouteObjects).build();
pathRequestList.add(pathRequestEl);
//Extract RouteObjectIncludeExclude list in the case of pre-computed path A-to-Z
private void extractRouteObjectIcludeAtoZ(List<AToZ> listAtoZ) throws GnpyException {
+ Long index = 0L;
for (int i = 0; i < listAtoZ.size(); i++) {
- createResource(listAtoZ.get(i).getResource().getResource());
+ index = createResource(listAtoZ.get(i).getResource().getResource(),index);
}
}
//Extract RouteObjectIncludeExclude list in the case of pre-computed path Z-to-A
private void extractRouteObjectIcludeZtoA(List<ZToA> listZtoA) throws GnpyException {
+ Long index = 0L;
for (int i = 0; i < listZtoA.size(); i++) {
- createResource(listZtoA.get(i).getResource().getResource());
+ index = createResource(listZtoA.get(i).getResource().getResource(),index);
}
}
//Create a new resource node or link
- private void createResource(@Nullable Resource resource) throws GnpyException {
+ private Long createResource(@Nullable Resource resource, Long index) throws GnpyException {
+ Long idx = index;
if (resource
instanceof
org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017
if (node.getNodeId() == null) {
throw new GnpyException("In gnpyServiceImpl: nodeId is null");
}
- addNodeToRouteObject(this.mapDisgNodeRefNode.get(node.getNodeId()));
- return;
+ idx = addNodeToRouteObject(this.mapDisgNodeRefNode.get(node.getNodeId()),idx);
}
if (resource
.pce.resource.resource.resource.Link link =
(org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017
.pce.resource.resource.resource.Link) resource;
- addLinkToRouteObject(link.getLinkId());
- return;
+ idx = addLinkToRouteObject(link.getLinkId(),idx);
}
+ return idx;
}
//Create RouteObjectIncludeExclude list in the case of hard constraint
private void extractHardConstraints(PceConstraints pceHardConstraints) throws GnpyException {
List<String> listNodeToInclude = getListToInclude(pceHardConstraints);
- if (listNodeToInclude != null) {
+ if (!listNodeToInclude.isEmpty()) {
+ Long index = 0L;
for (int i = 0; i < listNodeToInclude.size(); i++) {
String nodeId = listNodeToInclude.get(i);
- addNodeToRouteObject(nodeId);
+ index = addNodeToRouteObject(nodeId, index);
}
}
}
}
//Add a node to the route object
- private void addNodeToRouteObject(String nodeRef) throws GnpyException {
- boolean found = false;
+ private Long addNodeToRouteObject(String nodeRef, Long index) throws GnpyException {
+ Long idx = index;
IpAddress ipAddress = this.mapNodeRefIp.get(nodeRef);
if (ipAddress == null) {
throw new GnpyException(String.format("In gnpyServiceImpl : NodeRef %s does not exist", nodeRef));
for (Elements element : this.elements) {
if (element.getUid().contains(ipAddress.getIpv4Address().getValue())) {
- if ((this.currentNodeIpAddress == null) || (this.currentNodeIpAddress != ipAddress)) {
+ if ((this.currentNodeIpAddress == null) || (!this.currentNodeIpAddress.equals(ipAddress))) {
this.currentNodeIpAddress = ipAddress;
RouteObjectIncludeExclude routeObjectIncludeExclude =
- addRouteObjectIncludeExclude(ipAddress, Uint32.valueOf(1));
+ addRouteObjectIncludeExclude(ipAddress, Uint32.valueOf(1),idx);
routeObjectIncludeExcludes.add(routeObjectIncludeExclude);
- index++;
- found = true;
+ idx += 1;
}
- return;
+ return idx;
}
}
- if (!found) {
- throw new GnpyException(String.format("In gnpyServiceImpl : NodeRef %s does not exist",nodeRef));
- }
+ throw new GnpyException(String.format("In gnpyServiceImpl : NodeRef %s does not exist",nodeRef));
}
//Add a link to the route object
- private void addLinkToRouteObject(String linkId) throws GnpyException {
+ private Long addLinkToRouteObject(String linkId, Long index) throws GnpyException {
+ Long idx = index;
if (linkId == null) {
- throw new GnpyException(String.format("In GnpyServiceImpl: the linkId does not exist"));
+ throw new GnpyException("In GnpyServiceImpl: the linkId is null");
}
//Only the ROADM-to-ROADM link are included in the route object
if (!mapLinkFiber.containsKey(linkId)) {
- return;
+ return idx;
}
List<String> listSubLink = this.mapLinkFiber.get(linkId);
if (listSubLink == null) {
subLink));
}
RouteObjectIncludeExclude routeObjectIncludeExclude =
- addRouteObjectIncludeExclude(fiberIp, Uint32.valueOf(1));
+ addRouteObjectIncludeExclude(fiberIp, Uint32.valueOf(1),idx);
routeObjectIncludeExcludes.add(routeObjectIncludeExclude);
- index++;
+ idx += 1;
}
+ return idx;
}
// Add routeObjectIncludeExclude
- private RouteObjectIncludeExclude addRouteObjectIncludeExclude(IpAddress ipAddress, Uint32 teTpValue) {
+ private RouteObjectIncludeExclude addRouteObjectIncludeExclude(IpAddress ipAddress, Uint32 teTpValue, Long index) {
TeNodeId teNodeId = new TeNodeId(ipAddress);
TeTpId teTpId = new TeTpId(teTpValue);
NumUnnumHop numUnnumHop = new org.opendaylight.yang.gen.v1.gnpy.path.rev200202.explicit.route.hop.type.num
.setHopType(TeHopType.STRICT).build();
Type type1 = new NumUnnumHopBuilder().setNumUnnumHop(numUnnumHop).build();
// Create routeObjectIncludeExclude element
- RouteObjectIncludeExclude routeObjectIncludeExclude = new RouteObjectIncludeExcludeBuilder()
- .setIndex(this.index).setExplicitRouteUsage(RouteIncludeEro.class).setType(type1).build();
- return routeObjectIncludeExclude;
+ return new RouteObjectIncludeExcludeBuilder()
+ .setIndex(index).setExplicitRouteUsage(RouteIncludeEro.class).setType(type1).build();
}
//Create the path constraints
TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
.setTechnology("flexi-grid").setTrxType("openroadm-beta1")
.setTrxMode("W100G").setEffectiveFreqSlot(effectiveFreqSlot)
- .setSpacing(new BigDecimal(FIX_CH * CONVERT_TH_HZ)).build();
- PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
- return pathConstraints;
+ .setSpacing(BigDecimal.valueOf(FIX_CH * CONVERT_TH_HZ)).build();
+ return new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
}
//Create the synchronization
private List<Connections> connections = new ArrayList<>();
//Mapping elements
//Mapping between the ord-topo and ord-ntw node
- private Map<String, String> mapDisgNodeRefNode = new HashMap<String, String>();
+ private Map<String, String> mapDisgNodeRefNode = new HashMap<>();
//Mapping between the ord-ntw and node ip
- private Map<String, IpAddress> mapNodeRefIp = new HashMap<String, IpAddress>();
+ private Map<String, IpAddress> mapNodeRefIp = new HashMap<>();
//Mapping between the ROADM-ROADM linkId/secElement and the linkId
- private Map<String, List<String>> mapLinkFiber = new HashMap<String, List<String>>();
+ private Map<String, List<String>> mapLinkFiber = new HashMap<>();
//Mapping between the ROADM-ROADM linkId/secElement and ipAddress
- private Map<String, IpAddress> mapFiberIp = new HashMap<String, IpAddress>();
+ private Map<String, IpAddress> mapFiberIp = new HashMap<>();
//List of Xponders
private List<String> trxList = new ArrayList<>();
//Initialize the 32 bit identifiers for the edfa and the fiber.
.read(LogicalDatastoreType.CONFIGURATION, insIdrOpenRoadmNet).get();
if (openRoadmNet.isPresent() && openRoadmTopo.isPresent()) {
extractElements(openRoadmTopo,openRoadmNet);
- extractConnections(openRoadmTopo,openRoadmNet);
+ extractConnections(openRoadmTopo);
LOG.debug("In GnpyTopoImpl : elements and connections are well extracted");
}
else {
private void extractElements(java.util.Optional<Network> openRoadmTopo,
java.util.Optional<Network> openRoadmNet) throws GnpyException {
+ if ((!openRoadmNet.isPresent()) || (!openRoadmTopo.isPresent())) {
+ throw new GnpyException("In gnpyTopoImpl: openRoadmNet or openRoadmTopo is not present");
+ }
// Create the list of nodes
List<Node> openRoadmNetNodeList = openRoadmNet.get().getNode();
List<Node> openRoadmTopoNodeList = openRoadmTopo.get().getNode();
}
IpAddress ipAddress = null;
String nodeRef = supportingNode.getNodeRef().getValue();
+ if (nodeRef == null) {
+ throw new GnpyException("In gnpyTopoImpl: nodeRef is null");
+ }
// Retrieve the mapping between the openRoadm topology and openRoadm network
mapDisgNodeRefNode.put(openRoadmTopoNode.getNodeId().getValue(), nodeRef);
Node1 openRoadmNetNode1 = null;
commonNetworkNode1 = openRoadmNetNode.augmentation(org.opendaylight.yang.gen.v1
.http.org.openroadm.common.network.rev181130.Node1.class);
ipAddress = openRoadmNetNode1.getIp();
+ if (ipAddress == null) {
+ throw new GnpyException(String.format(
+ "In gnpyTopoImpl: ipAddress of node %s is null",nodeRef));
+ }
mapNodeRefIp.put(nodeRef, ipAddress);
break;
}
}
+ if (commonNetworkNode1 == null) {
+ throw new GnpyException(String.format("In gnpyTopoImpl: the node type of %s is null",nodeRef));
+ }
if (commonNetworkNode1.getNodeType().getName().equals("ROADM")) {
if (!nodesList.contains(nodeRef)) {
Elements element = createElementsRoadm(LATITUDE, LONGITUTE, nodeRef,
}
}
- private void extractConnections(java.util.Optional<Network> openRoadmTopo,
- java.util.Optional<Network> openRoadmNet) throws GnpyException {
+ private void extractConnections(java.util.Optional<Network> openRoadmTopo) throws GnpyException {
// Create the list of connections
+ if (!openRoadmTopo.isPresent()) {
+ throw new GnpyException("In gnpyTopoImpl: openroadmTopo is not present");
+ }
Network1 nw1 = openRoadmTopo.get().augmentation(Network1.class);
List<Link> linksList = nw1.getLink();
// 1:EXPRESS-LINK 2:ADD-LINK 3:DROP-LINK
org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130
.Link1 openroadmNetworkLink1 = link.augmentation(org.opendaylight.yang.gen.v1.http.org
.openroadm.network.topology.rev181130.Link1.class);
+ if (link1.getLinkType() == null) {
+ throw new GnpyException("In gnpyTopoImpl: the link type is null");
+ }
int linkType = link1.getLinkType().getIntValue();
if (! IntStream.of(externalLink).anyMatch(x -> x == linkType)) {
continue;
//Case of Span
if (amplifiedLink.getSectionElement().getSectionElement() instanceof Span) {
Span span = (Span) amplifiedLink.getSectionElement().getSectionElement();
- destIp = extractSpan((SpanAttributes) span.getSpan(), linkId, secElt);
+ destIp = extractSpan(span.getSpan(), linkId, secElt);
}
// Create a new link
if (createNewConnection(srcIp,destIp)) {
throws GnpyException {
SpanAttributes span = omsAttributes.getSpan();
- IpAddress destIp = extractSpan((SpanAttributes) span, linkId, linkId);
+ IpAddress destIp = extractSpan(span, linkId, linkId);
if (createNewConnection(srcIp, destIp)) {
return destIp;
}
//convert to kilometer
length += srlgLength / CONVERT_KM_M;
}
+ if (length == 0) {
+ throw new GnpyException(String.format(
+ "In gnpyTopoImpl: length of the link %s is equal to zero",linkId));
+ }
double lossCoef = span.getSpanlossCurrent().getValue().doubleValue() / length;
Elements element = createElementsFiber(LATITUDE, LONGITUTE, REGION, CITY,
ipFiber.getIpv4Address().getValue(), length, attIn, lossCoef, connIn, connOut, typeVariety);
private Elements createElementsFiber(double latitude, double longitude, String region, String city, String uidFiber,
double length, double attIn, double lossCoef, double connIn, double connOut, String typeVariety) {
// Create an amplifier after the ROADM
- Coordinate c1 = new Coordinate(new BigDecimal(latitude));
- Coordinate c2 = new Coordinate(new BigDecimal(longitude));
+ Coordinate c1 = new Coordinate(BigDecimal.valueOf(latitude));
+ Coordinate c2 = new Coordinate(BigDecimal.valueOf(longitude));
Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
.build();
Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
- Fiber fiber = new FiberBuilder().setLength(new BigDecimal(length)).setLengthUnits(Km.class)
- .setAttIn(new BigDecimal(attIn)).setLossCoef(new BigDecimal(lossCoef)).setConIn(new BigDecimal(connIn))
- .setConOut(new BigDecimal(connOut)).build();
+ Fiber fiber = new FiberBuilder().setLength(BigDecimal.valueOf(length)).setLengthUnits(Km.class)
+ .setAttIn(BigDecimal.valueOf(attIn)).setLossCoef(BigDecimal.valueOf(lossCoef))
+ .setConIn(BigDecimal.valueOf(connIn))
+ .setConOut(BigDecimal.valueOf(connOut)).build();
Params params1 = new ParamsBuilder().setFiberroadm(fiber).build();
- Elements element1 = new ElementsBuilder().setUid(uidFiber)
+ return new ElementsBuilder().setUid(uidFiber)
.setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Fiber.class)
.setTypeVariety(typeVariety).setMetadata(metadata1)
.setElementType(new FiberRoadmBuilder().setParams(params1).build()).build();
- return element1;
}
/*
private Elements createElementsEdfa(double latitude, double longitude, String region, String city,
BigDecimal gainTarget, BigDecimal tiltTarget, BigDecimal outVoa, String typeVariety, String uidEdfa) {
// Create an amplifier after the ROADM
- Coordinate c1 = new Coordinate(new BigDecimal(latitude));
- Coordinate c2 = new Coordinate(new BigDecimal(longitude));
+ Coordinate c1 = new Coordinate(BigDecimal.valueOf(latitude));
+ Coordinate c2 = new Coordinate(BigDecimal.valueOf(longitude));
Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
.build();
Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
.setOutVoa(outVoa).build();
Edfa edfa = new EdfaBuilder()
.setOperational(operational).build();
- Elements element1 = new ElementsBuilder().setUid(uidEdfa)
+ return new ElementsBuilder().setUid(uidEdfa)
.setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Edfa.class)
.setMetadata(metadata1).setElementType(edfa).setTypeVariety(typeVariety).build();
- return element1;
}
/*
private Elements createElementsRoadm(double latitude, double longitude, String region, String city,
double targetPchOutDb, String uidRoadm) {
- Coordinate c1 = new Coordinate(new BigDecimal(latitude));
- Coordinate c2 = new Coordinate(new BigDecimal(longitude));
+ Coordinate c1 = new Coordinate(BigDecimal.valueOf(latitude));
+ Coordinate c2 = new Coordinate(BigDecimal.valueOf(longitude));
Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
.build();
Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
- Roadm roadm = new RoadmBuilder().setTargetPchOutDb(new BigDecimal(targetPchOutDb)).build();
+ Roadm roadm = new RoadmBuilder().setTargetPchOutDb(BigDecimal.valueOf(targetPchOutDb)).build();
Params params1 = new ParamsBuilder().setFiberroadm(roadm).build();
- Elements element1 = new ElementsBuilder().setUid(uidRoadm)
+ return new ElementsBuilder().setUid(uidRoadm)
.setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Roadm.class)
.setMetadata(metadata1).setElementType(new FiberRoadmBuilder().setParams(params1).build()).build();
- return element1;
}
/*
*/
private Elements createElementsTransceiver(double latitude, double longitude, String region, String city,
String uidTrans) {
- Coordinate c1 = new Coordinate(new BigDecimal(latitude));
- Coordinate c2 = new Coordinate(new BigDecimal(longitude));
+ Coordinate c1 = new Coordinate(BigDecimal.valueOf(latitude));
+ Coordinate c2 = new Coordinate(BigDecimal.valueOf(longitude));
Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
.build();
Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
Transceiver transceiver = new TransceiverBuilder().build();
- Elements element1 = new ElementsBuilder().setUid(uidTrans)
+ return new ElementsBuilder().setUid(uidTrans)
.setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Transceiver.class)
.setMetadata(metadata1).setElementType(transceiver).build();
- return element1;
}
/*
}
String fromNode = srcIp.getIpv4Address().getValue();
String toNode = destIp.getIpv4Address().getValue();
- if (fromNode == toNode) {
+ if (fromNode.equals(toNode)) {
return false;
}
Connections connection = new ConnectionsBuilder().setFromNode(fromNode).setToNode(toNode).build();
}
fields[3] = Integer.toString(intF3);
String nidString = fields[0] + "." + fields[1] + "." + fields[2] + "." + fields[3];
- Ipv4Address nid = new Ipv4Address(nidString);
- return nid;
+ return new Ipv4Address(nidString);
}
public List<Elements> getElements() {
public class GnpyUtilitiesImpl {
- private static final Logger LOG = LoggerFactory.getLogger(GnpyResult.class);
+ private static final Logger LOG = LoggerFactory.getLogger(GnpyUtilitiesImpl.class);
private NetworkTransactionService networkTransaction;
private PathComputationRequestInput input;
private GnpyTopoImpl gnpyTopo = null;
synchronizationList);
// Analyze the response
if (gnpyResponse == null) {
- throw new GnpyException("In GnpyUtilities: no respnse from GNPy server");
+ throw new GnpyException("In GnpyUtilities: no response from GNPy server");
}
GnpyResult result = new GnpyResult(gnpyResponse, gnpyTopo);
result.analyzeResult();
return result;
}
- public HardConstraints askNewPathFromGnpy(HardConstraints gnpyPathAsHC, PceConstraints pceHardConstraints)
+ public HardConstraints askNewPathFromGnpy(PceConstraints pceHardConstraints)
throws GnpyException, Exception {
AToZDirection atoztmp = new AToZDirectionBuilder()
GnpyResult result = gnpyResponseOneDirection(gnpySvc);
if (result == null) {
- throw new GnpyException("In GnpyUtilities: no response from the GNPy server");
+ throw new GnpyException("In GnpyUtilities: no result from the GNPy server");
}
if (!result.getPathFeasibility()) {
return null;
}
List<PathRouteObjects> pathRouteObjectList = result.analyzeResult();
- gnpyPathAsHC = result.computeHardConstraintsFromGnpyPath(pathRouteObjectList);
-
- return gnpyPathAsHC;
+ return result.computeHardConstraintsFromGnpyPath(pathRouteObjectList);
}
public String getGnpyResponse(List<Elements> elementsList, List<Connections> connectionsList,
.replace("gnpy-path-computation-simplified:", "")
.replace("gnpy-network-topology:", "");
- String gnpyResponse = connect.gnpyCnx(gnpyJsonModified);
- return gnpyResponse;
+ return connect.returnGnpyResponse(gnpyJsonModified);
}
public GnpyResult getGnpyAtoZ() {
package org.opendaylight.transportpce.pce.gnpy;
-import com.google.common.base.Function;
//false positive in SpotBug -> cannot be used with FluentIterable...
import com.google.common.collect.FluentIterable;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Optional;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
import org.opendaylight.yangtools.yang.data.codec.gson.JsonWriterFactory;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public ServiceDataStoreOperationsImpl(NetworkTransactionService networkTransactionService) {
}
+ @Override
public void createXMLFromDevice(DataStoreContext dataStoreContextUtil, OrgOpenroadmDevice device, String output)
throws GnpyException {
}
Writer writerFromDataObject =
cwDsU.writerFromDataObject(device, OrgOpenroadmDevice.class,cwDsU.dataContainer());
- try {
- BufferedWriter writer = new BufferedWriter(new FileWriter(output));
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter(output,StandardCharsets.UTF_8))) {
writer.write(writerFromDataObject.toString());
- writer.close();
} catch (IOException e) {
throw new GnpyException(
- String.format("In ServiceDataStoreOperationsImpl : Bufferwriter error"),e);
+ String.format("In ServiceDataStoreOperationsImpl : Bufferwriter error %s",e));
}
- LOG.debug("GNPy: device xml : {}", writerFromDataObject.toString());
+ LOG.debug("GNPy: device xml : {}", writerFromDataObject);
}
}
+ @Override
public String createJsonStringFromDataObject(final InstanceIdentifier<?> id, DataObject object)
throws GnpyException, Exception {
- final SchemaPath scPath = SchemaPath
- .create(FluentIterable.from(id.getPathArguments()).transform(new Function<PathArgument, QName>() {
- @Override
- public QName apply(final PathArgument input) {
- return BindingReflections.findQName(input.getType());
- }
- }), true);
- final Writer writer = new StringWriter();
- NormalizedNodeStreamWriter domWriter;
+ final SchemaPath scPath = SchemaPath.create(FluentIterable
+ .from(id.getPathArguments())
+ .transform(input -> BindingReflections.findQName(input.getType())), true);
+
+ // Prepare the variables
+ final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
+ Iterable<? extends YangModuleInfo> moduleInfos = Collections
+ .singleton(BindingReflections.getModuleInfo(object.getClass()));
+ moduleContext.addModuleInfos(moduleInfos);
+ SchemaContext schemaContext = moduleContext.tryToCreateSchemaContext().get();
+ BindingRuntimeContext bindingContext;
+ bindingContext = BindingRuntimeContext.create(moduleContext, schemaContext);
+ final BindingNormalizedNodeCodecRegistry codecRegistry =
+ new BindingNormalizedNodeCodecRegistry(bindingContext);
- try {
- // Prepare the variables
- final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
- Iterable<? extends YangModuleInfo> moduleInfos = Collections
- .singleton(BindingReflections.getModuleInfo(object.getClass()));
- moduleContext.addModuleInfos(moduleInfos);
- SchemaContext schemaContext = moduleContext.tryToCreateSchemaContext().get();
- BindingRuntimeContext bindingContext;
- bindingContext = BindingRuntimeContext.create(moduleContext, schemaContext);
- final BindingNormalizedNodeCodecRegistry codecRegistry =
- new BindingNormalizedNodeCodecRegistry(bindingContext);
+ /*
+ * This function needs : - context - scPath.getParent() -
+ * scPath.getLastComponent().getNamespace(), -
+ * JsonWriterFactory.createJsonWriter(writer)
+ */
+ final Writer writer = new StringWriter();
- /*
- * This function needs : - context - scPath.getParent() -
- * scPath.getLastComponent().getNamespace(), -
- * JsonWriterFactory.createJsonWriter(writer)
- */
- domWriter = JSONNormalizedNodeStreamWriter.createExclusiveWriter(
+ try (NormalizedNodeStreamWriter domWriter = JSONNormalizedNodeStreamWriter.createExclusiveWriter(
JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.createSimple(schemaContext),
scPath.getParent(), scPath.getLastComponent().getNamespace(),
- JsonWriterFactory.createJsonWriter(writer, 2));
+ JsonWriterFactory.createJsonWriter(writer, 2));) {
// The write part
codecRegistry.getSerializer(id.getTargetType()).serialize(object, codecRegistry.newWriter(id, domWriter));
- domWriter.close();
- writer.close();
- } catch (IOException | YangSyntaxErrorException | ReactorException e) {
+ } catch (IOException e) {
throw new GnpyException("In ServiceDataStoreOperationsImpl: exception during json file creation",e);
}
return writer.toString();
}
// Write the json as a string in a file
+ @Override
public void writeStringFile(String jsonString, String fileName) throws GnpyException {
- try {
- FileWriter file = new FileWriter(fileName);
+ try (FileWriter file = new FileWriter(fileName,StandardCharsets.UTF_8)) {
file.write(jsonString);
- file.close();
} catch (IOException e) {
throw new GnpyException("In ServiceDataStoreOperationsImpl : exception during file writing",e);
}
import org.jgrapht.GraphPath;
import org.jgrapht.alg.shortestpath.PathValidator;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType;
-//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class InAlgoPathValidator implements PathValidator<String, PceGraphEdge> {
/* Logging. */
- private static final Logger LOG = LoggerFactory.getLogger(PceGraph.class);
+ private static final Logger LOG = LoggerFactory.getLogger(InAlgoPathValidator.class);
public InAlgoPathValidator() {
super();
LOG.debug("InAlgoPathValidator: partialPath size: {} prev edge {} new edge {}",
size, edge.link().getlinkType(), partialPath.getEdgeList().get(size - 1).link().getlinkType());
- if ((!checkTurn(partialPath.getEdgeList().get(size - 1).link().getlinkType(), edge.link().getlinkType()))) {
- return false;
- } else {
- return true;
- }
+ return (checkTurn(partialPath.getEdgeList().get(size - 1).link().getlinkType(), edge.link().getlinkType()));
}
private boolean checkTurn(OpenroadmLinkType prevType, OpenroadmLinkType nextType) {
import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
import org.opendaylight.transportpce.pce.networkanalyzer.PceResult.LocalCause;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private int mhopsPerPath = 50;
// input
- private Map<NodeId, PceNode> allPceNodes = new HashMap<NodeId, PceNode>();
+ private Map<NodeId, PceNode> allPceNodes = new HashMap<>();
private PceNode apceNode = null;
private PceNode zpceNode = null;
private String serviceType = "";
// for path calculation
List<GraphPath<String, PceGraphEdge>> allWPaths = null;
- private List<PceLink> pathAtoZ = new ArrayList<PceLink>();
+ private List<PceLink> pathAtoZ = new ArrayList<>();
public PceGraph(PceNode aendNode, PceNode zendNode, Map<NodeId, PceNode> allPceNodes,
PceConstraints pceHardConstraints, PceConstraints pceSoftConstraints, PceResult pceResult,
this.pceSoftConstraints = pceSoftConstraints;
this.serviceType = serviceType;
- LOG.info("In GraphCalculator: A and Z = {} / {} ", aendNode.toString(), zendNode.toString());
- LOG.debug("In GraphCalculator: allPceNodes size {}, nodes {} ", allPceNodes.size(), allPceNodes.toString());
+ LOG.info("In GraphCalculator: A and Z = {} / {} ", aendNode, zendNode);
+ LOG.debug("In GraphCalculator: allPceNodes size {}, nodes {} ", allPceNodes.size(), allPceNodes);
}
public boolean calcPath() {
LOG.info(" In PCE GRAPH calcPath : K SHORT PATHS algorithm ");
DefaultDirectedWeightedGraph<String, PceGraphEdge> weightedGraph =
- new DefaultDirectedWeightedGraph<String, PceGraphEdge>(PceGraphEdge.class);
+ new DefaultDirectedWeightedGraph<>(PceGraphEdge.class);
populateWithNodes(weightedGraph);
populateWithLinks(weightedGraph);
if (!runKgraphs(weightedGraph)) {
- LOG.info("In calcPath : pceResult {}", pceResult.toString());
+ LOG.info("In calcPath : pceResult {}", pceResult);
return false;
}
pceResult.getResponseCode(), ResponseCodes.RESPONSE_OK);
if (!pceResult.getResponseCode().equals(ResponseCodes.RESPONSE_OK)) {
- LOG.info("In calcPath: post algo validations DROPPED the path {}", path.toString());
+ LOG.info("In calcPath: post algo validations DROPPED the path {}", path);
continue;
}
shortestPathAtoZ = new ArrayList<>(pathAtoZ);
if (("100GE".equals(serviceType)) || ("OTU4".equals(serviceType))) {
LOG.info("In calcPath Path FOUND path for wl [{}], hops {}, distance per metrics {}, path AtoZ {}",
- pceResult.getResultWavelength(), pathAtoZ.size(), path.getWeight(), pathAtoZ.toString());
+ pceResult.getResultWavelength(), pathAtoZ.size(), path.getWeight(), pathAtoZ);
break;
} else {
// Service is at OTN layer and is relying on a supporting wavelength service
LOG.info("In calcPath Path FOUND path for hops {}, distance per metrics {}, path AtoZ {}",
- pathAtoZ.size(), path.getWeight(), pathAtoZ.toString());
+ pathAtoZ.size(), path.getWeight(), pathAtoZ);
break;
}
if (shortestPathAtoZ != null) {
LOG.info("In calcPath CHOOSEN PATH for wl [{}], hops {}, path AtoZ {}",
- pceResult.getResultWavelength(), shortestPathAtoZ.size(), shortestPathAtoZ.toString());
+ pceResult.getResultWavelength(), shortestPathAtoZ.size(), shortestPathAtoZ);
}
- LOG.info("In calcPath : pceResult {}", pceResult.toString());
+ LOG.info("In calcPath : pceResult {}", pceResult);
return (pceResult.getStatus());
}
// KShortestPaths on weightedGraph
KShortestSimplePaths<String, PceGraphEdge> swp =
- new KShortestSimplePaths<String, PceGraphEdge>(weightedGraph, mhopsPerPath, wpv);
+ new KShortestSimplePaths<>(weightedGraph, mhopsPerPath, wpv);
allWPaths = swp.getPaths(apceNode.getNodeId().getValue(), zpceNode.getNodeId().getValue(), kpathsToBring);
if (allWPaths.isEmpty()) {
// debug print
for (GraphPath<String, PceGraphEdge> path : allWPaths) {
- LOG.debug("path Weight: {} : {}", path.getWeight(), path.getVertexList().toString());
+ LOG.debug("path Weight: {} : {}", path.getWeight(), path.getVertexList());
}
return true;
PceNode dest = allPceNodes.get(pcelink.getDestId());
if (source == null) {
- LOG.error("In addLinkToGraph link source node is null : {}", pcelink.toString());
+ LOG.error("In addLinkToGraph link source node is null : {}", pcelink);
return false;
}
if (dest == null) {
- LOG.error("In addLinkToGraph link dest node is null : {}", pcelink.toString());
+ LOG.error("In addLinkToGraph link dest node is null : {}", pcelink);
return false;
}
- LOG.debug("In addLinkToGraph link to nodes : {}{} {}", pcelink.toString(), source.toString(), dest.toString());
+ LOG.debug("In addLinkToGraph link to nodes : {}{} {}", pcelink, source, dest);
return true;
}
while (nodes.hasNext()) {
Map.Entry<NodeId, PceNode> node = nodes.next();
weightedGraph.addVertex(node.getValue().getNodeId().getValue());
- LOG.debug("In populateWithNodes in node : {}", node.getValue().toString());
+ LOG.debug("In populateWithNodes in node : {}", node.getValue());
}
}
PceNode pcenode = node.getValue();
List<PceLink> links = pcenode.getOutgoingLinks();
- LOG.debug("In populateGraph: use node for graph {}", pcenode.toString());
+ LOG.debug("In populateGraph: use node for graph {}", pcenode);
for (PceLink link : links) {
- LOG.debug("In populateGraph node {} : add edge to graph {}", pcenode.toString(), link.toString());
+ LOG.debug("In populateGraph node {} : add edge to graph {}", pcenode, link);
if (!validateLinkforGraph(link)) {
continue;
switch (pceHardConstraints.getPceMetrics()) {
case HopCount :
weight = 1;
- LOG.debug("In PceGraph HopCount is used as a metrics. {}", link.toString());
+ LOG.debug("In PceGraph HopCount is used as a metrics. {}", link);
break;
case PropagationDelay :
weight = link.getLatency();
- LOG.debug("In PceGraph PropagationDelay is used as a metrics. {}", link.toString());
+ LOG.debug("In PceGraph PropagationDelay is used as a metrics. {}", link);
if ((("1GE".equals(serviceType)) || ("10GE".equals(serviceType)) || ("ODU4".equals(serviceType)))
&& (weight == 0)) {
LOG.warn("PropagationDelay set as metric, but latency is null: is latency set for OTN link {}?",
- link.toString());
+ link);
}
break;
// TODO implement IGPMetric and TEMetric - low priority.
public class PostAlgoPathValidator {
/* Logging. */
- private static final Logger LOG = LoggerFactory.getLogger(PceGraph.class);
+ private static final Logger LOG = LoggerFactory.getLogger(PostAlgoPathValidator.class);
- // TODO hard-coded 96
private static final int MAX_WAWELENGTH = 96;
private static final double MIN_OSNR_W100G = 17;
private static final double TRX_OSNR = 33;
PceResult pceResult, PceConstraints pceHardConstraints, String serviceType) {
// check if the path is empty
- if (path.getEdgeList().size() == 0) {
+ if (path.getEdgeList().isEmpty()) {
pceResult.setRC(ResponseCodes.RESPONSE_FAILED);
return pceResult;
}
return pceResult;
}
pceResult.setResultWavelength(waveL);
- LOG.info("In PostAlgoPathValidator: chooseWavelength WL found {} {}", waveL, path.toString());
+ LOG.info("In PostAlgoPathValidator: chooseWavelength WL found {} {}", waveL, path);
// Check the OSNR
if (!checkOSNR(path)) {
case "ODU4":
pceResult.setRC(ResponseCodes.RESPONSE_OK);
- LOG.info("In PostAlgoPathValidator: ODU4 path found {}", path.toString());
+ LOG.info("In PostAlgoPathValidator: ODU4 path found {}", path);
break;
default:
pceResult.setRC(ResponseCodes.RESPONSE_FAILED);
LOG.warn("In PostAlgoPathValidator checkPath: unsupported serviceType {} found {}",
- serviceType, path.toString());
+ serviceType, path);
break;
}
Long wavelength = -1L;
for (long i = 1; i <= MAX_WAWELENGTH; i++) {
boolean completed = true;
- LOG.debug("In chooseWavelength: {} {}", path.getLength(), path.toString());
+ LOG.debug("In chooseWavelength: {} {}", path.getLength(), path);
for (PceGraphEdge edge : path.getEdgeList()) {
- LOG.debug("In chooseWavelength: source {} ", edge.link().getSourceId().toString());
+ LOG.debug("In chooseWavelength: source {} ", edge.link().getSourceId());
PceNode pceNode = allPceNodes.get(edge.link().getSourceId());
if (!pceNode.checkWL(i)) {
completed = false;
edge.link().getLinkId().getValue());
}
}
- if (latency > maxLatency) {
- return false;
- }
- return true;
+ return (latency < maxLatency);
}
// Check the inclusion if it is defined in the hard constraints
List<PceGraphEdge> pathEdges = path.getEdgeList();
LOG.debug(" in checkInclude vertex list: [{}]", path.getVertexList());
- List<String> listOfElementsSubNode = new ArrayList<String>();
+ List<String> listOfElementsSubNode = new ArrayList<>();
listOfElementsSubNode.add(pathEdges.get(0).link().getsourceNetworkSupNodeId());
listOfElementsSubNode.addAll(listOfElementsBuild(pathEdges, PceConstraints.ResourceType.NODE,
pceHardConstraintsInput));
- List<String> listOfElementsCLLI = new ArrayList<String>();
+ List<String> listOfElementsCLLI = new ArrayList<>();
listOfElementsCLLI.add(pathEdges.get(0).link().getsourceCLLI());
listOfElementsCLLI.addAll(listOfElementsBuild(pathEdges, PceConstraints.ResourceType.CLLI,
pceHardConstraintsInput));
- List<String> listOfElementsSRLG = new ArrayList<String>();
+ List<String> listOfElementsSRLG = new ArrayList<>();
// first link is XPONDEROUTPUT, no SRLG for it
listOfElementsSRLG.add("NONE");
listOfElementsSRLG.addAll(listOfElementsBuild(pathEdges, PceConstraints.ResourceType.SRLG,
private List<String> listOfElementsBuild(List<PceGraphEdge> pathEdges, PceConstraints.ResourceType type,
PceConstraints pceHardConstraints) {
- List<String> listOfElements = new ArrayList<String>();
+ List<String> listOfElements = new ArrayList<>();
for (PceGraphEdge link : pathEdges) {
switch (type) {
case NODE:
listOfElements.add(srlgStr);
LOG.info("listOfElementsBuild. FOUND SRLG {} in link {}", srlgStr, link.link());
found = true;
- continue;
}
}
if (!found) {
private Map<String, Uint16> chooseTribPort(GraphPath<String,
PceGraphEdge> path, Map<NodeId, PceNode> allPceNodes) {
- LOG.info("In choosetribPort: edgeList = {} ", path.getEdgeList().toString());
+ LOG.info("In choosetribPort: edgeList = {} ", path.getEdgeList());
Map<String, Uint16> tribPortMap = new HashMap<>();
for (PceGraphEdge edge : path.getEdgeList()) {
private Map<String, List<Uint16>> chooseTribSlot(GraphPath<String,
PceGraphEdge> path, Map<NodeId, PceNode> allPceNodes, int nbSlot) {
- LOG.info("In choosetribSlot2: edgeList = {} ", path.getEdgeList().toString());
+ LOG.info("In choosetribSlot2: edgeList = {} ", path.getEdgeList());
Map<String, List<Uint16>> tribSlotMap = new HashMap<>();
for (PceGraphEdge edge : path.getEdgeList()) {
discontinue = false;
Integer val = commonEdgeTsPool.get(index).toJava();
for (int i = 0; i < nbSlot; i++) {
- if (commonEdgeTsPool.get(index + i).equals(val + i)) {
+ if (commonEdgeTsPool.get(index + i).equals(Uint16.valueOf(val + i))) {
tribSlotList.add(commonEdgeTsPool.get(index + i));
} else {
discontinue = true;
LOG.debug("In choosetribSlot: AllPceNodes contains PceNode instance, no trib port search");
return tribSlot;
} else if (nodeClass.getClass().isInstance(PceNode.class)) {
- LOG.debug("In choosetribPort: {} {}", path.getLength(), path.toString());
+ LOG.debug("In choosetribPort: {} {}", path.getLength(), path);
}
for (PceGraphEdge edge : path.getEdgeList()) {
- LOG.debug("In chooseTribSlot: source {} ", edge.link().getSourceId().toString());
+ LOG.debug("In chooseTribSlot: source {} ", edge.link().getSourceId());
PceNode pceNode = allPceNodes.get(edge.link().getSourceId());
Object tps = allPceNodes.get(edge.link().getSourceTP());
Object tpd = allPceNodes.get(edge.link().getDestTP());
if ((pceNode.getAvailableTribSlots().containsKey(tps.toString()))
&& (pceNode.getAvailableTribSlots().containsKey(tpd.toString()))) {
- List<Uint16> tribSlotEdgeSourceN = new ArrayList<>();
- List<Uint16> tribSlotEdgeDestN = new ArrayList<>();
- tribSlotEdgeSourceN = pceNode.getAvailableTribSlots().get(tps.toString());
- tribSlotEdgeDestN = pceNode.getAvailableTribSlots().get(tps.toString());
+ List<Uint16> tribSlotEdgeSourceN = pceNode.getAvailableTribSlots().get(tps.toString());
+ List<Uint16> tribSlotEdgeDestN = pceNode.getAvailableTribSlots().get(tps.toString());
check = false;
for (int i = 0; i <= 79; i++) {
if (tribSlotEdgeSourceN.get(i) == null) {
// TODO This will need to be modified as soon as the trib-slots allocation per
// trib-port
// policy applied by the different manufacturer is known
- if (tribSlotEdgeSourceN.get(i) == tribSlotEdgeDestN.get(i)) {
+ if (tribSlotEdgeSourceN.get(i).equals(tribSlotEdgeDestN.get(i))) {
check = true;
} else {
check = false;
LOG.debug("In chooseTribSlot: Misalignement of trib slots between source {} and dest {}",
- edge.link().getSourceId().toString(), edge.link().getDestId().toString());
+ edge.link().getSourceId(), edge.link().getDestId());
break;
}
}
}
} else {
LOG.debug("In chooseTribSlot: source {} does not have provisonned hosting HO interface ",
- edge.link().getSourceId().toString());
+ edge.link().getSourceId());
statusOK = false;
}
}
return false;
}
LOG.info("In checkOSNR: OSNR of the path is {} dB", osnrDb);
- if ((osnrDb + SYS_MARGIN) < MIN_OSNR_W100G) {
- return false;
- }
- return true;
+ return ((osnrDb + SYS_MARGIN) > MIN_OSNR_W100G);
}
private double getOsnrDb(double osnrLu) {
import java.util.Arrays;
import java.util.List;
import java.util.TreeMap;
+
import org.opendaylight.transportpce.common.NetworkUtils;
import org.opendaylight.transportpce.pce.constraints.PceConstraints;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1;
List<String> excSrlgLinks = pceHardConstraints.getExcludeSrlgLinks();
LOG.info("mapDiversityConstraints before : ExcludeClliNodes {} \n ExcludeNodes {} \n ExcludeSrlgLinks {}",
- excClliNodes.toString(), excNodes.toString(), excSrlgLinks.toString());
+ excClliNodes, excNodes, excSrlgLinks);
for (Node node : allNodes) {
if (excClliNodes.contains(node.getNodeId().getValue())) {
if (!srlg.isEmpty()) {
pceHardConstraints.setExcludeSRLG(srlg);
LOG.debug("mapDiversityConstraints setExcludeSRLG {} for link {}",
- srlg.toString(), link.getLinkId().getValue());
+ srlg, link.getLinkId().getValue());
}
}
}
}
LOG.info("mapDiversityConstraints after : ExcludeCLLI {} \n ExcludeSupNodes {} \n ExcludeSRLG {}",
- pceHardConstraints.getExcludeCLLI().toString(),
- pceHardConstraints.getExcludeSupNodes().toString(),
- pceHardConstraints.getExcludeSRLG().toString());
+ pceHardConstraints.getExcludeCLLI(),
+ pceHardConstraints.getExcludeSupNodes(),
+ pceHardConstraints.getExcludeSRLG());
}
}
public static List<Long> getSRLG(Link link) {
- List<Long> srlgList = new ArrayList<Long>();
+ List<Long> srlgList = new ArrayList<>();
try {
List<LinkConcatenation> linkList = getOmsAttributesSpan(link).getLinkConcatenation();
for (LinkConcatenation lc : linkList) {
}
public static List<Long> getSRLGfromLink(Link link) {
- List<Long> srlgList = new ArrayList<Long>();
+ List<Long> srlgList = new ArrayList<>();
org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1 linkC =
link.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class);
if (linkC == null) {
}
public static TreeMap<String, String> getAllSupNode(Node node) {
- TreeMap<String, String> allSupNodes = new TreeMap<String, String>();
- List<SupportingNode> supNodes = new ArrayList<SupportingNode>();
+ TreeMap<String, String> allSupNodes = new TreeMap<>();
+ List<SupportingNode> supNodes = new ArrayList<>();
try {
supNodes = node.getSupportingNode();
} catch (NullPointerException e) {
org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1 linkOpposite
= link.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class);
tmpoppositeLink = linkOpposite.getOppositeLink();
- LOG.debug("PceLink: reading oppositeLink. {}", linkOpposite.toString());
+ LOG.debug("PceLink: reading oppositeLink. {}", linkOpposite);
if (tmpoppositeLink == null) {
LOG.error("PceLink: Error reading oppositeLink. Link is ignored {}", link.getLinkId().getValue());
return null;
private PceConstraints pceHardConstraints;
///////////// Intermediate data/////////////////
- private List<PceLink> addLinks = new ArrayList<PceLink>();
- private List<PceLink> dropLinks = new ArrayList<PceLink>();
- private HashSet<NodeId> azSrgs = new HashSet<NodeId>();
+ private List<PceLink> addLinks = new ArrayList<>();
+ private List<PceLink> dropLinks = new ArrayList<>();
+ private HashSet<NodeId> azSrgs = new HashSet<>();
private PceNode aendPceNode = null;
private PceNode zendPceNode = null;
private List<Node> allNodes = null;
// this List serves graph calculation
- private Map<NodeId, PceNode> allPceNodes = new HashMap<NodeId, PceNode>();
+ private Map<NodeId, PceNode> allPceNodes = new HashMap<>();
// this List serves calculation of ZtoA path description
// TODO maybe better solution is possible
- private Map<LinkId, PceLink> allPceLinks = new HashMap<LinkId, PceLink>();
- private Set<LinkId> linksToExclude = new HashSet<LinkId>();
+ private Map<LinkId, PceLink> allPceLinks = new HashMap<>();
+ private Set<LinkId> linksToExclude = new HashSet<>();
private PceResult returnStructure;
private enum ConstraintTypes {
//And casting to int bumps the limit here.
//Passing by ENUM or String are possible alternatives.
//Maybe HashMap and similar options should also be considered here.
- } else if (serviceFormatA == "Ethernet") {
+ } else if ("Ethernet".equals(serviceFormatA)) {
//only rate 100L is currently supported except in Ethernet
if (serviceRate == 10L) {
serviceType = "10GE";
} else if (serviceRate == 1L) {
serviceType = "1GE";
} else {
- LOG.debug("parseInput: unsupported service type: Format Ethernet Rate {}", String.valueOf(serviceRate));
+ LOG.debug("parseInput: unsupported service type: Format Ethernet Rate {}", serviceRate);
}
} else {
LOG.debug("parseInput: unsupported service type: Format {} Rate {}",
- serviceFormatA, String.valueOf(serviceRate));
+ serviceFormatA, serviceRate);
}
returnStructure.setRate(input.getServiceAEnd().getServiceRate().toJava());
networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, nwInstanceIdentifier).get();
if (nwOptional.isPresent()) {
nw = nwOptional.get();
- LOG.debug("readMdSal: network nodes: nwOptional.isPresent = true {}", nw.toString());
+ LOG.debug("readMdSal: network nodes: nwOptional.isPresent = true {}", nw);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("readMdSal: Error reading topology {}", nwInstanceIdentifier);
return false;
}
LOG.info("readMdSal: network nodes: {} nodes added", allNodes.size());
- LOG.debug("readMdSal: network nodes: {} nodes added", allNodes.toString());
+ LOG.debug("readMdSal: network nodes: {} nodes added", allNodes);
if (allLinks == null || allLinks.isEmpty()) {
LOG.error("readMdSal: no links ");
return false;
}
LOG.info("readMdSal: network links: {} links added", allLinks.size());
- LOG.debug("readMdSal: network links: {} links added", allLinks.toString());
+ LOG.debug("readMdSal: network links: {} links added", allLinks);
return true;
}
validateOtnNode(node);
}
- LOG.info("analyzeNw: allPceNodes {}", allPceNodes.toString());
+ LOG.info("analyzeNw: allPceNodes {}", allPceNodes);
if (aendPceNode == null || zendPceNode == null) {
LOG.error("analyzeNw: Error in reading nodes: A or Z do not present in the network");
return false;
}
- LOG.debug("analyzeNw: allPceNodes {}", allPceNodes.toString());
- LOG.debug("analyzeNw: allPceLinks {}", allPceLinks.toString());
+ LOG.debug("analyzeNw: allPceNodes {}", allPceNodes);
+ LOG.debug("analyzeNw: allPceLinks {}", allPceLinks);
return true;
}
if (azSrgs.contains(nodeId)) {
allPceLinks.put(pcelink.getLinkId(), pcelink);
allPceNodes.get(nodeId).addOutgoingLink(pcelink);
- LOG.debug("analyzeNw: Add_LINK added to source and to allPceLinks {}", pcelink.getLinkId().toString());
+ LOG.debug("analyzeNw: Add_LINK added to source and to allPceLinks {}", pcelink.getLinkId());
return true;
}
if (azSrgs.contains(nodeId)) {
allPceLinks.put(pcelink.getLinkId(), pcelink);
allPceNodes.get(nodeId).addOutgoingLink(pcelink);
- LOG.debug("analyzeNw: Drop_LINK added to dest and to allPceLinks {}", pcelink.getLinkId().toString());
+ LOG.debug("analyzeNw: Drop_LINK added to dest and to allPceLinks {}", pcelink.getLinkId());
return true;
}
}
private boolean validateLink(Link link) {
- LOG.info("validateLink: link {} ", link.toString());
+ LOG.info("validateLink: link {} ", link);
NodeId sourceId = link.getSource().getSourceNode();
NodeId destId = link.getDestination().getDestNode();
return false;
}
LinkId linkId = pcelink.getLinkId();
- switch (validateLinkConstraints(pcelink)) {
- case HARD_EXCLUDE:
- dropOppositeLink(link);
- LOG.debug("validateLink: constraints : link is ignored == {}", linkId.getValue());
- return false;
- default:
- break;
+ if (validateLinkConstraints(pcelink).equals(ConstraintTypes.HARD_EXCLUDE)) {
+ dropOppositeLink(link);
+ LOG.debug("validateLink: constraints : link is ignored == {}", linkId.getValue());
+ return false;
}
switch (pcelink.getlinkType()) {
case ROADMTOROADM:
allPceLinks.put(linkId, pcelink);
source.addOutgoingLink(pcelink);
LOG.debug("validateLink: {}-LINK added to allPceLinks {}",
- pcelink.getlinkType(), pcelink.toString());
+ pcelink.getlinkType(), pcelink);
break;
case ADDLINK:
pcelink.setClient(source.getRdmSrgClient(pcelink.getSourceTP().toString()));
addLinks.add(pcelink);
- LOG.debug("validateLink: ADD-LINK saved {}", pcelink.toString());
+ LOG.debug("validateLink: ADD-LINK saved {}", pcelink);
break;
case DROPLINK:
pcelink.setClient(dest.getRdmSrgClient(pcelink.getDestTP().toString()));
dropLinks.add(pcelink);
- LOG.debug("validateLink: DROP-LINK saved {}", pcelink.toString());
+ LOG.debug("validateLink: DROP-LINK saved {}", pcelink);
break;
case XPONDERINPUT:
// store separately all SRG links directly
// connected to A/Z
if (!dest.checkTP(pcelink.getDestTP().toString())) {
LOG.debug(
- "validateLink: XPONDER-INPUT is rejected as NW port is busy - {} ", pcelink.toString());
+ "validateLink: XPONDER-INPUT is rejected as NW port is busy - {} ", pcelink);
return false;
}
if (dest.getXpdrClient(pcelink.getDestTP().toString()) != null) {
}
allPceLinks.put(linkId, pcelink);
source.addOutgoingLink(pcelink);
- LOG.debug("validateLink: XPONDER-INPUT link added to allPceLinks {}", pcelink.toString());
+ LOG.debug("validateLink: XPONDER-INPUT link added to allPceLinks {}", pcelink);
break;
// does it mean XPONDER==>>SRG ?
case XPONDEROUTPUT:
// connected to A/Z
if (!source.checkTP(pcelink.getSourceTP().toString())) {
LOG.debug(
- "validateLink: XPONDER-OUTPUT is rejected as NW port is busy - {} ", pcelink.toString());
+ "validateLink: XPONDER-OUTPUT is rejected as NW port is busy - {} ", pcelink);
return false;
}
if (source.getXpdrClient(pcelink.getSourceTP().toString()) != null) {
}
allPceLinks.put(linkId, pcelink);
source.addOutgoingLink(pcelink);
- LOG.debug("validateLink: XPONDER-OUTPUT link added to allPceLinks {}", pcelink.toString());
+ LOG.debug("validateLink: XPONDER-OUTPUT link added to allPceLinks {}", pcelink);
break;
default:
- LOG.warn("validateLink: link type is not supported {}", pcelink.toString());
+ LOG.warn("validateLink: link type is not supported {}", pcelink);
}
return true;
}
LinkId linkId = pceOtnLink.getLinkId();
- switch (validateLinkConstraints(pceOtnLink)) {
- case HARD_EXCLUDE:
- dropOppositeLink(link);
- LOG.debug("validateLink: constraints : link is ignored == {}", linkId.getValue());
- return false;
- default:
- break;
+ if (validateLinkConstraints(pceOtnLink).equals(ConstraintTypes.HARD_EXCLUDE)) {
+ dropOppositeLink(link);
+ LOG.debug("validateLink: constraints : link is ignored == {}", linkId.getValue());
+ return false;
}
+
switch (pceOtnLink.getlinkType()) {
case OTNLINK:
if (dest.getXpdrClient(pceOtnLink.getDestTP().toString()) != null) {
allPceLinks.put(linkId, pceOtnLink);
source.addOutgoingLink(pceOtnLink);
- LOG.info("validateLink: OTN-LINK added to allPceLinks {}", pceOtnLink.toString());
+ LOG.info("validateLink: OTN-LINK added to allPceLinks {}", pceOtnLink);
break;
default:
- LOG.warn("validateLink: link type is not supported {}", pceOtnLink.toString());
+ LOG.warn("validateLink: link type is not supported {}", pceOtnLink);
}
return true;
}
private boolean validateNode(Node node) {
- LOG.debug("validateNode: node {} ", node.toString());
+ LOG.debug("validateNode: node {} ", node);
// PceNode will be used in Graph algorithm
Node1 node1 = node.augmentation(Node1.class);
return false;
}
- switch (validateNodeConstraints(pceNode)) {
- case HARD_EXCLUDE:
- return false;
-
- default:
- break;
+ if (validateNodeConstraints(pceNode).equals(ConstraintTypes.HARD_EXCLUDE)) {
+ return false;
}
if ((pceNode.getSupNetworkNodeId().equals(anodeId) && (this.aendPceNode == null))
- && (endPceNode(nodeType, pceNode.getNodeId(), pceNode))) {
+ && (Boolean.TRUE.equals(endPceNode(nodeType, pceNode.getNodeId(), pceNode)))) {
this.aendPceNode = pceNode;
}
if ((pceNode.getSupNetworkNodeId().equals(znodeId) && (this.zendPceNode == null))
- && (endPceNode(nodeType, pceNode.getNodeId(), pceNode))) {
+ && (Boolean.TRUE.equals(endPceNode(nodeType, pceNode.getNodeId(), pceNode)))) {
this.zendPceNode = pceNode;
}
LOG.warn(" validateOtnNode: Node {} is ignored", node.getNodeId().getValue());
return false;
}
- switch (validateNodeConstraints(pceOtnNode)) {
- case HARD_EXCLUDE:
- return false;
- default:
- break;
+ if (validateNodeConstraints(pceOtnNode).equals(ConstraintTypes.HARD_EXCLUDE)) {
+ return false;
}
if (pceOtnNode.getNodeId().getValue().equals(anodeId) && this.aendPceNode == null) {
this.aendPceNode = pceOtnNode;
return ConstraintTypes.NONE;
}
- List<Long> constraints = new ArrayList<Long>(pceHardConstraints.getExcludeSRLG());
+ List<Long> constraints = new ArrayList<>(pceHardConstraints.getExcludeSRLG());
constraints.retainAll(link.getsrlgList());
if (!constraints.isEmpty()) {
LOG.info("validateLinkConstraints: {}", link.getLinkId().getValue());
private void dropOppositeLink(Link link) {
LinkId opplink = MapUtils.extractOppositeLink(link);
- PceLink oppPceLink = allPceLinks.get(opplink);
- if (oppPceLink != null) {
- allPceLinks.remove(oppPceLink);
+ if (allPceLinks.containsKey(opplink)) {
+ allPceLinks.remove(opplink);
} else {
linksToExclude.add(opplink);
}
while (nodes.hasNext()) {
PceNode pcenode = nodes.next().getValue();
List<PceLink> links = pcenode.getOutgoingLinks();
- LOG.info("In printNodes in node {} : outgoing links {} ", pcenode.getNodeId().getValue(), links.toString());
+ LOG.info("In printNodes in node {} : outgoing links {} ", pcenode.getNodeId().getValue(), links);
}
}
}
package org.opendaylight.transportpce.pce.networkanalyzer;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
import java.util.List;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class PceLink {
+public class PceLink implements Serializable {
+ private static final long serialVersionUID = 1L;
/* Logging. */
private static final Logger LOG = LoggerFactory.getLogger(PceLink.class);
///////////////////////// LINKS ////////////////////
private final OpenroadmLinkType linkType;
private final NodeId sourceId;
private final NodeId destId;
- private final Object sourceTP;
- private final Object destTP;
+ private transient Object sourceTP;
+ private transient Object destTP;
private final String sourceNetworkSupNodeId;
private final String destNetworkSupNodeId;
private final String sourceCLLI;
private final Long usedBandwidth;
private final List<Long> srlgList;
private final double osnr;
- private final Span omsAttributesSpan;
+ private final transient Span omsAttributesSpan;
private static final double CELERITY = 2.99792458 * 1e5; //meter per ms
private static final double NOISE_MASK_A = 0.571429;
private static final double NOISE_MASK_B = 39.285714;
this.availableBandwidth = 0L;
this.usedBandwidth = 0L;
}
- LOG.debug("PceLink: created PceLink {}", toString());
+ LOG.debug("PceLink: created PceLink {}", linkId);
}
//Retrieve the opposite link
}
public Long getUsedBandwidth() {
- return availableBandwidth;
+ return usedBandwidth;
}
public String getsourceNetworkSupNodeId() {
return false;
}
- long neededBW = 0L;
+ long neededBW;
OtnLinkType neededType = null;
switch (serviceType) {
return true;
}
+ @Override
public String toString() {
return "PceLink type=" + linkType + " ID=" + linkId.getValue() + " latency=" + latency;
}
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ out.defaultWriteObject();
+ out.writeObject(this.sourceTP);
+ out.writeObject(this.destTP);
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException,ClassNotFoundException {
+ in.defaultReadObject();
+ this.sourceTP = in.readObject();
+ this.destTP = in.readObject();
+ }
}
import org.slf4j.LoggerFactory;
public class PceOpticalNode implements PceNode {
- private static final Logger LOG = LoggerFactory.getLogger(PceCalculation.class);
+ private static final Logger LOG = LoggerFactory.getLogger(PceOpticalNode.class);
private boolean valid = true;
private final String pceNodeType;
// wavelength calculation per node type
- private List<Long> availableWLindex = new ArrayList<Long>();
- private Map<String, OpenroadmTpType> availableSrgPp = new TreeMap<String, OpenroadmTpType>();
- private Map<String, OpenroadmTpType> availableSrgCp = new TreeMap<String, OpenroadmTpType>();
- private List<String> usedXpndrNWTps = new ArrayList<String>();
- private List<PceLink> outgoingLinks = new ArrayList<PceLink>();
- private Map<String, String> clientPerNwTp = new HashMap<String, String>();
+ private List<Long> availableWLindex = new ArrayList<>();
+ private Map<String, OpenroadmTpType> availableSrgPp = new TreeMap<>();
+ private Map<String, OpenroadmTpType> availableSrgCp = new TreeMap<>();
+ private List<String> usedXpndrNWTps = new ArrayList<>();
+ private List<PceLink> outgoingLinks = new ArrayList<>();
+ private Map<String, String> clientPerNwTp = new HashMap<>();
public PceOpticalNode(Node node, OpenroadmNodeType nodeType, NodeId nodeId, ServiceFormat serviceFormat,
String pceNodeType) {
List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
.node.TerminationPoint> allTps = nodeTp.getTerminationPoint();
if (allTps == null) {
- LOG.error("initSrgTpList: ROADM TerminationPoint list is empty for node {}", this.toString());
+ LOG.error("initSrgTpList: ROADM TerminationPoint list is empty for node {}", this);
this.valid = false;
return;
}
.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130
.TerminationPoint1.class);
OpenroadmTpType type = cntp1.getTpType();
- LOG.info("type = {} for tp {}", type.getName(), tp.toString());
+ LOG.info("type = {} for tp {}", type.getName(), tp);
switch (type) {
case SRGTXRXCP:
}
}
if (this.availableSrgPp.isEmpty() && this.availableSrgCp.isEmpty()) {
- LOG.error("initSrgTpList: ROADM SRG TerminationPoint list is empty for node {}", this.toString());
+ LOG.error("initSrgTpList: ROADM SRG TerminationPoint list is empty for node {}", this);
this.valid = false;
return;
}
LOG.info("initSrgTpList: availableSrgPp size = {} && availableSrgCp size = {} in {}",
- this.availableSrgPp.size(), this.availableSrgCp.size(), this.toString());
- return;
+ this.availableSrgPp.size(), this.availableSrgCp.size(), this);
}
public void initWLlist() {
node1.getSrgAttributes().getAvailableWavelengths();
if (srgAvailableWL == null) {
this.valid = false;
- LOG.error("initWLlist: SRG AvailableWavelengths is empty for node {}", this.toString());
+ LOG.error("initWLlist: SRG AvailableWavelengths is empty for node {}", this);
return;
}
for (org.opendaylight.yang.gen.v1.http.org.openroadm.srg.rev181130.srg.node.attributes
.AvailableWavelengths awl : srgAvailableWL) {
this.availableWLindex.add(awl.getIndex().toJava());
- LOG.debug("initWLlist: SRG next = {} in {}", awl.getIndex(), this.toString());
+ LOG.debug("initWLlist: SRG next = {} in {}", awl.getIndex(), this);
}
break;
case DEGREE :
.AvailableWavelengths> degAvailableWL = node1.getDegreeAttributes().getAvailableWavelengths();
if (degAvailableWL == null) {
this.valid = false;
- LOG.error("initWLlist: DEG AvailableWavelengths is empty for node {}", this.toString());
+ LOG.error("initWLlist: DEG AvailableWavelengths is empty for node {}", this);
return;
}
for (org.opendaylight.yang.gen.v1.http.org.openroadm.degree.rev181130.degree.node.attributes
.AvailableWavelengths awl : degAvailableWL) {
this.availableWLindex.add(awl.getIndex().toJava());
- LOG.debug("initWLlist: DEGREE next = {} in {}", awl.getIndex(), this.toString());
+ LOG.debug("initWLlist: DEGREE next = {} in {}", awl.getIndex(), this);
}
break;
case XPONDER :
}
break;
default:
- LOG.error("initWLlist: unsupported node type {} in node {}", this.nodeType, this.toString());
+ LOG.error("initWLlist: unsupported node type {} in node {}", this.nodeType, this);
break;
}
- if (this.availableWLindex.size() == 0) {
- LOG.debug("initWLlist: There are no available wavelengths in node {}", this.toString());
+ if (this.availableWLindex.isEmpty()) {
+ LOG.debug("initWLlist: There are no available wavelengths in node {}", this);
this.valid = false;
}
- LOG.debug("initWLlist: availableWLindex size = {} in {}", this.availableWLindex.size(), this.toString());
- return;
+ LOG.debug("initWLlist: availableWLindex size = {} in {}", this.availableWLindex.size(), this);
}
public void initXndrTps() {
.node.TerminationPoint> allTps = nodeTp.getTerminationPoint();
if (allTps == null) {
this.valid = false;
- LOG.error("initXndrTps: XPONDER TerminationPoint list is empty for node {}", this.toString());
+ LOG.error("initXndrTps: XPONDER TerminationPoint list is empty for node {}", this);
return;
}
this.valid = false;
this.clientPerNwTp.put(tp.getTpId().getValue(), client);
this.valid = true;
} else {
- LOG.error("initXndrTps: XPONDER {} NW TP doesn't have defined Client {}", this.toString(),
- tp.getTpId().getValue());
+ LOG.error("initXndrTps: XPONDER {} NW TP doesn't have defined Client {}",
+ this, tp.getTpId().getValue());
}
} else if (ServiceFormat.OTU.equals(this.serviceFormat)) {
LOG.info("Infrastructure OTU4 connection");
}
}
if (!isValid()) {
- LOG.error("initXndrTps: XPONDER doesn't have available wavelengths for node {}", this.toString());
- return;
+ LOG.error("initXndrTps: XPONDER doesn't have available wavelengths for node {}", this);
}
}
.sorted(new SortPortsByName())
.findFirst();
if (!client.isPresent()) {
- LOG.error("getRdmSrgClient: ROADM {} doesn't have PP Client for CP {}", this.toString(), tp);
+ LOG.error("getRdmSrgClient: ROADM {} doesn't have PP Client for CP {}", this, tp);
return null;
}
LOG.info("getRdmSrgClient: client PP {} for CP {} found !", client, tp);
return client.get();
} else {
- LOG.error("getRdmSrgClient: SRG TerminationPoint PP list is not available for node {}", this.toString());
+ LOG.error("getRdmSrgClient: SRG TerminationPoint PP list is not available for node {}", this);
return null;
}
}
return nodeId;
}
+ @Override
public String toString() {
return "PceNode type=" + nodeType + " ID=" + nodeId.getValue() + " CLLI=" + this.getSupClliNodeId();
}
@Override
public Map<String, List<Uint16>> getAvailableTribPorts() {
- // TODO Auto-generated method stub
return null;
}
@Override
public Map<String, List<Uint16>> getAvailableTribSlots() {
- // TODO Auto-generated method stub
return null;
}
}
public class PceOtnNode implements PceNode {
/* Logging. */
- private static final Logger LOG = LoggerFactory.getLogger(PceCalculation.class);
+ private static final Logger LOG = LoggerFactory.getLogger(PceOtnNode.class);
////////////////////////// OTN NODES ///////////////////////////
/*
* For This Class the node passed shall be at the otn-openroadm Layer
private final String pceNodeType;
private final String otnServiceType;
- private Map<String, List<Uint16>> tpAvailableTribPort = new TreeMap<String, List<Uint16>>();
- private Map<String, List<Uint16>> tpAvailableTribSlot = new TreeMap<String, List<Uint16>>();
- private Map<String, OpenroadmTpType> availableXponderTp = new TreeMap<String, OpenroadmTpType>();
- private List<String> usedXpdrNWTps = new ArrayList<String>();
+ private Map<String, List<Uint16>> tpAvailableTribPort = new TreeMap<>();
+ private Map<String, List<Uint16>> tpAvailableTribSlot = new TreeMap<>();
+ private Map<String, OpenroadmTpType> availableXponderTp = new TreeMap<>();
+ private List<String> usedXpdrNWTps = new ArrayList<>();
private List<TpId> availableXpdrNWTps;
private List<TpId> usableXpdrNWTps;
- private List<String> usedXpdrClientTps = new ArrayList<String>();
+ private List<String> usedXpdrClientTps = new ArrayList<>();
private List<TpId> availableXpdrClientTps;
private List<TpId> usableXpdrClientTps;
- private List<PceLink> outgoingLinks = new ArrayList<PceLink>();
- private Map<String, String> clientPerNwTp = new HashMap<String, String>();
+ private List<PceLink> outgoingLinks = new ArrayList<>();
+ private Map<String, String> clientPerNwTp = new HashMap<>();
public PceOtnNode(Node node, OpenroadmNodeType nodeType, NodeId nodeId, String pceNodeType, String serviceType) {
this.node = node;
this.otnServiceType = serviceType;
this.tpAvailableTribSlot.clear();
this.usedXpdrNWTps.clear();
- this.availableXpdrNWTps = new ArrayList<TpId>();
- this.usableXpdrNWTps = new ArrayList<TpId>();
+ this.availableXpdrNWTps = new ArrayList<>();
+ this.usableXpdrNWTps = new ArrayList<>();
this.usedXpdrClientTps.clear();
- this.availableXpdrClientTps = new ArrayList<TpId>();
- this.usableXpdrClientTps = new ArrayList<TpId>();
+ this.availableXpdrClientTps = new ArrayList<>();
+ this.usableXpdrClientTps = new ArrayList<>();
this.tpAvailableTribPort.clear();
checkAvailableTribPort();
this.tpAvailableTribSlot.clear();
.node.TerminationPoint> allTps = nodeTp.getTerminationPoint();
this.valid = false;
if (allTps == null) {
- LOG.error("PceOtnNode: initXndrTps: XPONDER TerminationPoint list is empty for node {}", this.toString());
+ LOG.error("PceOtnNode: initXndrTps: XPONDER TerminationPoint list is empty for node {}", this);
return;
}
&& ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool() != null
&& ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().get(0).getOdtuType()
.equals(ODTU4TsAllocated.class)
- && ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().get(0).getTpnPool().size() >= 1
- && ontTp1.getXpdrTpPortConnectionAttributes().getTsPool().size() >= tsNb) {
+ && ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().get(0).getTpnPool().isEmpty()
+ && (ontTp1.getXpdrTpPortConnectionAttributes().getTsPool().size() >= tsNb)) {
return true;
- } else {
- return false;
}
+ return false;
}
private boolean checkClientTp(TerminationPoint1 ontTp1) {
Long neededBW) {
if (this.nodeType != OpenroadmNodeType.TPDR) {
return true;
- } else {
- org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1 node1 =
- node.augmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class);
- SwitchingPools sp = node1.getSwitchingPools();
- List<OduSwitchingPools> osp = new ArrayList<OduSwitchingPools>();
- osp = sp.getOduSwitchingPools();
- for (OduSwitchingPools ospx : osp) {
- List<NonBlockingList> nbl = ospx.getNonBlockingList();
- for (NonBlockingList nbll : nbl) {
- if (nbll.getAvailableInterconnectBandwidth().toJava() >= neededBW) {
- List<TpId> tplist = new ArrayList<TpId>(nbll.getTpList());
- if ((tplist.contains(tp1.getTpId())) & (tplist.contains(tp2.getTpId()))) {
- LOG.debug("validateSwitchingPoolBandwidth: couple of tp {} x {} valid for crossconnection",
- tp1.getTpId().toString(), tp2.getTpId().toString());
- return true;
- }
- }
+ }
+ org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1 node1 =
+ node.augmentation(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class);
+ SwitchingPools sp = node1.getSwitchingPools();
+ List<OduSwitchingPools> osp = sp.getOduSwitchingPools();
+ for (OduSwitchingPools ospx : osp) {
+ List<NonBlockingList> nbl = ospx.getNonBlockingList();
+ for (NonBlockingList nbll : nbl) {
+ if (nbll.getAvailableInterconnectBandwidth().toJava() >= neededBW && nbll.getTpList() != null
+ && nbll.getTpList().contains(tp1.getTpId()) && nbll.getTpList().contains(tp2.getTpId())) {
+ LOG.debug("validateSwitchingPoolBandwidth: couple of tp {} x {} valid for crossconnection",
+ tp1.getTpId(), tp2.getTpId());
+ return true;
}
}
- LOG.debug("validateSwitchingPoolBandwidth: No valid Switching pool for crossconnecting tp {} and {}",
- tp1.getTpId().toString(), tp2.getTpId().toString());
- return false;
}
+
+ LOG.debug("validateSwitchingPoolBandwidth: No valid Switching pool for crossconnecting tp {} and {}",
+ tp1.getTpId(), tp2.getTpId());
+ return false;
+
}
public void validateIntermediateSwitch() {
} else {
LOG.info("validateIntermediateSwitch: Switch usable for transit == {}", nodeId.getValue());
}
- return;
}
public void checkAvailableTribPort() {
return valid;
}
+ @Override
public void addOutgoingLink(PceLink outLink) {
this.outgoingLinks.add(outLink);
}
+ @Override
public List<PceLink> getOutgoingLinks() {
return outgoingLinks;
}
return this.clientPerNwTp.get(tp);
}
+ @Override
public String toString() {
return "PceNode type=" + nodeType + " ID=" + nodeId.getValue() + " CLLI=" + this.getSupClliNodeId();
}
public void printLinksOfNode() {
- LOG.info(" outgoing links of node {} : {} ", nodeId.getValue(), this.getOutgoingLinks().toString());
+ LOG.info(" outgoing links of node {} : {} ", nodeId.getValue(), this.getOutgoingLinks());
}
@Override
@Override
public String getRdmSrgClient(String tp) {
- // TODO Auto-generated method stub
return null;
}
@Override
public boolean checkTP(String tp) {
- // TODO Auto-generated method stub
return false;
}
@Override
public boolean checkWL(long index) {
- // TODO Auto-generated method stub
return false;
}
}
import org.opendaylight.transportpce.pce.PceComplianceCheckResult;
import org.opendaylight.transportpce.pce.PceSendingPceRPCs;
import org.opendaylight.transportpce.pce.gnpy.GnpyResult;
-
import org.opendaylight.yang.gen.v1.gnpy.path.rev200202.result.Response;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.CancelResourceReserveInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.CancelResourceReserveOutput;
RpcStatusEx.Pending, "Service compliant, submitting cancelResourceReserve Request ...", null);
PceSendingPceRPCs sendingPCE = new PceSendingPceRPCs();
sendingPCE.cancelResourceReserve();
- if (sendingPCE.getSuccess()) {
+ if (Boolean.TRUE.equals(sendingPCE.getSuccess())) {
message = "ResourceReserve cancelled !";
} else {
message = "Cancelling ResourceReserve failed !";
}
- LOG.info(message);
+ LOG.info("in PathComputationServiceImpl : {}",message);
sendNotifications(ServicePathNotificationTypes.CancelResourceReserve, input.getServiceName(),
RpcStatusEx.Successful, "cancel Resource Reserve successful!", null);
ConfigurationResponseCommonBuilder configurationResponseCommon =
}
output.setGnpyResponse(listResponse);
- if (!(sendingPCE.getSuccess()) || (path == null)) {
+ if (Boolean.FALSE.equals(sendingPCE.getSuccess()) || (path == null)) {
configurationResponseCommon.setAckFinalIndicator("Yes")
.setRequestId(input.getServiceHandlerHeader().getRequestId()).setResponseCode(responseCode)
.setResponseMessage(message);
feasible = true;
}
}
- GnpyResponse gnpypResp = new GnpyResponseBuilder().setPathDir(pathDir).setResponseType(respType)
- .setFeasibility(feasible).build();
- return gnpypResp;
+ return new GnpyResponseBuilder().setPathDir(pathDir).setResponseType(respType).setFeasibility(feasible).build();
}
}
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-aggregator</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<name>transportpce</name>
<packaging>pom</packaging>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-renderer</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
</dependency>
</dependencies>
-<!-- checkstyle and spotbugds enforced by odlparent since Magnesium -->
- <properties>
- <!-- odlparent.checkstyle.enforce>false</odlparent.checkstyle.enforce -->
- <odlparent.spotbugs.enforce>false</odlparent.spotbugs.enforce>
- </properties>
-
</project>
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
+
public final class ModelMappingUtils {
private static final Logger LOG = LoggerFactory.getLogger(ModelMappingUtils.class);
public static ServicePowerSetupInput createServicePowerSetupInput(List<Nodes> olmList,
ServiceImplementationRequestInput input) {
ServicePowerSetupInputBuilder olmSetupBldr = new ServicePowerSetupInputBuilder()
- .setNodes(olmList)
- .setWaveNumber(input.getPathDescription().getAToZDirection().getAToZWavelengthNumber());
+ .setNodes(olmList);
+ if (input != null && input.getPathDescription() != null
+ && input.getPathDescription().getAToZDirection() != null) {
+ olmSetupBldr.setWaveNumber(
+ input.getPathDescription().getAToZDirection().getAToZWavelengthNumber());
+ }
return olmSetupBldr.build();
}
}
int[] pos = findTheLongestSubstring(nodeID, tpID);
- //TODO: do not rely on nodeId to be integer
- int id = Integer.parseInt(sortId);
- treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID));
- } else if (resourceType.equals("Link")) {
+ if (pos != null) {
+ //TODO: do not rely on nodeId to be integer
+ int id = Integer.parseInt(sortId);
+ treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID));
+ }
+ } else if ("Link".equals(resourceType)) {
LOG.info("The type is link");
} else {
LOG.info("The type is not indentified: {}", resourceType);
}
} catch (IllegalArgumentException | SecurityException e) {
- // TODO Auto-generated catch block
LOG.error("Dont find the getResource method", e);
}
}
- String desID = null;
- String srcID = null;
- for (NodeIdPair values : treeMap.values()) {
- if (srcID == null) {
- srcID = values.getTpID();
- } else if (desID == null) {
- desID = values.getTpID();
- NodesBuilder nb = new NodesBuilder()
- .withKey(new NodesKey(values.getNodeID()))
- .setDestTp(desID)
- .setSrcTp(srcID);
- list.add(nb.build());
-
- NodesBuilder olmNb = new NodesBuilder()
- .setNodeId(values.getNodeID())
- .setDestTp(desID)
- .setSrcTp(srcID);
- olmList.add(olmNb.build());
- srcID = null;
- desID = null;
- } else {
- LOG.warn("both, the source and destination id are null!");
- }
- }
+ populateNodeLists(treeMap, list, olmList);
return new NodeLists(olmList, list);
}
}
int[] pos = findTheLongestSubstring(nodeID, tpID);
- //TODO: do not rely on nodeId to be integer
- int id = Integer.parseInt(sortId);
- treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID));
- } else if (resourceType.equals("Link")) {
+ if (pos != null) {
+ //TODO: do not rely on nodeId to be integer
+ int id = Integer.parseInt(sortId);
+ treeMap.put(id, new NodeIdPair(nodeID.substring(0, pos[0] - 1), tpID));
+ }
+ } else if ("Link".equals(resourceType)) {
LOG.info("The type is link");
} else {
LOG.info("The type is not indentified: {}", resourceType);
}
}
+ populateNodeLists(treeMap, list, olmList);
+ return new NodeLists(olmList, list);
+ }
+
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = {"NP_LOAD_OF_KNOWN_NULL_VALUE","RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE"},
+ justification = "loop when value is not always null - "
+ + "TODO: check if something exists in Java lib")
+ private static void populateNodeLists(Map<Integer, NodeIdPair> treeMap,
+ List<Nodes> list, List<Nodes> olmList) {
String desID = null;
String srcID = null;
for (NodeIdPair values : treeMap.values()) {
LOG.warn("both, the source and destination id are null!");
}
}
- return new NodeLists(olmList, list);
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "PZLA_PREFER_ZERO_LENGTH_ARRAYS",
+ justification = "not relevant to return and zero length array"
+ + " as we need real pos")
public static int[] findTheLongestSubstring(String s1, String s2) {
if ((s1 == null) || (s2 == null)) {
return null;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.Mapping;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.PowerDBm;
-
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.Interface1;
import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.Interface1Builder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev161014.ethernet.container.EthernetBuilder;
-
import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.EthernetCsmacd;
import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.InterfaceType;
import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.OpenROADMOpticalMultiplex;
public class OpenRoadmInterface121 {
+ private static final String MAPPING_MSG_ERROR =
+ "Unable to get mapping from PortMapping for node % and logical connection port %s";
private final PortMapping portMapping;
private final OpenRoadmInterfaces openRoadmInterfaces;
- private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterfaceFactory.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterface121.class);
public OpenRoadmInterface121(PortMapping portMapping, OpenRoadmInterfaces openRoadmInterfaces) {
this.portMapping = portMapping;
throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
if (portMap == null) {
- throw new OpenRoadmInterfaceException(String.format(
- "Unable to get mapping from PortMapping for node % and logical connection port %s",
- nodeId, logicalConnPoint));
+ throw new OpenRoadmInterfaceException(String.format(MAPPING_MSG_ERROR, nodeId, logicalConnPoint));
}
// Ethernet interface specific data
throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
if (portMap == null) {
- throw new OpenRoadmInterfaceException(String.format(
- "Unable to get mapping from PortMapping for node % and logical connection port %s",
- nodeId, logicalConnPoint));
+ throw new OpenRoadmInterfaceException(String.format(MAPPING_MSG_ERROR, nodeId, logicalConnPoint));
}
// Create generic interface
InterfaceBuilder otuInterfaceBldr = createGenericInterfaceBuilder(portMap, OtnOtu.class, logicalConnPoint
throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
if (portMap == null) {
- throw new OpenRoadmInterfaceException(String.format(
- "Unable to get mapping from PortMapping for node % and logical connection port %s",
- nodeId, logicalConnPoint));
+ throw new OpenRoadmInterfaceException(String.format(MAPPING_MSG_ERROR, nodeId, logicalConnPoint));
}
InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint
+ "-ODU");
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import java.util.Optional;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
OduBuilder oduIfBuilder = new OduBuilder()
.setRate(ODU4.class)
.setMonitoringMode(OduAttributes.MonitoringMode.Terminated);
- if (!nodeId.toLowerCase().contains("eci")) {
+ if (!nodeId.toLowerCase(Locale.getDefault()).contains("eci")) {
oduIfBuilder.setTxDapi("");
oduIfBuilder.setTxSapi("");
}
public class OpenRoadmInterfaceFactory {
+ private static final String OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG =
+ "OTN funtions are not supported by Openroadm models 1.2.1";
private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterfaceFactory.class);
private final MappingUtils mappingUtils;
private final OpenRoadmInterface121 openRoadmInterface121;
}
}
- public boolean isUsedbyXc(String nodeId, String interfaceName, String xc,
+ public boolean isUsedByXc(String nodeId, String interfaceName, String xc,
DeviceTransactionManager deviceTransactionManager) {
switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
}
}
- public boolean isUsedbyOtnXc(String nodeId, String interfaceName, String xc,
+ public boolean isUsedByOtnXc(String nodeId, String interfaceName, String xc,
DeviceTransactionManager deviceTransactionManager) {
switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
- LOG.error("OTN funtions are not supported by Openroadm models 1.2.1");
+ LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG);
return false;
case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
return openRoadmInterface221.isUsedByOtnXc(nodeId, interfaceName, xc, deviceTransactionManager);
String logicalConnPoint) throws OpenRoadmInterfaceException {
switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
- LOG.error("OTN funtions are not supported by Openroadm models 1.2.1");
+ LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG);
return null;
case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
return openRoadmOtnInterface.createOpenRoadmEth1GInterface(nodeId, logicalConnPoint);
String logicalConnPoint) throws OpenRoadmInterfaceException {
switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
- LOG.error("OTN funtions are not supported by Openroadm models 1.2.1");
+ LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG);
return null;
case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
return openRoadmOtnInterface.createOpenRoadmEth10GInterface(nodeId, logicalConnPoint);
throws OpenRoadmInterfaceException {
switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
- LOG.error("OTN funtions are not supported by Openroadm models 1.2.1");
+ LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG);
return null;
case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
return openRoadmOtnInterface.createOpenRoadmOdu0Interface(
throws OpenRoadmInterfaceException {
switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
- LOG.error("OTN funtions are not supported by Openroadm models 1.2.1");
+ LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG);
return null;
case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
return openRoadmOtnInterface.createOpenRoadmOdu2Interface(
throws OpenRoadmInterfaceException {
switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
- LOG.error("OTN funtions are not supported by Openroadm models 1.2.1");
+ LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG);
return null;
case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
return openRoadmOtnInterface.createOpenRoadmOdu2eInterface(
private final PortMapping portMapping;
private final OpenRoadmInterfaces openRoadmInterfaces;
- private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmOtnInterface221.class);
+ private static final Logger LOG = LoggerFactory
+ .getLogger(OpenRoadmOtnInterface221.class);
- public OpenRoadmOtnInterface221(PortMapping portMapping, OpenRoadmInterfaces openRoadmInterfaces) {
+ public OpenRoadmOtnInterface221(PortMapping portMapping,
+ OpenRoadmInterfaces openRoadmInterfaces) {
this.portMapping = portMapping;
this.openRoadmInterfaces = openRoadmInterfaces;
}
- public String createOpenRoadmEth1GInterface(String nodeId, String logicalConnPoint)
- throws OpenRoadmInterfaceException {
+ public String createOpenRoadmEth1GInterface(String nodeId,
+ String logicalConnPoint) throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
if (portMap == null) {
- throw new OpenRoadmInterfaceException(String.format(
- "Unable to get mapping from PortMapping for node % and logical connection port %s",
- nodeId, logicalConnPoint));
+ throwException(nodeId, logicalConnPoint);
}
// Ethernet interface specific data
EthernetBuilder ethIfBuilder = new EthernetBuilder();
- //ethIfBuilder.setAutoNegotiation(EthAttributes.AutoNegotiation.Disabled);
ethIfBuilder.setSpeed(1000L);
- InterfaceBuilder ethInterfaceBldr =
- createGenericInterfaceBuilder(portMap, EthernetCsmacd.class, logicalConnPoint + "-ETHERNET1G");
+ InterfaceBuilder ethInterfaceBldr = createGenericInterfaceBuilder(
+ portMap, EthernetCsmacd.class,
+ logicalConnPoint + "-ETHERNET1G");
// Create Interface1 type object required for adding as augmentation
- Interface1Builder ethIf1Builder = new Interface1Builder();
- ethInterfaceBldr.addAugmentation(Interface1.class, ethIf1Builder.setEthernet(ethIfBuilder.build()).build());
+ Interface1Builder ethIf1Builder = new Interface1Builder();
+ ethInterfaceBldr.addAugmentation(Interface1.class,
+ ethIf1Builder.setEthernet(ethIfBuilder.build()).build());
// Post interface on the device
this.openRoadmInterfaces.postOTNInterface(nodeId, ethInterfaceBldr);
// Post the equipment-state change on the device circuit-pack
- this.openRoadmInterfaces.postOTNEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
- this.portMapping.updateMapping(nodeId,portMap);
+ this.openRoadmInterfaces.postOTNEquipmentState(nodeId,
+ portMap.getSupportingCircuitPackName(), true);
+ this.portMapping.updateMapping(nodeId, portMap);
String ethernetInterfaceName = ethInterfaceBldr.getName();
return ethernetInterfaceName;
}
+ private void throwException(String nodeId, String logicalConnPoint)
+ throws OpenRoadmInterfaceException {
+ throw new OpenRoadmInterfaceException(String.format(
+ "Unable to get mapping from PortMapping for node % and logical connection port %s",
+ nodeId, logicalConnPoint));
+ }
+
private InterfaceBuilder createGenericInterfaceBuilder(Mapping portMap,
Class<? extends InterfaceType> type, String key) {
InterfaceBuilder interfaceBuilder = new InterfaceBuilder()
- //.setDescription(" TBD ")
- //.setCircuitId(" TBD ")
- .setSupportingCircuitPackName(portMap.getSupportingCircuitPackName())
- .setSupportingPort(portMap.getSupportingPort())
- .setAdministrativeState(AdminStates.InService)
- //TODO get rid of unchecked cast warning
- .setType(
- (Class<? extends InterfaceType>)
- type
- )
- .setName(key)
- .withKey(new InterfaceKey(key));
+ // .setDescription(" TBD ")
+ // .setCircuitId(" TBD ")
+ .setSupportingCircuitPackName(
+ portMap.getSupportingCircuitPackName())
+ .setSupportingPort(portMap.getSupportingPort())
+ .setAdministrativeState(AdminStates.InService)
+ // TODO get rid of unchecked cast warning
+ .setType(type).setName(key).withKey(new InterfaceKey(key));
return interfaceBuilder;
}
- public String createOpenRoadmEth10GInterface(String nodeId, String logicalConnPoint)
- throws OpenRoadmInterfaceException {
+ public String createOpenRoadmEth10GInterface(String nodeId,
+ String logicalConnPoint) throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
if (portMap == null) {
- throw new OpenRoadmInterfaceException(
- String.format(
- "Unable to get mapping from PortMapping for node % and logical connection port %s",
- nodeId, logicalConnPoint));
+ throwException(nodeId, logicalConnPoint);
}
// Ethernet interface specific data
EthernetBuilder ethIfBuilder = new EthernetBuilder()
- //.setAutoNegotiation(EthAttributes.AutoNegotiation.Disabled)
- .setSpeed(10000L);
+ // .setAutoNegotiation(EthAttributes.AutoNegotiation.Disabled)
+ .setSpeed(10000L);
// Create Interface1 type object required for adding as augmentation
- Interface1Builder ethIf1Builder = new Interface1Builder();
- InterfaceBuilder ethInterfaceBldr =
- createGenericInterfaceBuilder(portMap, EthernetCsmacd.class, logicalConnPoint + "-ETHERNET10G")
- .addAugmentation(Interface1.class, ethIf1Builder.setEthernet(ethIfBuilder.build()).build());
+ Interface1Builder ethIf1Builder = new Interface1Builder();
+ InterfaceBuilder ethInterfaceBldr = createGenericInterfaceBuilder(portMap, EthernetCsmacd.class,
+ logicalConnPoint + "-ETHERNET10G").addAugmentation(Interface1.class,
+ ethIf1Builder.setEthernet(ethIfBuilder.build()).build());
// Post interface on the device
this.openRoadmInterfaces.postOTNInterface(nodeId, ethInterfaceBldr);
// Post the equipment-state change on the device circuit-pack
- this.openRoadmInterfaces.postOTNEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
- this.portMapping.updateMapping(nodeId,portMap);
+ this.openRoadmInterfaces.postOTNEquipmentState(nodeId,
+ portMap.getSupportingCircuitPackName(), true);
+ this.portMapping.updateMapping(nodeId, portMap);
String ethernetInterfaceName = ethInterfaceBldr.getName();
return ethernetInterfaceName;
}
-
- public String createOpenRoadmOdu2eInterface(
- String nodeId, String logicalConnPoint, String serviceName,
- String payLoad, boolean isNetworkPort, int tribPortNumber, int tribSlotIndex)
+ public String createOpenRoadmOdu2eInterface(String nodeId,
+ String logicalConnPoint, String serviceName, String payLoad,
+ boolean isNetworkPort, int tribPortNumber, int tribSlotIndex)
throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
if (portMap == null) {
- throw new OpenRoadmInterfaceException(String.format(
- "Unable to get mapping from PortMapping for node % and logical connection port %s",
- nodeId, logicalConnPoint));
+ throwException(nodeId, logicalConnPoint);
}
String supportingInterface = null;
if (supportingInterface == null) {
throw new OpenRoadmInterfaceException(
- "Interface Creation failed because of missing supported ODU4 on network end or Eth iface on client");
+ "Interface Creation failed because of missing supported "
+ + "ODU4 on network end or Eth iface on client");
}
- InterfaceBuilder oduInterfaceBldr =
- createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint + "-ODU2e-" + serviceName)
- .setSupportingInterface(supportingInterface);
+ InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(
+ portMap, OtnOdu.class,
+ logicalConnPoint + "-ODU2e-" + serviceName)
+ .setSupportingInterface(supportingInterface);
// ODU interface specific data
- OduBuilder oduIfBuilder = new OduBuilder()
- .setRate(ODU2e.class)
- .setOduFunction(ODUTTPCTP.class)
- .setMonitoringMode(OduAttributes.MonitoringMode.Terminated);
- LOG.debug("Inside the ODU2e creation {} {} {}",isNetworkPort,tribPortNumber,tribSlotIndex);
+ OduBuilder oduIfBuilder = new OduBuilder().setRate(ODU2e.class)
+ .setOduFunction(ODUTTPCTP.class)
+ .setMonitoringMode(OduAttributes.MonitoringMode.Terminated);
+ LOG.debug("Inside the ODU2e creation {} {} {}", isNetworkPort,
+ tribPortNumber, tribSlotIndex);
if (isNetworkPort) {
List<Uint16> tribSlots = new ArrayList<>();
Uint16 newIdx = Uint16.valueOf(tribSlotIndex);
tribSlots.add(newIdx);
- IntStream.range(tribSlotIndex, tribSlotIndex + 8).forEach(
- nbr -> tribSlots.add(Uint16.valueOf(nbr))
- );
+ IntStream.range(tribSlotIndex, tribSlotIndex + 8)
+ .forEach(nbr -> tribSlots.add(Uint16.valueOf(nbr)));
ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
- .setTribPortNumber(tribPortNumber)
- .setTribSlots(tribSlots);
+ .setTribPortNumber(tribPortNumber).setTribSlots(tribSlots);
oduIfBuilder.setOduFunction(ODUCTP.class)
.setMonitoringMode(OduAttributes.MonitoringMode.Monitored)
.setParentOduAllocation(parentOduAllocationBuilder.build());
- }
- else {
+ } else {
// Set Opu attributes
OpuBuilder opuBldr = new OpuBuilder()
.setPayloadType(new PayloadTypeDef(payLoad))
}
// Create Interface1 type object required for adding as augmentation
// TODO look at imports of different versions of class
- org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder oduIf1Builder =
- new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
+ org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder
+ oduIf1Builder = new
+ org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
oduInterfaceBldr.addAugmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class,
oduIf1Builder.setOdu(oduIfBuilder.build()).build());
return oduInterfaceBldr.getName();
}
- public String createOpenRoadmOdu0Interface(String nodeId, String logicalConnPoint,
- String serviceName, String payLoad, boolean isNetworkPort, int tribPortNumber, int tribSlot)
+ public String createOpenRoadmOdu0Interface(String nodeId,
+ String logicalConnPoint, String serviceName, String payLoad,
+ boolean isNetworkPort, int tribPortNumber, int tribSlot)
throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
String supportingInterface = null;
supportingInterface = logicalConnPoint + "-ETHERNET1G";
}
if (portMap == null) {
- throw new OpenRoadmInterfaceException(String.format(
- "Unable to get mapping from PortMapping for node % and logical connection port %s",
- nodeId, logicalConnPoint));
+ throwException(nodeId, logicalConnPoint);
}
- InterfaceBuilder oduInterfaceBldr =
- createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint + "-ODU0-" + serviceName);
+ InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(
+ portMap, OtnOdu.class,
+ logicalConnPoint + "-ODU0-" + serviceName);
oduInterfaceBldr.setSupportingInterface(supportingInterface);
// ODU interface specific data
- OduBuilder oduIfBuilder = new OduBuilder()
- .setRate(ODU0.class)
- .setOduFunction(ODUTTPCTP.class)
- .setMonitoringMode(OduAttributes.MonitoringMode.Terminated);
+ OduBuilder oduIfBuilder = new OduBuilder().setRate(ODU0.class)
+ .setOduFunction(ODUTTPCTP.class)
+ .setMonitoringMode(OduAttributes.MonitoringMode.Terminated);
if (isNetworkPort) {
LOG.debug("Network port is true");
List<Uint16> tribSlots = new ArrayList<>();
- tribSlots.add(Uint16.valueOf(tribSlot)); //add trib slots
+ // add trib slots
+ tribSlots.add(Uint16.valueOf(tribSlot));
ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
- //set trib port numbers
- .setTribPortNumber(tribPortNumber)
- .setTribSlots(tribSlots);
+ // set trib port numbers
+ .setTribPortNumber(tribPortNumber).setTribSlots(tribSlots);
oduIfBuilder.setOduFunction(ODUCTP.class)
.setMonitoringMode(OduAttributes.MonitoringMode.Monitored)
.setParentOduAllocation(parentOduAllocationBuilder.build());
oduIfBuilder.getParentOduAllocation().getTribSlots(),
oduIfBuilder.getRate(),
oduIfBuilder.getParentOduAllocation().getTribPortNumber());
- }
- else {
+ } else {
LOG.debug("Current port is a client port");
OpuBuilder opuBldr = new OpuBuilder()
.setPayloadType(new PayloadTypeDef(payLoad))
}
// Create Interface1 type object required for adding as augmentation
// TODO look at imports of different versions of class
- org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder oduIf1Builder =
- new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
+ org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder
+ oduIf1Builder = new
+ org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
oduInterfaceBldr.addAugmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class,
oduIf1Builder.setOdu(oduIfBuilder.build()).build());
return oduInterfaceBldr.getName();
}
-
- public String createOpenRoadmOdu2Interface(
- String nodeId, String logicalConnPoint, String serviceName,
- String payLoad, boolean isNetworkPort, int tribPortNumber, int tribSlotIndex)
+ public String createOpenRoadmOdu2Interface(String nodeId,
+ String logicalConnPoint, String serviceName, String payLoad,
+ boolean isNetworkPort, int tribPortNumber, int tribSlotIndex)
throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
String supportingInterface = null;
- if (isNetworkPort) {
- supportingInterface = portMap.getSupportingOdu4();
+ if (portMap != null) {
+ if (isNetworkPort) {
+ supportingInterface = portMap.getSupportingOdu4();
+ } else {
+ supportingInterface = portMap.getSupportingEthernet();
+ }
} else {
- supportingInterface = portMap.getSupportingEthernet();
- }
- if (portMap == null) {
- throw new OpenRoadmInterfaceException(
- String.format("Unable to get mapping from PortMapping for node % and logical connection port %s",
- nodeId, logicalConnPoint));
+ throwException(nodeId, logicalConnPoint);
}
- InterfaceBuilder oduInterfaceBldr =
- createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint + "-ODU2-" + serviceName)
- .setSupportingInterface(supportingInterface);
+ InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(
+ portMap, OtnOdu.class,
+ logicalConnPoint + "-ODU2-" + serviceName)
+ .setSupportingInterface(supportingInterface);
- OduBuilder oduIfBuilder = new OduBuilder()
- .setRate(ODU2.class)
- .setOduFunction(ODUTTPCTP.class)
- .setMonitoringMode(OduAttributes.MonitoringMode.Terminated);
+ OduBuilder oduIfBuilder = new OduBuilder().setRate(ODU2.class)
+ .setOduFunction(ODUTTPCTP.class)
+ .setMonitoringMode(OduAttributes.MonitoringMode.Terminated);
if (isNetworkPort) {
List<Uint16> tribSlots = new ArrayList<>();
- IntStream.range(tribSlotIndex, tribSlotIndex + 8).forEach(
- nbr -> tribSlots.add(Uint16.valueOf(nbr))
- );
+ IntStream.range(tribSlotIndex, tribSlotIndex + 8)
+ .forEach(nbr -> tribSlots.add(Uint16.valueOf(nbr)));
ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
- //set trib port numbers
- .setTribPortNumber(tribPortNumber)
- .setTribSlots(tribSlots);
+ // set trib port numbers
+ .setTribPortNumber(tribPortNumber).setTribSlots(tribSlots);
oduIfBuilder.setOduFunction(ODUCTP.class)
.setMonitoringMode(OduAttributes.MonitoringMode.Monitored)
.setParentOduAllocation(parentOduAllocationBuilder.build());
- }
- else {
+ } else {
// Set Opu attributes
OpuBuilder opuBldr = new OpuBuilder()
.setPayloadType(new PayloadTypeDef(payLoad))
// TODO look at imports of different versions of class
// Create Interface1 type object required for adding as augmentation
// TODO look at imports of different versions of class
- org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder oduIf1Builder =
- new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
+ org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder
+ oduIf1Builder = new
+ org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
oduInterfaceBldr.addAugmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class,
oduIf1Builder.setOdu(oduIfBuilder.build()).build());
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.FluentFuture;
+
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
+
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
+
public class DeviceRendererServiceImpl implements DeviceRendererService {
+ private static final String ODU4 = "-ODU4";
private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererServiceImpl.class);
private final DataBroker dataBroker;
private final DeviceTransactionManager deviceTransactionManager;
private ConcurrentLinkedQueue<String> processErrorMessage(String message, ForkJoinPool forkJoinPool,
ConcurrentLinkedQueue<String> messages) {
- LOG.warn(message);
+ LOG.warn("Received error message {}", message);
messages.add(message);
forkJoinPool.shutdown();
return messages;
}
// if the node is currently mounted then proceed.
if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
- if (destTp.contains(StringConstants.NETWORK_TOKEN)
- || srcTp.contains(StringConstants.CLIENT_TOKEN)
- || srcTp.contains(StringConstants.NETWORK_TOKEN)
- || destTp.contains(StringConstants.CLIENT_TOKEN)) {
- if (destTp.contains(StringConstants.NETWORK_TOKEN)) {
- try {
- if (this.openRoadmInterfaces.getInterface(nodeId, destTp + "-ODU").isPresent()) {
- interfacesToDelete.add(destTp + "-ODU");
- }
- if (this.openRoadmInterfaces.getInterface(nodeId, destTp + "-ODU4").isPresent()) {
- interfacesToDelete.add(destTp + "-ODU4");
- }
- }
- catch (OpenRoadmInterfaceException e) {
- LOG.error("impossible to get interface {} or {}", destTp + "-ODU", destTp + "-ODU4", e);
- }
- interfacesToDelete.add(destTp + "-OTU");
- interfacesToDelete.add(
- this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(destTp, waveNumber));
- }
- if (srcTp.contains(StringConstants.NETWORK_TOKEN)) {
- interfacesToDelete.add(srcTp + "-ODU");
- interfacesToDelete.add(srcTp + "-OTU");
- interfacesToDelete
- .add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp, waveNumber));
- }
- if (srcTp.contains(StringConstants.CLIENT_TOKEN)) {
- interfacesToDelete.add(srcTp + "-ETHERNET");
- }
- if (destTp.contains(StringConstants.CLIENT_TOKEN)) {
- interfacesToDelete.add(destTp + "-ETHERNET");
- }
- } else {
- String connectionNumber = srcTp + "-" + destTp + "-" + waveNumber;
- List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, false);
- connectionNumber = destTp + "-" + srcTp + "-" + waveNumber;
- if (intToDelete != null) {
- for (String interf : intToDelete) {
- if (!this.openRoadmInterfaceFactory.isUsedbyXc(nodeId, interf, connectionNumber,
- this.deviceTransactionManager)) {
- interfacesToDelete.add(interf);
- }
- }
- }
- }
+ interfacesToDelete.addAll(getInterfaces2delete(nodeId, srcTp, destTp, waveNumber));
} else {
String result = nodeId + " is not mounted on the controller";
results.add(result);
}
}
+ private List<String> getInterfaces2delete(
+ String nodeId, String srcTp, String destTp, Long waveNumber) {
+ List<String> interfacesToDelete = new LinkedList<>();
+ if (destTp.contains(StringConstants.NETWORK_TOKEN)
+ || srcTp.contains(StringConstants.CLIENT_TOKEN)
+ || srcTp.contains(StringConstants.NETWORK_TOKEN)
+ || destTp.contains(StringConstants.CLIENT_TOKEN)) {
+ if (destTp.contains(StringConstants.NETWORK_TOKEN)) {
+ try {
+ if (this.openRoadmInterfaces.getInterface(nodeId, destTp + "-ODU").isPresent()) {
+ interfacesToDelete.add(destTp + "-ODU");
+ }
+ if (this.openRoadmInterfaces.getInterface(nodeId, destTp + ODU4).isPresent()) {
+ interfacesToDelete.add(destTp + ODU4);
+ }
+ }
+ catch (OpenRoadmInterfaceException e) {
+ LOG.error("impossible to get interface {} or {}", destTp + "-ODU", destTp + ODU4, e);
+ }
+ interfacesToDelete.add(destTp + "-OTU");
+ interfacesToDelete.add(
+ this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(destTp, waveNumber));
+ }
+ if (srcTp.contains(StringConstants.NETWORK_TOKEN)) {
+ interfacesToDelete.add(srcTp + "-ODU");
+ interfacesToDelete.add(srcTp + "-OTU");
+ interfacesToDelete
+ .add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp, waveNumber));
+ }
+ if (srcTp.contains(StringConstants.CLIENT_TOKEN)) {
+ interfacesToDelete.add(srcTp + "-ETHERNET");
+ }
+ if (destTp.contains(StringConstants.CLIENT_TOKEN)) {
+ interfacesToDelete.add(destTp + "-ETHERNET");
+ }
+ } else {
+ String connectionNumber = srcTp + "-" + destTp + "-" + waveNumber;
+ List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, false);
+ connectionNumber = destTp + "-" + srcTp + "-" + waveNumber;
+ if (intToDelete != null) {
+ for (String interf : intToDelete) {
+ if (!this.openRoadmInterfaceFactory.isUsedByXc(nodeId, interf, connectionNumber,
+ this.deviceTransactionManager)) {
+ interfacesToDelete.add(interf);
+ }
+ }
+ }
+ }
+ return interfacesToDelete;
+ }
+
@Override
public RendererRollbackOutput rendererRollback(RendererRollbackInput input) {
boolean success = true;
}
} else {
result = input.getNodeId() + " is not mounted on the controller";
- LOG.warn(result);
+ LOG.warn("{} is not mounted on the controller",input.getNodeId());
}
return output.setResult(result).setSuccess(success).build();
}
import org.slf4j.LoggerFactory;
public class OtnDeviceRendererServiceImpl implements OtnDeviceRendererService {
+ private static final String ODU2E = "-ODU2e-";
private static final Logger LOG = LoggerFactory.getLogger(OtnDeviceRendererServiceImpl.class);
private final OpenRoadmInterfaceFactory openRoadmInterfaceFactory;
private final CrossConnect crossConnect;
String connectionNumber = "";
switch (input.getServiceRate()) {
case("10G"):
- connectionNumber = srcTp + "-ODU2e-" + input.getServiceName() + "-x-" + destTp
- + "-ODU2e-" + input.getServiceName();
+ connectionNumber = srcTp + ODU2E + input.getServiceName() + "-x-" + destTp
+ + ODU2E + input.getServiceName();
break;
case("1G"):
connectionNumber = srcTp + "-ODU0-" + input.getServiceName() + "-x-" + destTp
- + "-ODU2e-" + input.getServiceName();
+ + ODU2E + input.getServiceName();
break;
default:
LOG.error("service rate {} not managed yet", input.getServiceRate());
List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, true);
if (intToDelete != null) {
for (String interf : intToDelete) {
- if (!this.openRoadmInterfaceFactory.isUsedbyOtnXc(nodeId, interf, connectionNumber,
+ if (!this.openRoadmInterfaceFactory.isUsedByOtnXc(nodeId, interf, connectionNumber,
this.deviceTransactionManager)) {
interfacesToDelete.add(interf);
if (!getSupportedInterface(nodeId, interf).contains("ODU4")) {
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
public class RendererServiceOperationsImpl implements RendererServiceOperations {
+ private static final String DEVICE_RENDERING_ROLL_BACK_MSG =
+ "Device rendering was not successful! Rendering will be rolled back.";
+ private static final String OLM_ROLL_BACK_MSG =
+ "OLM power setup was not successful! Rendering and OLM will be rolled back.";
+ private static final String RENDERING_DEVICES_A_Z_MSG = "Rendering devices A-Z";
+ private static final String TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG = "Turning down power on A-to-Z path";
private static final Logger LOG = LoggerFactory.getLogger(RendererServiceOperationsImpl.class);
private static final String FAILED = "Failed";
private static final String OPERATION_FAILED = "Operation Failed";
deviceRendering(rollbackProcessor, servicePathInputDataAtoZ, servicePathInputDataZtoA);
if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(),
- RpcStatusEx.Failed, "Device rendering was not successful! Rendering will be rolled back.");
+ RpcStatusEx.Failed, DEVICE_RENDERING_ROLL_BACK_MSG);
return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
}
ServicePowerSetupInput olmPowerSetupInputAtoZ =
if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest, input.getServiceName(),
RpcStatusEx.Failed,
- "OLM power setup was not successful! Rendering and OLM will be rolled back.");
+ OLM_ROLL_BACK_MSG);
return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
}
// run service activation test twice - once on source node and once on
});
}
+ @Override
@SuppressWarnings("checkstyle:IllegalCatch")
public OperationResult reserveResource(PathDescription pathDescription) {
return OperationResult.ok("Resources reserved successfully in network model");
}
+ @Override
@SuppressWarnings("checkstyle:IllegalCatch")
public OperationResult freeResource(PathDescription pathDescription) {
ModelMappingUtils.rendererCreateServiceInputZToA(serviceName, pathDescription);
// OLM turn down power
try {
- LOG.debug("Turning down power on A-to-Z path");
+ LOG.debug(TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG);
sendNotifications(ServicePathNotificationTypes.ServiceDelete,
- input.getServiceName(), RpcStatusEx.Pending, "Turning down power on A-to-Z path");
+ input.getServiceName(), RpcStatusEx.Pending, TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG);
ServicePowerTurndownOutput atozPowerTurndownOutput = olmPowerTurndown(servicePathInputDataAtoZ);
// TODO add some flag rather than string
if (FAILED.equals(atozPowerTurndownOutput.getResult())) {
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
private ServicePowerTurndownOutput olmPowerTurndown(ServicePathInputData servicePathInputData)
throws InterruptedException, ExecutionException, TimeoutException {
- LOG.debug("Turning down power on A-to-Z path");
+ LOG.debug(TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG);
Future<RpcResult<ServicePowerTurndownOutput>> powerTurndownFuture = this.olmService.servicePowerTurndown(
new ServicePowerTurndownInputBuilder(servicePathInputData.getServicePathInput()).build());
return powerTurndownFuture.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS).getResult();
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
private Optional<PathDescription> getPathDescriptionFromDatastore(String serviceName) {
InstanceIdentifier<PathDescription> pathDescriptionIID = InstanceIdentifier.create(ServicePathList.class)
.child(ServicePaths.class, new ServicePathsKey(serviceName)).child(PathDescription.class);
}
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
private List<DeviceRenderingResult> deviceRendering(RollbackProcessor rollbackProcessor,
ServicePathInputData servicePathDataAtoZ, ServicePathInputData servicePathDataZtoA) {
- LOG.info("Rendering devices A-Z");
+ LOG.info(RENDERING_DEVICES_A_Z_MSG);
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
servicePathDataAtoZ.getServicePathInput().getServiceName(), RpcStatusEx.Pending,
- "Rendering devices A-Z");
+ RENDERING_DEVICES_A_Z_MSG);
ListenableFuture<DeviceRenderingResult> atozrenderingFuture =
this.executor.submit(new DeviceRenderingTask(this.deviceRenderer, servicePathDataAtoZ,
ServicePathDirection.A_TO_Z));
LOG.info("Rendering devices Z-A");
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
servicePathDataAtoZ.getServicePathInput().getServiceName(), RpcStatusEx.Pending,
- "Rendering devices A-Z");
+ RENDERING_DEVICES_A_Z_MSG);
ListenableFuture<DeviceRenderingResult> ztoarenderingFuture =
this.executor.submit(new DeviceRenderingTask(this.deviceRenderer, servicePathDataZtoA,
ServicePathDirection.Z_TO_A));
LOG.info("Waiting for A-Z and Z-A device renderers ...");
renderingResults = renderingCombinedFuture.get(Timeouts.RENDERING_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
- LOG.warn("Device rendering was not successful! Rendering will be rolled back.", e);
+ LOG.warn(DEVICE_RENDERING_ROLL_BACK_MSG, e);
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
servicePathDataAtoZ.getServicePathInput().getServiceName(), RpcStatusEx.Pending,
- "Device rendering was not successful! Rendering will be rolled back.");
+ DEVICE_RENDERING_ROLL_BACK_MSG);
//FIXME we can't do rollback here, because we don't have rendering results.
return renderingResults;
}
return renderingResults;
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
private void olmPowerSetup(RollbackProcessor rollbackProcessor, ServicePowerSetupInput powerSetupInputAtoZ,
ServicePowerSetupInput powerSetupInputZtoA) {
LOG.info("Olm power setup A-Z");
LOG.info("Waiting for A-Z and Z-A OLM power setup ...");
olmResults = olmFutures.get(Timeouts.OLM_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
- LOG.warn("OLM power setup was not successful! Rendering and OLM will be rolled back.", e);
+ LOG.warn(OLM_ROLL_BACK_MSG, e);
sendNotifications(ServicePathNotificationTypes.ServiceImplementationRequest,
powerSetupInputAtoZ.getServiceName(), RpcStatusEx.Pending,
- "OLM power setup was not successful! Rendering and OLM will be rolled back.");
+ OLM_ROLL_BACK_MSG);
rollbackProcessor.addTask(new OlmPowerSetupRollbackTask("AtoZOLMTask", true,
this.olmService, powerSetupInputAtoZ));
rollbackProcessor.addTask(new OlmPowerSetupRollbackTask("ZtoAOLMTask", true,
this.olmService, powerSetupInputZtoA));
}
+ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
private boolean isServiceActivated(String nodeId, String tpId) {
LOG.info("Starting service activation test on node {} and tp {}", nodeId, tpId);
for (int i = 0; i < 3; i++) {
package org.opendaylight.transportpce.renderer.provisiondevice.otn;
import java.util.List;
+
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.CircuitPacks;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.OduSwitchingPools;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.odu.switching.pools.non.blocking.list.PortList;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.port.capability.rev181019.port.group.restriction.grp.PortGroupRestriction;
public interface OtnDeviceOperations {
/**
* This method checks if the client port can be used or not.
- *
- * @param nodeID unique identifier of a device
* @param circuitPackName circuit pack name of the client port
* @param portName port name of the client port
* @param capacity rate of the service needed
+ * @param portGroupRestriction TODO
+ *
* @return String which states whether the client port is valid or not
*/
- String validateClientPort(String nodeID, String circuitPackName, String portName, String capacity);
+ String validateClientPort(String circuitPackName, String portName, String capacity,
+ PortGroupRestriction portGroupRestriction);
/**
* This method retrieves the possible network ports.
*</p>
* @param circuitPackName Circuit pack name of the client port
* @param portName port name of the client port
+ * @param oduSwitchingPools TODO
+ * @param circuitPacks TODO
* @return List of all possible network ports
*/
- List<PortList> getPossibleNetworkPorts(String circuitPackName, String portName);
+ List<PortList> getPossibleNetworkPorts(String circuitPackName, String portName,
+ OduSwitchingPools oduSwitchingPools, CircuitPacks circuitPacks);
}
*/
package org.opendaylight.transportpce.renderer.provisiondevice.otn;
+import java.util.ArrayList;
import java.util.List;
+
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.CircuitPacks;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.pack.Ports;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.OduSwitchingPools;
public class OtnDeviceOperationsImpl implements OtnDeviceOperations {
@Override
- public String validateClientPort(String nodeID, String circuitPackName, String portName, String capacity) {
-
- PortGroupRestriction portGroupRestriction = null; //should not be initiated as null
- List<PortBandwidthSharing> portBandwidthSharingList = portGroupRestriction.getPortBandwidthSharing();
- for (PortBandwidthSharing portBandwidthSharing: portBandwidthSharingList) {
- List<PortList> portLists = portBandwidthSharing.getPortList();
- for (PortList portList: portLists) {
- if (portList.getCircuitPackName().equals(circuitPackName) && portList.getPortName().equals(portName)) {
- if (!usageOfOtherPorts(portBandwidthSharing,
- getConfigID(portBandwidthSharing, circuitPackName, portName))) {
- return "valid port";
- }
- else {
- return "not a valid port";
+ public String validateClientPort(String circuitPackName, String portName, String capacity,
+ PortGroupRestriction portGroupRestriction) {
+
+ List<PortBandwidthSharing> portBandwidthSharingList = portGroupRestriction
+ .getPortBandwidthSharing();
+ if (portGroupRestriction.getPortBandwidthSharing() != null) {
+ for (PortBandwidthSharing portBandwidthSharing : portBandwidthSharingList) {
+ List<PortList> portLists = portBandwidthSharing.getPortList();
+ for (PortList portList : portLists) {
+ if (portList.getCircuitPackName().equals(circuitPackName)
+ && portList.getPortName().equals(portName)) {
+ if (!usageOfOtherPorts(portBandwidthSharing,
+ getConfigID(portBandwidthSharing,
+ circuitPackName, portName))) {
+ return "valid port";
+ } else {
+ return "not a valid port";
+ }
}
}
}
}
- return "not valid circuitPackName or portName"; // if the client port is not found at all throw exception
+ // if the client port is not found at all throw exception
+ return "not valid circuitPackName or portName";
}
private Integer getConfigID(PortBandwidthSharing portBandwidthSharing, String circuitPackName, String portName) {
}
}
}
- return null; // throw exception if not able to get config id
+ // throw exception if not able to get config id
+ return null;
}
@Override
public List<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org
.openroadm.device.container.org.openroadm.device.odu.switching.pools.non.blocking.list.PortList>
- getPossibleNetworkPorts(String circuitPackName, String portName) {
+ getPossibleNetworkPorts(String circuitPackName, String portName, OduSwitchingPools oduSwitchingPools,
+ CircuitPacks circuitPacks) {
List<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org
.openroadm.device.container.org.openroadm.device.odu.switching
- .pools.non.blocking.list.PortList> networkPortList = null;
-
- //need a method to get swtiching pool object from device
-
- OduSwitchingPools oduSwitchingPools = null; // should not be initiated as null
+ .pools.non.blocking.list.PortList> networkPortList = new ArrayList<>();
List<NonBlockingList> nonBlockingLists = oduSwitchingPools.getNonBlockingList();
if (port.getCircuitPackName().equals(circuitPackName) && port.getPortName().equals(portName)) {
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device
.container.org.openroadm.device.odu.switching.pools.non.blocking.list
- .PortList networkPort = checkNetworkPorts(nonBlockingList.getPortList());
+ .PortList networkPort = checkNetworkPorts(nonBlockingList.getPortList(), circuitPacks);
if (networkPort != null) {
networkPortList.add(networkPort);
}
private org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device
.container.org.openroadm.device.odu.switching.pools.non.blocking.list.PortList
checkNetworkPorts(List<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org
- .openroadm.device.container.org.openroadm.device.odu.switching.pools.non.blocking.list.PortList> portList) {
- CircuitPacks circuitPacks = null;
-
+ .openroadm.device.container.org.openroadm.device.odu.switching.pools.non.blocking.list.PortList> portList,
+ CircuitPacks circuitPacks) {
List<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.packs
.CircuitPacks> circuitPackList = circuitPacks.getCircuitPacks();
return searchNetworkPort(port, circuitPack);
}
}
- return null; // throw exception if no available network ports
+ // TODO: throw exception if no available network ports
+ return null;
}
private org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container
org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.packs.CircuitPacks circuitPack) {
if (port.getCircuitPackName().equals(circuitPack.getCircuitPackName())) {
for (Ports prt : circuitPack.getPorts()) {
- if (port.getPortName().equals(prt.getPortName()) && prt.getPortQual().equals("xpdr-network")) {
+ if (prt.getPortQual() != null
+ && port.getPortName().equals(prt.getPortName())
+ && "xpdr-network".equals(prt.getPortQual().getName())) {
return port;
}
}
}
- return null; // throw exception
+ // TODO: throw exception
+ return null;
}
import java.util.List;
import java.util.concurrent.Callable;
+
import org.opendaylight.transportpce.renderer.ServicePathInputData;
import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRenderingResult;
public DeviceRenderingResult call() throws Exception {
ServicePathOutput output = this.deviceRenderer.setupServicePath(this.servicePathInputData.getServicePathInput(),
this.direction);
- if (! output.isSuccess()) {
+ if (!output.isSuccess()) {
LOG.warn("Device rendering not successfully finished.");
return DeviceRenderingResult.failed("Operation Failed");
}
package org.opendaylight.transportpce.renderer.rpcs;
import com.google.common.util.concurrent.ListenableFuture;
+
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
import org.opendaylight.transportpce.renderer.provisiondevice.OtnDeviceRendererService;
*/
@Override
public ListenableFuture<RpcResult<ServicePathOutput>> servicePath(ServicePathInput input) {
- if (input.getOperation().getIntValue() == 1) {
- LOG.info("Create operation request received");
- return RpcResultBuilder.success(this.deviceRenderer.setupServicePath(input, null)).buildFuture();
- } else if (input.getOperation().getIntValue() == 2) {
- LOG.info("Delete operation request received");
- return RpcResultBuilder.success(this.deviceRenderer.deleteServicePath(input)).buildFuture();
+ if (input.getOperation() != null) {
+ if (input.getOperation().getIntValue() == 1) {
+ LOG.info("Create operation request received");
+ return RpcResultBuilder.success(
+ this.deviceRenderer.setupServicePath(input, null))
+ .buildFuture();
+ } else if (input.getOperation().getIntValue() == 2) {
+ LOG.info("Delete operation request received");
+ return RpcResultBuilder
+ .success(this.deviceRenderer.deleteServicePath(input))
+ .buildFuture();
+ }
}
return RpcResultBuilder.success(new ServicePathOutputBuilder().setResult("Invalid operation")).buildFuture();
}
@Override
public ListenableFuture<RpcResult<OtnServicePathOutput>> otnServicePath(OtnServicePathInput input) {
- if (input.getOperation().getIntValue() == 1) {
- LOG.info("Create operation request received");
- return RpcResultBuilder.success(this.otnDeviceRendererService.setupOtnServicePath(input)).buildFuture();
- } else if (input.getOperation().getIntValue() == 2) {
- LOG.info("Delete operation request received");
- return RpcResultBuilder.success(this.otnDeviceRendererService.deleteOtnServicePath(input)).buildFuture();
+ if (input.getOperation() != null) {
+ if (input.getOperation().getIntValue() == 1) {
+ LOG.info("Create operation request received");
+ return RpcResultBuilder.success(this.otnDeviceRendererService
+ .setupOtnServicePath(input)).buildFuture();
+ } else if (input.getOperation().getIntValue() == 2) {
+ LOG.info("Delete operation request received");
+ return RpcResultBuilder.success(this.otnDeviceRendererService
+ .deleteOtnServicePath(input)).buildFuture();
+ }
}
return RpcResultBuilder.success(new OtnServicePathOutputBuilder().setResult("Invalid operation")).buildFuture();
}
try {
output = this.rendererServiceOperations.serviceDelete(input).get();
} catch (InterruptedException | ExecutionException e) {
- LOG.error("RPC service delete failed !");
+ LOG.error("RPC service delete failed !", e);
}
return ModelMappingUtils.createServiceDeleteRpcResponse(output);
}
try {
output = this.rendererServiceOperations.serviceImplementation(input).get();
} catch (InterruptedException | ExecutionException e) {
- LOG.error("RPC service implementation failed !");
+ LOG.error("RPC service implementation failed !", e);
}
return ModelMappingUtils.createServiceImplementationRpcResponse(output);
}
package org.opendaylight.transportpce.renderer.stub;
import java.util.Optional;
+
import javax.annotation.Nonnull;
+
import org.opendaylight.mdsal.binding.api.BindingService;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.MountPoint;
import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class MountPointStub implements MountPoint {
+public class MountPointStub implements MountPoint {
private DataBroker dataBroker;
this.dataBroker = dataBroker;
}
- public void setRpcConsumerRegistry(RpcConsumerRegistry rpcConsumerRegistry) {
+ public void setRpcConsumerRegistry(
+ RpcConsumerRegistry rpcConsumerRegistry) {
this.rpcConsumerRegistry = rpcConsumerRegistry;
}
@SuppressWarnings("unchecked")
public <T extends BindingService> Optional<T> getService(Class<T> service) {
if (service.isInstance(dataBroker)) {
- return Optional.ofNullable((T)dataBroker);
+ return Optional.ofNullable((T) dataBroker);
}
if (service.isInstance(rpcConsumerRegistry)) {
- return Optional.ofNullable((T)rpcConsumerRegistry);
+ return Optional.ofNullable((T) rpcConsumerRegistry);
}
return Optional.empty();
}
@Nonnull
@Override
public InstanceIdentifier<?> getIdentifier() {
- return null;
+ throw new UnsupportedOperationException();
}
}
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-servicehandler</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-tapi</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencyManagement>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>transportpce-tapimodels</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
</project>
<groupId>org.opendaylight.transportpce</groupId>
<artifactId>test-common</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>