X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=servicehandler%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fservicehandler%2FModelMappingUtils.java;h=7ef1bab194177f298809ca0f4e12f9983232c7fc;hb=c6b93e8d8dd5a5597ca891140212229d99431614;hp=11be1f1b5b31102d00a5bf9541feacf4f2670ead;hpb=1b8941461b6f81f6f7b018f6fc6907d1c7d1292d;p=transportpce.git diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java index 11be1f1b5..7ef1bab19 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java @@ -7,17 +7,18 @@ */ package org.opendaylight.transportpce.servicehandler; +import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.PathComputationRequestOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.path.computation.request.input.ServiceAEnd; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.path.computation.request.input.ServiceAEndBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.path.computation.request.input.ServiceZEnd; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.path.computation.request.input.ServiceZEndBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220118.service.path.rpc.result.PathDescription; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.computation.request.input.ServiceAEnd; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.computation.request.input.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.computation.request.input.ServiceZEnd; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.computation.request.input.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.service.path.rpc.result.PathDescription; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestInput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestInputBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ServiceEndpoint; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommonBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.response.parameters.ResponseParametersBuilder; @@ -89,6 +90,33 @@ import org.slf4j.LoggerFactory; public final class ModelMappingUtils { private static final Logger LOG = LoggerFactory.getLogger(ModelMappingUtils.class); + private static final ImmutableMap ODU_RATE_MAP = + ImmutableMap.builder() + .put("ODU0", ODU0.VALUE) + .put("ODU1", ODU1.VALUE) + .put("ODU2", ODU2.VALUE) + .put("ODU2e", ODU2e.VALUE) + .put("ODU3", ODU3.VALUE) + .put("ODU4", ODU4.VALUE) + .put("ODUCn", ODUCn.VALUE) + .put("ODUflexCbr", ODUflexCbr.VALUE) + .put("ODUflexFlexe", ODUflexFlexe.VALUE) + .put("ODUflexGfp", ODUflexGfp.VALUE) + .put("ODUflexImp", ODUflexImp.VALUE) + .build(); + + private static final ImmutableMap OTU_RATE_MAP = + ImmutableMap.builder() + .put("OTU0", OTU0.VALUE) + .put("OTU1", OTU1.VALUE) + .put("OTU2", OTU2.VALUE) + .put("OTU2e", OTU2e.VALUE) + .put("OTU3", OTU3.VALUE) + .put("OTU4", OTU4.VALUE) + .put("OTUCn", OTUCn.VALUE) + .put("OTUflex", OTUflex.VALUE) + .build(); + private ModelMappingUtils() { } @@ -157,74 +185,20 @@ public final class ModelMappingUtils { .build(); } - private static Class getOduServiceRate( - Class - oduServiceRate) { - if (oduServiceRate == null) { + private static OduRateIdentity getOduServiceRate(OduRateIdentity oduServiceRate) { + if (oduServiceRate == null || !ODU_RATE_MAP.containsKey(oduServiceRate.toString())) { + LOG.error("ODU rate {} not recognized", oduServiceRate); return null; } - String oduRate = oduServiceRate.getSimpleName(); - LOG.info("ODU rate = {}", oduRate); - //TODO a Map would probably be more indicated here - switch (oduRate) { - case "ODU0": - return ODU0.class; - case "ODU1": - return ODU1.class; - case "ODU2": - return ODU2.class; - case "ODU2e": - return ODU2e.class; - case "ODU3": - return ODU3.class; - case "ODU4": - return ODU4.class; - case "ODUCn": - return ODUCn.class; - case "ODUflexCbr": - return ODUflexCbr.class; - case "ODUflexFlexe": - return ODUflexFlexe.class; - case "ODUflexGfp": - return ODUflexGfp.class; - case "ODUflexImp": - return ODUflexImp.class; - default: - LOG.error("OTU rate {} not recognized", oduRate); - } - return null; + return ODU_RATE_MAP.get(oduServiceRate.toString()); } - private static Class getOtuServiceRate( - Class - otuServiceRate) { - if (otuServiceRate == null) { + private static OtuRateIdentity getOtuServiceRate(OtuRateIdentity otuServiceRate) { + if (otuServiceRate == null || !OTU_RATE_MAP.containsKey(otuServiceRate.toString())) { + LOG.error("OTU rate {} not recognized", otuServiceRate); return null; } - String otuRate = otuServiceRate.getSimpleName(); - LOG.info("OTU rate = {}", otuRate); - //TODO a Map would probably be more indicated here - switch (otuRate) { - case "OTU0": - return OTU0.class; - case "OTU1": - return OTU1.class; - case "OTU2": - return OTU2.class; - case "OTU2e": - return OTU2e.class; - case "OTU3": - return OTU3.class; - case "OTU4": - return OTU4.class; - case "OTUCn": - return OTUCn.class; - case "OTUflex": - return OTUflex.class; - default: - LOG.error("OTU rate {} not recognized", otuRate); - } - return null; + return OTU_RATE_MAP.get(otuServiceRate.toString()); } public static org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915 @@ -285,6 +259,19 @@ public final class ModelMappingUtils { .build(); } + public static org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808 + .path.computation.reroute.request.input.ServiceAEnd createServiceAEndReroute(ServiceEndpoint serviceAEnd) { + return new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808 + .path.computation.reroute.request.input.ServiceAEndBuilder() + .setClli(serviceAEnd.getClli()) + .setNodeId(serviceAEnd.getNodeId().getValue()) + .setRxDirection(createRxDirection(serviceAEnd.getRxDirection().values().stream().findFirst().get())) + .setServiceFormat(serviceAEnd.getServiceFormat()) + .setServiceRate(serviceAEnd.getServiceRate()) + .setTxDirection(createTxDirection(serviceAEnd.getTxDirection().values().stream().findFirst().get())) + .build(); + } + public static ServiceZEnd createServiceZEnd(ServiceEndpoint serviceZEnd) { return new ServiceZEndBuilder() .setClli(serviceZEnd.getClli()) @@ -296,6 +283,19 @@ public final class ModelMappingUtils { .build(); } + public static org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808 + .path.computation.reroute.request.input.ServiceZEnd createServiceZEndReroute(ServiceEndpoint serviceZEnd) { + return new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808 + .path.computation.reroute.request.input.ServiceZEndBuilder() + .setClli(serviceZEnd.getClli()) + .setNodeId(serviceZEnd.getNodeId().getValue()) + .setRxDirection(createRxDirection(serviceZEnd.getRxDirection().values().stream().findFirst().get())) + .setServiceFormat(serviceZEnd.getServiceFormat()) + .setServiceRate(serviceZEnd.getServiceRate()) + .setTxDirection(createTxDirection(serviceZEnd.getTxDirection().values().stream().findFirst().get())) + .build(); + } + public static RxDirection createRxDirection( org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210 .service.endpoint.RxDirection rxDirection) { @@ -417,14 +417,16 @@ public final class ModelMappingUtils { } public static ListenableFuture> createRerouteServiceReply( - ServiceRerouteInput input, String finalAckYes, String message) { + ServiceRerouteInput input, String finalAckYes, String message, String responseCode) { return RpcResultBuilder .success( new ServiceRerouteOutputBuilder() .setConfigurationResponseCommon( new ConfigurationResponseCommonBuilder() - .setResponseMessage(message) - .build()) + .setAckFinalIndicator(finalAckYes) + .setResponseCode(responseCode) + .setResponseMessage(message) + .build()) .setHardConstraints(null) .setSoftConstraints(null) .build()) @@ -455,6 +457,7 @@ public final class ModelMappingUtils { .setConnectionType(serviceCreateInput.getConnectionType()) .setCustomer(serviceCreateInput.getCustomer()) .setCustomerContact(serviceCreateInput.getCustomerContact()) + .setServiceResiliency(serviceCreateInput.getServiceResiliency()) .setHardConstraints(serviceCreateInput.getHardConstraints()) .setSoftConstraints(serviceCreateInput.getSoftConstraints()) .setSdncRequestHeader(serviceCreateInput.getSdncRequestHeader())