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.rev200128.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, String logicalConnPoint)
36 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 nodeId node ID
54 * @param logicalConnPoint logical connection point
55 * @param waveNumber wavelength number of the OCH interface.
57 * @return Name of the interface if successful, otherwise return null.
59 * @throws OpenRoadmInterfaceException OpenRoadm interface exception
62 public List<String> createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber)
63 throws OpenRoadmInterfaceException {
65 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
66 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
67 return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint,waveNumber);
68 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
69 return openRoadmInterface221.createFlexOCH(nodeId, logicalConnPoint,waveNumber);
76 public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber,
77 Class<? extends RateIdentity> rate, OchAttributes.ModulationFormat format) throws OpenRoadmInterfaceException {
78 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
79 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
80 return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber,
82 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
83 return openRoadmInterface221.createOpenRoadmOchInterface(nodeId,logicalConnPoint,waveNumber);
90 * This methods creates an ODU interface on the given termination point.
92 * @param nodeId node ID
93 * @param logicalConnPoint logical connection point
94 * @param supportingOtuInterface supporting OTU interface
96 * @return Name of the interface if successful, otherwise return null.
98 * @throws OpenRoadmInterfaceException OpenRoadm interface exception
101 public String createOpenRoadmOdu4Interface(String nodeId, String logicalConnPoint, String supportingOtuInterface)
102 throws OpenRoadmInterfaceException {
103 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
104 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
105 return openRoadmInterface121.createOpenRoadmOdu4Interface(nodeId, logicalConnPoint,
106 supportingOtuInterface);
107 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
108 return openRoadmInterface221.createOpenRoadmOdu4Interface(nodeId, logicalConnPoint,
109 supportingOtuInterface);
116 * This methods creates an OTU interface on the given termination point.
118 * @param nodeId node ID
119 * @param logicalConnPoint logical connection point
120 * @param supportOchInterface supporting OCH interface
122 * @return Name of the interface if successful, otherwise return null.
124 * @throws OpenRoadmInterfaceException OpenRoadm interface exception
127 public String createOpenRoadmOtu4Interface(String nodeId, String logicalConnPoint, String supportOchInterface)
128 throws OpenRoadmInterfaceException {
129 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
130 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
131 return openRoadmInterface121.createOpenRoadmOtu4Interface(nodeId,
132 logicalConnPoint,supportOchInterface);
133 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
134 return openRoadmInterface221.createOpenRoadmOtu4Interface(nodeId,logicalConnPoint, supportOchInterface);
140 public String createOpenRoadmOchInterfaceName(String logicalConnectionPoint, Long waveNumber) {
141 return logicalConnectionPoint + "-" + waveNumber;
144 public String createOpenRoadmOmsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException {
145 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
146 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
147 return openRoadmInterface121.createOpenRoadmOmsInterface(nodeId,mapping);
148 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
149 return openRoadmInterface221.createOpenRoadmOmsInterface(nodeId,mapping);
155 public String createOpenRoadmOtsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException {
156 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
157 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
158 return openRoadmInterface121.createOpenRoadmOtsInterface(nodeId,mapping);
159 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
160 return openRoadmInterface221.createOpenRoadmOtsInterface(nodeId,mapping);
166 public boolean isUsedbyXc(String nodeId, String interfaceName, String xc,
167 DeviceTransactionManager deviceTransactionManager) {
168 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
169 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
170 return openRoadmInterface121.isUsedByXc(nodeId, interfaceName, xc, deviceTransactionManager);
171 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
172 return openRoadmInterface221.isUsedByXc(nodeId, interfaceName, xc, deviceTransactionManager);