2 * Copyright © 2021 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.common.service;
12 import org.opendaylight.transportpce.common.StringConstants;
13 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.Mapping;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.PortQual;
15 import org.opendaylight.yangtools.yang.common.Uint32;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 public final class ServiceTypes {
20 private static final Logger LOG = LoggerFactory.getLogger(ServiceTypes.class);
22 private ServiceTypes() {
25 public static String getServiceType(String serviceFormat, Uint32 serviceRate, Mapping mapping) {
27 switch (serviceFormat) {
29 if (Uint32.valueOf(100).equals(serviceRate)) {
30 return StringConstants.SERVICE_TYPE_100GE_T;
32 LOG.warn("Invalid service-rate {}", serviceRate);
36 if (Uint32.valueOf(400).equals(serviceRate)) {
37 return StringConstants.SERVICE_TYPE_400GE;
39 if (Uint32.valueOf(100).equals(serviceRate)
40 && (mapping == null || !PortQual.SwitchClient.getName().equals(mapping.getPortQual()))) {
41 return StringConstants.SERVICE_TYPE_100GE_T;
43 return getOtnServiceType(serviceFormat, serviceRate);
48 return getOtnServiceType(serviceFormat, serviceRate);
52 public static String getOtnServiceType(String serviceFormat, Uint32 serviceRate) {
53 Map<String, Map<Uint32, String>> otnMap = Map.of(
55 Uint32.valueOf(1), StringConstants.SERVICE_TYPE_1GE,
56 Uint32.valueOf(10), StringConstants.SERVICE_TYPE_10GE,
57 Uint32.valueOf(100), StringConstants.SERVICE_TYPE_100GE_M),
59 Uint32.valueOf(100), StringConstants.SERVICE_TYPE_OTU4,
60 Uint32.valueOf(400), StringConstants.SERVICE_TYPE_OTUC4),
62 Uint32.valueOf(100), StringConstants.SERVICE_TYPE_ODU4,
63 Uint32.valueOf(400), StringConstants.SERVICE_TYPE_ODUC4));
65 if (!otnMap.containsKey(serviceFormat)) {
66 LOG.warn("Invalid service-format {}", serviceFormat);
70 if (!otnMap.get(serviceFormat).containsKey(serviceRate)) {
71 LOG.warn("Invalid service-rate {}", serviceRate);
75 return otnMap.get(serviceFormat).get(serviceRate);