Update Renderer Module
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / openroadminterface / OpenRoadmInterfaceFactory.java
1 /*
2  * Copyright © 2017 AT&T and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.transportpce.renderer.openroadminterface;
10
11 import java.util.List;
12
13 import org.opendaylight.transportpce.common.StringConstants;
14 import org.opendaylight.transportpce.common.mapping.MappingUtils;
15 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev170228.network.nodes.Mapping;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.RateIdentity;
19
20 public class OpenRoadmInterfaceFactory {
21
22     private final MappingUtils mappingUtils;
23     private final OpenRoadmInterface121 openRoadmInterface121;
24     private final OpenRoadmInterface22 openRoadmInterface22;
25
26
27     public OpenRoadmInterfaceFactory(MappingUtils mappingUtils, OpenRoadmInterface121 openRoadmInterface121,
28         OpenRoadmInterface22 openRoadmInterface22) {
29         this.mappingUtils = mappingUtils;
30         this.openRoadmInterface121 = openRoadmInterface121;
31         this.openRoadmInterface22 = openRoadmInterface22;
32     }
33
34     public String createOpenRoadmEthInterface(String nodeId,
35                                               String logicalConnPoint) throws OpenRoadmInterfaceException {
36
37         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
38             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
39                 return openRoadmInterface121.createOpenRoadmEthInterface(nodeId, logicalConnPoint);
40             case StringConstants.OPENROADM_DEVICE_VERSION_2_2:
41                 return openRoadmInterface22.createOpenRoadmEthInterface(nodeId, logicalConnPoint);
42             default:
43                 return null;
44         }
45     }
46
47
48     /**
49      * This methods creates an OCH interface on the given termination point on
50      * Roadm.
51      *
52      * @param waveNumber wavelength number of the OCH interface.
53      * @return Name of the interface if successful, otherwise return null.
54      */
55
56     public List<String> createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber)
57         throws OpenRoadmInterfaceException {
58
59         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
60             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
61                 return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint,waveNumber);
62             case StringConstants.OPENROADM_DEVICE_VERSION_2_2:
63                 return openRoadmInterface22.createFlexOCH(nodeId, logicalConnPoint,waveNumber);
64             default:
65                 return null;
66         }
67     }
68
69
70     public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber,
71         Class<? extends RateIdentity> rate, OchAttributes.ModulationFormat format) throws OpenRoadmInterfaceException {
72         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
73             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
74                 return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber,
75                     rate, format);
76             case StringConstants.OPENROADM_DEVICE_VERSION_2_2:
77                 return openRoadmInterface22.createOpenRoadmOchInterface(nodeId,logicalConnPoint,waveNumber);
78             default:
79                 return null;
80         }
81     }
82
83     /**
84      * This methods creates an ODU interface on the given termination point.
85      *
86      * @return Name of the interface if successful, otherwise return null.
87      */
88
89     public String createOpenRoadmOdu4Interface(String nodeId, String logicalConnPoint, String supportingOtuInterface)
90             throws OpenRoadmInterfaceException {
91         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
92             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
93                 return openRoadmInterface121.createOpenRoadmOdu4Interface(nodeId, logicalConnPoint,
94                     supportingOtuInterface);
95             case StringConstants.OPENROADM_DEVICE_VERSION_2_2:
96                 return openRoadmInterface22.createOpenRoadmOdu4Interface(nodeId, logicalConnPoint,
97                     supportingOtuInterface);
98             default:
99                 return null;
100         }
101     }
102
103     /**
104      * This methods creates an OTU interface on the given termination point.
105      *
106      * @return Name of the interface if successful, otherwise return null.
107      */
108
109     public String createOpenRoadmOtu4Interface(String nodeId, String logicalConnPoint, String supportOchInterface)
110             throws OpenRoadmInterfaceException {
111         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
112             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
113                 return openRoadmInterface121.createOpenRoadmOtu4Interface(nodeId,
114                     logicalConnPoint,supportOchInterface);
115             case StringConstants.OPENROADM_DEVICE_VERSION_2_2:
116                 return openRoadmInterface22.createOpenRoadmOtu4Interface(nodeId,logicalConnPoint, supportOchInterface);
117             default:
118                 return null;
119         }
120     }
121
122     public String createOpenRoadmOchInterfaceName(String logicalConnectionPoint, Long waveNumber) {
123         return logicalConnectionPoint + "-" + waveNumber;
124     }
125
126     public String createOpenRoadmOmsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException {
127         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
128             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
129                 return openRoadmInterface121.createOpenRoadmOmsInterface(nodeId,mapping);
130             case StringConstants.OPENROADM_DEVICE_VERSION_2_2:
131                 return openRoadmInterface22.createOpenRoadmOmsInterface(nodeId,mapping);
132             default:
133                 return null;
134         }
135     }
136
137     public String createOpenRoadmOtsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException {
138         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
139             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
140                 return openRoadmInterface121.createOpenRoadmOtsInterface(nodeId,mapping);
141             case StringConstants.OPENROADM_DEVICE_VERSION_2_2:
142                 return openRoadmInterface22.createOpenRoadmOtsInterface(nodeId,mapping);
143             default:
144                 return null;
145         }
146     }
147
148
149
150
151
152 }