- if (ServiceFormat.OTU.equals(input.getServiceAEnd().getServiceFormat())
- && input.getServiceAEnd().getOtuServiceRate() != null) {
- switch (input.getServiceAEnd().getOtuServiceRate().getSimpleName()) {
- case "OTUCn":
- return Uint32.valueOf(400);
- case "OTU4":
- return Uint32.valueOf(100);
- case "OTU2":
- case "OTU2e":
- return Uint32.valueOf(10);
- default:
- LOG.warn("otu-service-rate {} not managed yet", input.getServiceAEnd().getOtuServiceRate()
- .getSimpleName());
- return Uint32.ZERO;
- }
- } else if (ServiceFormat.ODU.equals(input.getServiceAEnd().getServiceFormat())
- && input.getServiceAEnd().getOduServiceRate() != null) {
- switch (input.getServiceAEnd().getOduServiceRate().getSimpleName()) {
- case "ODUCn":
- return Uint32.valueOf(400);
- case "ODU4":
- return Uint32.valueOf(100);
- case "ODU2":
- case "ODU2e":
- return Uint32.valueOf(10);
- case "ODU0":
- return Uint32.valueOf(1);
- default:
- LOG.warn("odu-service-rate {} not managed yet", input.getServiceAEnd().getOduServiceRate()
- .getSimpleName());
- return Uint32.ZERO;
- }
- } else {
- LOG.warn("Unable to get service-rate for service {} - otu-service-rate should not be null",
- input.getServiceName());
+ LOG.warn("Input should have rate if you are using 200 or 300G");
+ // TODO: missing 200, and 300G rates here, OTUCn cannot always be 400G
+ Map<ServiceFormat, Map<String, Uint32>> formatRateMap = Map.of(
+ ServiceFormat.OTU, Map.of(
+ "OTUCn", Uint32.valueOf(400),
+ "OTU4", Uint32.valueOf(100),
+ "OTU2", Uint32.valueOf(10),
+ "OTU2e", Uint32.valueOf(10)),
+ ServiceFormat.ODU, Map.of(
+ "ODUCn",Uint32.valueOf(400),
+ "ODU4", Uint32.valueOf(100),
+ "ODU2", Uint32.valueOf(10),
+ "ODU2e", Uint32.valueOf(10),
+ "ODU0", Uint32.valueOf(1)));
+ if (!formatRateMap.containsKey(input.getServiceAEnd().getServiceFormat())) {
+ LOG.warn("Unable to get service-rate for service {} - unsupported service format {}",
+ input.getServiceName(), input.getServiceAEnd().getServiceFormat());
+ return Uint32.ZERO;
+ }
+ String serviceName =
+ ServiceFormat.OTU.getName().equals(input.getServiceAEnd().getServiceFormat().getName())
+ ? input.getServiceAEnd().getOtuServiceRate().getSimpleName()
+ : input.getServiceAEnd().getOduServiceRate().getSimpleName();
+ if (!formatRateMap.get(input.getServiceAEnd().getServiceFormat()).containsKey(serviceName)) {
+ LOG.warn("Unable to get service-rate for service {} - unsupported service name {}",
+ input.getServiceName(), serviceName);