2 * Copyright © 2017 AT&T 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.renderer.openroadminterface;
11 import java.util.List;
13 import org.opendaylight.transportpce.common.StringConstants;
14 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
15 import org.opendaylight.transportpce.common.mapping.MappingUtils;
16 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev170228.network.nodes.Mapping;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.RateIdentity;
21 public class OpenRoadmInterfaceFactory {
23 private final MappingUtils mappingUtils;
24 private final OpenRoadmInterface121 openRoadmInterface121;
25 private final OpenRoadmInterface221 openRoadmInterface221;
28 public OpenRoadmInterfaceFactory(MappingUtils mappingUtils, OpenRoadmInterface121 openRoadmInterface121,
29 OpenRoadmInterface221 openRoadmInterface221) {
30 this.mappingUtils = mappingUtils;
31 this.openRoadmInterface121 = openRoadmInterface121;
32 this.openRoadmInterface221 = openRoadmInterface221;
35 public String createOpenRoadmEthInterface(String nodeId,
36 String logicalConnPoint) throws OpenRoadmInterfaceException {
38 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
39 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
40 return openRoadmInterface121.createOpenRoadmEthInterface(nodeId, logicalConnPoint);
41 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
42 return openRoadmInterface221.createOpenRoadmEthInterface(nodeId, logicalConnPoint);
50 * This methods creates an OCH interface on the given termination point on
53 * @param waveNumber wavelength number of the OCH interface.
54 * @return Name of the interface if successful, otherwise return null.
57 public List<String> createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber)
58 throws OpenRoadmInterfaceException {
60 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
61 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
62 return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint,waveNumber);
63 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
64 return openRoadmInterface221.createFlexOCH(nodeId, logicalConnPoint,waveNumber);
71 public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber,
72 Class<? extends RateIdentity> rate, OchAttributes.ModulationFormat format) throws OpenRoadmInterfaceException {
73 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
74 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
75 return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber,
77 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
78 return openRoadmInterface221.createOpenRoadmOchInterface(nodeId,logicalConnPoint,waveNumber);
85 * This methods creates an ODU interface on the given termination point.
87 * @return Name of the interface if successful, otherwise return null.
90 public String createOpenRoadmOdu4Interface(String nodeId, String logicalConnPoint, String supportingOtuInterface)
91 throws OpenRoadmInterfaceException {
92 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
93 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
94 return openRoadmInterface121.createOpenRoadmOdu4Interface(nodeId, logicalConnPoint,
95 supportingOtuInterface);
96 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
97 return openRoadmInterface221.createOpenRoadmOdu4Interface(nodeId, logicalConnPoint,
98 supportingOtuInterface);
105 * This methods creates an OTU interface on the given termination point.
107 * @return Name of the interface if successful, otherwise return null.
110 public String createOpenRoadmOtu4Interface(String nodeId, String logicalConnPoint, String supportOchInterface)
111 throws OpenRoadmInterfaceException {
112 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
113 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
114 return openRoadmInterface121.createOpenRoadmOtu4Interface(nodeId,
115 logicalConnPoint,supportOchInterface);
116 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
117 return openRoadmInterface221.createOpenRoadmOtu4Interface(nodeId,logicalConnPoint, supportOchInterface);
123 public String createOpenRoadmOchInterfaceName(String logicalConnectionPoint, Long waveNumber) {
124 return logicalConnectionPoint + "-" + waveNumber;
127 public String createOpenRoadmOmsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException {
128 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
129 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
130 return openRoadmInterface121.createOpenRoadmOmsInterface(nodeId,mapping);
131 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
132 return openRoadmInterface221.createOpenRoadmOmsInterface(nodeId,mapping);
138 public String createOpenRoadmOtsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException {
139 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
140 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
141 return openRoadmInterface121.createOpenRoadmOtsInterface(nodeId,mapping);
142 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
143 return openRoadmInterface221.createOpenRoadmOtsInterface(nodeId,mapping);
149 public boolean isUsedbyXc(String nodeId, String interfaceName, String xc,
150 DeviceTransactionManager deviceTransactionManager) {
151 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
152 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
153 return openRoadmInterface121.isUsedByXc(nodeId, interfaceName, xc, deviceTransactionManager);
154 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
155 return openRoadmInterface221.isUsedByXc(nodeId, interfaceName, xc, deviceTransactionManager);