+ PathComputationRequestInput pathComputationInput = new PathComputationRequestInputBuilder()
+ .setServiceName("no_name")
+ .setServiceHandlerHeader(new ServiceHandlerHeaderBuilder().setRequestId("none").build())
+ .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
+ .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
+ .setHardConstraints(input.getHardConstraints())
+ .setPceRoutingMetric(input.getPceRoutingMetric())
+ .setResourceReserve(false)
+ .setSoftConstraints(input.getSoftConstraints())
+ .setRoutingMetric(input.getRoutingMetric())
+ .build();
+ PceSendingPceRPCs sendingPCE = new PceSendingPceRPCs(pathComputationInput, networkTransactionService,
+ gnpyConsumer, portMapping, input.getEndpoints());
+ sendingPCE.pathComputation();
+ String message = sendingPCE.getMessage();
+ String responseCode = sendingPCE.getResponseCode();
+ LOG.info("PCE response: {} {}", message, responseCode);
+ return output.setConfigurationResponseCommon(
+ configurationResponseCommon
+ .setAckFinalIndicator("Yes")
+ .setResponseCode(responseCode)
+ .setResponseMessage(message)
+ .build())
+ .build();
+ });
+ }
+
+ public GnpyResponse generateGnpyResponse(Response responseGnpy, String pathDir) {
+ if (responseGnpy == null) {
+ return new GnpyResponseBuilder()
+ .setPathDir(pathDir)
+ .setResponseType(null)
+ .setFeasibility(true)
+ .build();
+ }
+ if (responseGnpy.getResponseType()
+ instanceof org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.response.response.type.NoPathCase) {
+ LOG.info("GNPy : path is not feasible");
+ org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.response.response.type.NoPathCase
+ noPathGnpy =
+ (org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.response.response.type.NoPathCase)
+ responseGnpy.getResponseType();
+ return new GnpyResponseBuilder()
+ .setPathDir(pathDir)
+ .setResponseType(
+ new NoPathCaseBuilder()
+ .setNoPath(noPathGnpy.getNoPath())
+ .build())
+ .setFeasibility(false)
+ .build();
+ }
+ if (responseGnpy.getResponseType()
+ instanceof org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.response.response.type.PathCase) {
+ LOG.info("GNPy : path is feasible");
+ org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.response.response.type.PathCase
+ pathCase =
+ (org.opendaylight.yang.gen.v1.gnpy.path.rev220615.result.response.response.type.PathCase)
+ responseGnpy.getResponseType();
+ List<org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.properties.path.properties.PathMetric>
+ pathMetricList =
+ new ArrayList<>(pathCase.getPathProperties().getPathMetric().values());
+ List<PathMetric> gnpyPathMetricList = new ArrayList<>();
+ for (org.opendaylight.yang.gen.v1.gnpy.path.rev220615.generic.path.properties.path.properties.PathMetric
+ pathMetricGnpy : pathMetricList) {
+ gnpyPathMetricList.add(
+ new PathMetricBuilder()
+ .setMetricType(pathMetricGnpy.getMetricType())
+ .setAccumulativeValue(pathMetricGnpy.getAccumulativeValue())
+ .build());
+ }
+ return new GnpyResponseBuilder()
+ .setPathDir(pathDir)
+ .setResponseType(
+ new PathCaseBuilder()
+ .setPathProperties(
+ new PathPropertiesBuilder()
+ .setPathMetric(gnpyPathMetricList.stream()
+ .collect(Collectors.toMap(PathMetric::key, pathMetric -> pathMetric)))
+ .build())
+ .build())
+ .setFeasibility(true)
+ .build();