- private String getGnpyResponse(List<Elements> elementsList, List<Connections> connectionsList,
- List<PathRequest> pathRequestList, List<Synchronization> synchronizationList) throws Exception {
- GnpyApi gnpyApi = new GnpyApiBuilder()
- .setTopologyFile(
- new TopologyFileBuilder().setElements(elementsList).setConnections(connectionsList).build())
- .setServiceFile(new ServiceFileBuilder().setPathRequest(pathRequestList).build()).build();
- InstanceIdentifier<GnpyApi> idGnpyApi = InstanceIdentifier.builder(GnpyApi.class).build();
- String gnpyJson;
- ServiceDataStoreOperationsImpl sd = new ServiceDataStoreOperationsImpl(networkTransaction);
- gnpyJson = sd.createJsonStringFromDataObject(idGnpyApi, gnpyApi);
- LOG.debug("GNPy Id: {} / json created : {}", idGnpyApi, gnpyJson);
- ConnectToGnpyServer connect = new ConnectToGnpyServer();
- String gnpyJsonModified = gnpyJson.replace("gnpy-eqpt-config:", "")
- .replace("gnpy-path-computation-simplified:", "").replace("gnpy-network-topology:", "");
- String gnpyResponse = connect.gnpyCnx(gnpyJsonModified);
- return gnpyResponse;
+ private void callGnpyToComputeNewPath(GnpyUtilitiesImpl gnpy) throws GnpyException {
+
+ //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(pceHardConstraints);
+ if (gnpyPathAsHC == null) {
+ LOG.info("In pceSendingPceRPC: GNPy failed to find another path");
+ this.success = false;
+ this.message = "No path available by PCE and GNPy ";
+ this.responseCode = ResponseCodes.RESPONSE_FAILED;
+ gnpyAtoZ = gnpy.getGnpyAtoZ();
+ gnpyZtoA = gnpy.getGnpyZtoA();
+ 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();
+ PceConstraintsCalc constraintsGnpy = new PceConstraintsCalc(inputFromGnpy, networkTransaction);
+ PceConstraints gnpyHardConstraints = constraintsGnpy.getPceHardConstraints();
+ PceConstraints gnpySoftConstraints = constraintsGnpy.getPceSoftConstraints();
+ pathComputationWithConstraints(gnpyHardConstraints, gnpySoftConstraints);
+ AToZDirection atoz = rc.getAtoZDirection();
+ ZToADirection ztoa = rc.getZtoADirection();
+ if (gnpyToCheckFeasiblity(atoz, ztoa,gnpy)) {
+ LOG.info("In pceSendingPceRPC: the new path computed by GNPy is valid");
+ this.success = true;
+ this.message = "Path is calculated by GNPy";
+ this.responseCode = ResponseCodes.RESPONSE_OK;
+ setPathDescription(new PathDescriptionBuilder().setAToZDirection(atoz).setZToADirection(ztoa));
+ } else {
+ LOG.info("In pceSendingPceRPC: the new path computed by GNPy is not valid");
+ this.success = false;
+ this.message = "No path available";
+ this.responseCode = ResponseCodes.RESPONSE_FAILED;
+ setPathDescription(new PathDescriptionBuilder().setAToZDirection(null).setZToADirection(null));
+ }