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 nodeId node ID
54 * @param logicalConnPoint logical connection point
55 * @param waveNumber wavelength number of the OCH interface.
56 * @throws OpenRoadmInterfaceException OpenRoadm interface exception
58 * @return Name of the interface if successful, otherwise return null.
61 public List<String> createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber)
62 throws OpenRoadmInterfaceException {
64 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
65 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
66 return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint,waveNumber);
67 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
68 return openRoadmInterface221.createFlexOCH(nodeId, logicalConnPoint,waveNumber);
75 public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber,
76 Class<? extends RateIdentity> rate, OchAttributes.ModulationFormat format) throws OpenRoadmInterfaceException {
77 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
78 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
79 return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber,
81 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
82 return openRoadmInterface221.createOpenRoadmOchInterface(nodeId,logicalConnPoint,waveNumber);
89 * This methods creates an ODU interface on the given termination point.
91 * @param nodeId node ID
92 * @param logicalConnPoint logical connection point
93 * @param supportingOtuInterface supporting OTU interface
94 * @throws OpenRoadmInterfaceException OpenRoadm interface exception
96 * @return Name of the interface if successful, otherwise return null.
99 public String createOpenRoadmOdu4Interface(String nodeId, String logicalConnPoint, String supportingOtuInterface)
100 throws OpenRoadmInterfaceException {
101 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
102 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
103 return openRoadmInterface121.createOpenRoadmOdu4Interface(nodeId, logicalConnPoint,
104 supportingOtuInterface);
105 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
106 return openRoadmInterface221.createOpenRoadmOdu4Interface(nodeId, logicalConnPoint,
107 supportingOtuInterface);
114 * This methods creates an OTU interface on the given termination point.
116 * @param nodeId node ID
117 * @param logicalConnPoint logical connection point
118 * @param supportOchInterface supporting OCH interface
119 * @throws OpenRoadmInterfaceException OpenRoadm interface exception
121 * @return Name of the interface if successful, otherwise return null.
124 public String createOpenRoadmOtu4Interface(String nodeId, String logicalConnPoint, String supportOchInterface)
125 throws OpenRoadmInterfaceException {
126 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
127 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
128 return openRoadmInterface121.createOpenRoadmOtu4Interface(nodeId,
129 logicalConnPoint,supportOchInterface);
130 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
131 return openRoadmInterface221.createOpenRoadmOtu4Interface(nodeId,logicalConnPoint, supportOchInterface);
137 public String createOpenRoadmOchInterfaceName(String logicalConnectionPoint, Long waveNumber) {
138 return logicalConnectionPoint + "-" + waveNumber;
141 public String createOpenRoadmOmsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException {
142 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
143 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
144 return openRoadmInterface121.createOpenRoadmOmsInterface(nodeId,mapping);
145 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
146 return openRoadmInterface221.createOpenRoadmOmsInterface(nodeId,mapping);
152 public String createOpenRoadmOtsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException {
153 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
154 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
155 return openRoadmInterface121.createOpenRoadmOtsInterface(nodeId,mapping);
156 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
157 return openRoadmInterface221.createOpenRoadmOtsInterface(nodeId,mapping);
163 public boolean isUsedbyXc(String nodeId, String interfaceName, String xc,
164 DeviceTransactionManager deviceTransactionManager) {
165 switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
166 case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
167 return openRoadmInterface121.isUsedByXc(nodeId, interfaceName, xc, deviceTransactionManager);
168 case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
169 return openRoadmInterface221.isUsedByXc(nodeId, interfaceName, xc, deviceTransactionManager);