package org.opendaylight.transportpce.pce;
-import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices;
import org.opendaylight.transportpce.common.ResponseCodes;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
import org.opendaylight.transportpce.pce.constraints.PceConstraints;
import org.opendaylight.transportpce.pce.constraints.PceConstraintsCalc;
-import org.opendaylight.transportpce.pce.gnpy.ConnectToGnpyServer;
import org.opendaylight.transportpce.pce.gnpy.GnpyException;
import org.opendaylight.transportpce.pce.gnpy.GnpyResult;
import org.opendaylight.transportpce.pce.gnpy.GnpyUtilitiesImpl;
+import org.opendaylight.transportpce.pce.gnpy.consumer.GnpyConsumer;
import org.opendaylight.transportpce.pce.graph.PceGraph;
import org.opendaylight.transportpce.pce.networkanalyzer.PceCalculation;
import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.service.path.rpc.result.PathDescriptionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.AToZDirection;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.ZToADirection;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.RoutingConstraintsSp.PceMetric;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.routing.constraints.sp.HardConstraints;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.PathComputationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.service.path.rpc.result.PathDescriptionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.AToZDirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.path.description.ZToADirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev220118.routing.constraints.sp.HardConstraints;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.PceMetric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private Boolean success;
private String message;
private String responseCode;
- private BindingDOMCodecServices bindingDOMCodecServices;
+ private final GnpyConsumer gnpyConsumer;
+ private PortMapping portMapping;
- public PceSendingPceRPCs() {
+ public PceSendingPceRPCs(GnpyConsumer gnpyConsumer) {
setPathDescription(null);
this.input = null;
this.networkTransaction = null;
+ this.gnpyConsumer = gnpyConsumer;
}
public PceSendingPceRPCs(PathComputationRequestInput input,
- NetworkTransactionService networkTransaction, BindingDOMCodecServices bindingDOMCodecServices) {
+ NetworkTransactionService networkTransaction, GnpyConsumer gnpyConsumer, PortMapping portMapping) {
+ this.gnpyConsumer = gnpyConsumer;
setPathDescription(null);
// TODO compliance check to check that input is not empty
this.input = input;
this.networkTransaction = networkTransaction;
- this.bindingDOMCodecServices = bindingDOMCodecServices;
+ this.portMapping = portMapping;
}
public void cancelResourceReserve() {
public void pathComputationWithConstraints(PceConstraints hardConstraints, PceConstraints softConstraints) {
PceCalculation nwAnalizer =
- new PceCalculation(input, networkTransaction, hardConstraints, softConstraints, rc);
+ new PceCalculation(input, networkTransaction, hardConstraints, softConstraints, rc, portMapping);
nwAnalizer.retrievePceNetwork();
rc = nwAnalizer.getReturnStructure();
String serviceType = nwAnalizer.getServiceType();
return;
}
LOG.info("PceGraph ...");
- PceGraph graph = new PceGraph(nwAnalizer.getaendPceNode(),
- nwAnalizer.getzendPceNode(), nwAnalizer.getAllPceNodes(),
- hardConstraints, softConstraints, rc, serviceType);
+ PceGraph graph = new PceGraph(nwAnalizer.getaendPceNode(), nwAnalizer.getzendPceNode(),
+ nwAnalizer.getAllPceNodes(), hardConstraints, softConstraints, rc, serviceType);
graph.calcPath();
rc = graph.getReturnStructure();
if (!rc.getStatus()) {
//Connect to Gnpy to check path feasibility and recompute another path in case of path non-feasibility
try {
- ConnectToGnpyServer connectToGnpy = new ConnectToGnpyServer();
- if (connectToGnpy.isGnpyURLExist()) {
+ if (gnpyConsumer.isAvailable()) {
GnpyUtilitiesImpl gnpy = new GnpyUtilitiesImpl(networkTransaction, input,
- bindingDOMCodecServices);
+ gnpyConsumer);
if (rc.getStatus() && gnpyToCheckFeasiblity(atoz,ztoa,gnpy)) {
setPathDescription(new PathDescriptionBuilder().setAToZDirection(atoz).setZToADirection(ztoa));
return;
LOG.info("In pceSendingPceRPC: GNPy succeed to find another path");
// Compute the path
PathComputationRequestInput inputFromGnpy = new PathComputationRequestInputBuilder()
- .setServiceName(input.getServiceName()).setHardConstraints(gnpyPathAsHC)
- .setSoftConstraints(input.getSoftConstraints()).setPceMetric(PceMetric.HopCount)
- .setServiceAEnd(input.getServiceAEnd()).setServiceZEnd(input.getServiceZEnd()).build();
+ .setServiceName(input.getServiceName())
+ .setHardConstraints(gnpyPathAsHC)
+ .setSoftConstraints(input.getSoftConstraints())
+ .setPceRoutingMetric(PceMetric.HopCount)
+ .setServiceAEnd(input.getServiceAEnd())
+ .setServiceZEnd(input.getServiceZEnd())
+ .build();
PceConstraintsCalc constraintsGnpy = new PceConstraintsCalc(inputFromGnpy, networkTransaction);
PceConstraints gnpyHardConstraints = constraintsGnpy.getPceHardConstraints();
PceConstraints gnpySoftConstraints = constraintsGnpy.getPceSoftConstraints();