Move Ciena Waveserver specific code out to Ciena driver bundle.
Change-Id: I96adc5e878a391dd608ad856354ac89638638554
Showing
2 changed files
with
44 additions
and
44 deletions
... | @@ -22,10 +22,15 @@ import com.google.common.collect.Lists; | ... | @@ -22,10 +22,15 @@ import com.google.common.collect.Lists; |
22 | import org.apache.commons.configuration.HierarchicalConfiguration; | 22 | import org.apache.commons.configuration.HierarchicalConfiguration; |
23 | import org.onosproject.drivers.utilities.XmlConfigParser; | 23 | import org.onosproject.drivers.utilities.XmlConfigParser; |
24 | import org.onosproject.net.AnnotationKeys; | 24 | import org.onosproject.net.AnnotationKeys; |
25 | +import org.onosproject.net.ChannelSpacing; | ||
25 | import org.onosproject.net.CltSignalType; | 26 | import org.onosproject.net.CltSignalType; |
26 | import org.onosproject.net.DefaultAnnotations; | 27 | import org.onosproject.net.DefaultAnnotations; |
27 | import org.onosproject.net.DeviceId; | 28 | import org.onosproject.net.DeviceId; |
29 | +import org.onosproject.net.GridType; | ||
30 | +import org.onosproject.net.OchSignal; | ||
31 | +import org.onosproject.net.OduSignalType; | ||
28 | import org.onosproject.net.PortNumber; | 32 | import org.onosproject.net.PortNumber; |
33 | +import org.onosproject.net.SparseAnnotations; | ||
29 | import org.onosproject.net.behaviour.PortDiscovery; | 34 | import org.onosproject.net.behaviour.PortDiscovery; |
30 | import org.onosproject.net.device.PortDescription; | 35 | import org.onosproject.net.device.PortDescription; |
31 | import org.onosproject.net.driver.AbstractHandlerBehaviour; | 36 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
... | @@ -36,6 +41,7 @@ import java.util.ArrayList; | ... | @@ -36,6 +41,7 @@ import java.util.ArrayList; |
36 | import java.util.List; | 41 | import java.util.List; |
37 | 42 | ||
38 | import static com.google.common.base.Preconditions.checkNotNull; | 43 | import static com.google.common.base.Preconditions.checkNotNull; |
44 | +import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | ||
39 | import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription; | 45 | import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription; |
40 | 46 | ||
41 | /** | 47 | /** |
... | @@ -80,7 +86,7 @@ public class PortDiscoveryCienaWaveserverImpl extends AbstractHandlerBehaviour | ... | @@ -80,7 +86,7 @@ public class PortDiscoveryCienaWaveserverImpl extends AbstractHandlerBehaviour |
80 | HierarchicalConfiguration config = XmlConfigParser. | 86 | HierarchicalConfiguration config = XmlConfigParser. |
81 | loadXml(controller.get(deviceId, GENERAL_PORT_REQUEST, XML)); | 87 | loadXml(controller.get(deviceId, GENERAL_PORT_REQUEST, XML)); |
82 | List<HierarchicalConfiguration> portsConfig = | 88 | List<HierarchicalConfiguration> portsConfig = |
83 | - XmlConfigParser.parseWaveServerCienaPorts(config); | 89 | + parseWaveServerCienaPorts(config); |
84 | portsConfig.stream().forEach(sub -> { | 90 | portsConfig.stream().forEach(sub -> { |
85 | String portId = sub.getString(PORT_ID); | 91 | String portId = sub.getString(PORT_ID); |
86 | String name = sub.getString(NAME); | 92 | String name = sub.getString(NAME); |
... | @@ -90,7 +96,7 @@ public class PortDiscoveryCienaWaveserverImpl extends AbstractHandlerBehaviour | ... | @@ -90,7 +96,7 @@ public class PortDiscoveryCienaWaveserverImpl extends AbstractHandlerBehaviour |
90 | .set(AnnotationKeys.PORT_NAME, txName); | 96 | .set(AnnotationKeys.PORT_NAME, txName); |
91 | String wsportInfoRequest = SPECIFIC_PORT_PATH + portId + | 97 | String wsportInfoRequest = SPECIFIC_PORT_PATH + portId + |
92 | SPECIFIC_PORT_CONFIG; | 98 | SPECIFIC_PORT_CONFIG; |
93 | - ports.add(XmlConfigParser.parseWaveServerCienaOchPorts( | 99 | + ports.add(parseWaveServerCienaOchPorts( |
94 | sub.getLong(PORT_ID), | 100 | sub.getLong(PORT_ID), |
95 | toGbps(Long.parseLong(sub.getString(SPEED).replace(GBPS, EMPTY_STRING) | 101 | toGbps(Long.parseLong(sub.getString(SPEED).replace(GBPS, EMPTY_STRING) |
96 | .replace(" ", EMPTY_STRING))), | 102 | .replace(" ", EMPTY_STRING))), |
... | @@ -98,7 +104,7 @@ public class PortDiscoveryCienaWaveserverImpl extends AbstractHandlerBehaviour | ... | @@ -98,7 +104,7 @@ public class PortDiscoveryCienaWaveserverImpl extends AbstractHandlerBehaviour |
98 | annotations.build())); | 104 | annotations.build())); |
99 | //adding corresponding opposite side port | 105 | //adding corresponding opposite side port |
100 | String rxName = name.replace(".1", ".2") + " Rx"; | 106 | String rxName = name.replace(".1", ".2") + " Rx"; |
101 | - ports.add(XmlConfigParser.parseWaveServerCienaOchPorts( | 107 | + ports.add(parseWaveServerCienaOchPorts( |
102 | sub.getLong(PORT_ID) + 1, | 108 | sub.getLong(PORT_ID) + 1, |
103 | toGbps(Long.parseLong(sub.getString(SPEED).replace(GBPS, EMPTY_STRING) | 109 | toGbps(Long.parseLong(sub.getString(SPEED).replace(GBPS, EMPTY_STRING) |
104 | .replace(" ", EMPTY_STRING))), | 110 | .replace(" ", EMPTY_STRING))), |
... | @@ -122,10 +128,44 @@ public class PortDiscoveryCienaWaveserverImpl extends AbstractHandlerBehaviour | ... | @@ -122,10 +128,44 @@ public class PortDiscoveryCienaWaveserverImpl extends AbstractHandlerBehaviour |
122 | return ports; | 128 | return ports; |
123 | } | 129 | } |
124 | 130 | ||
131 | + public static List<HierarchicalConfiguration> parseWaveServerCienaPorts(HierarchicalConfiguration cfg) { | ||
132 | + return cfg.configurationsAt("ws-ports.port-interface"); | ||
133 | + } | ||
134 | + | ||
135 | + public static PortDescription parseWaveServerCienaOchPorts(long portNumber, long oduPortSpeed, | ||
136 | + HierarchicalConfiguration config, | ||
137 | + SparseAnnotations annotations) { | ||
138 | + final List<String> tunableType = Lists.newArrayList("Performance-Optimized", "Accelerated"); | ||
139 | + final String transmitterPath = "ptp-config.transmitter-state"; | ||
140 | + final String tunablePath = "ptp-config.adv-config.tx-tuning-mode"; | ||
141 | + final String gridTypePath = "ptp-config.adv-config.wl-spacing"; | ||
142 | + final String frequencyPath = "ptp-config.adv-config.frequency"; | ||
143 | + | ||
144 | + boolean isEnabled = config.getString(transmitterPath).equals("enabled"); | ||
145 | + boolean isTunable = tunableType.contains(config.getString(tunablePath)); | ||
146 | + | ||
147 | + //FIXME change when all optical types have two way information methods, see jira tickets | ||
148 | + final int speed100GbpsinMbps = 100000; | ||
149 | + OduSignalType oduSignalType = oduPortSpeed == speed100GbpsinMbps ? OduSignalType.ODU4 : null; | ||
150 | + GridType gridType = config.getString(gridTypePath).equals("FlexGrid") ? GridType.FLEX : null; | ||
151 | + ChannelSpacing chSpacing = gridType == GridType.FLEX ? ChannelSpacing.CHL_6P25GHZ : null; | ||
152 | + | ||
153 | + //Working in Ghz //(Nominal central frequency - 193.1)/channelSpacing = spacingMultiplier | ||
154 | + final int baseFrequency = 193100; | ||
155 | + int spacingMult = (int) (toGbps((Integer.parseInt(config.getString(frequencyPath)) - | ||
156 | + baseFrequency)) / toGbpsFromHz(chSpacing.frequency().asHz())); //FIXME is there a better way ? | ||
157 | + | ||
158 | + return ochPortDescription(PortNumber.portNumber(portNumber), isEnabled, oduSignalType, isTunable, | ||
159 | + new OchSignal(gridType, chSpacing, spacingMult, 1), annotations); | ||
160 | + } | ||
161 | + | ||
125 | //FIXME remove when all optical types have two way information methods, see jira tickets | 162 | //FIXME remove when all optical types have two way information methods, see jira tickets |
126 | - private long toGbps(long speed) { | 163 | + private static long toGbps(long speed) { |
127 | return speed * 1000; | 164 | return speed * 1000; |
128 | } | 165 | } |
129 | 166 | ||
167 | + private static long toGbpsFromHz(long speed) { | ||
168 | + return speed / 1000; | ||
169 | + } | ||
130 | } | 170 | } |
131 | 171 | ... | ... |
... | @@ -30,7 +30,6 @@ import org.onosproject.net.GridType; | ... | @@ -30,7 +30,6 @@ import org.onosproject.net.GridType; |
30 | import org.onosproject.net.OchSignal; | 30 | import org.onosproject.net.OchSignal; |
31 | import org.onosproject.net.OduSignalType; | 31 | import org.onosproject.net.OduSignalType; |
32 | import org.onosproject.net.PortNumber; | 32 | import org.onosproject.net.PortNumber; |
33 | -import org.onosproject.net.SparseAnnotations; | ||
34 | import org.onosproject.net.behaviour.ControllerInfo; | 33 | import org.onosproject.net.behaviour.ControllerInfo; |
35 | import org.onosproject.net.device.PortDescription; | 34 | import org.onosproject.net.device.PortDescription; |
36 | import org.slf4j.Logger; | 35 | import org.slf4j.Logger; |
... | @@ -187,45 +186,6 @@ public final class XmlConfigParser { | ... | @@ -187,45 +186,6 @@ public final class XmlConfigParser { |
187 | 186 | ||
188 | } | 187 | } |
189 | 188 | ||
190 | - public static List<HierarchicalConfiguration> parseWaveServerCienaPorts(HierarchicalConfiguration cfg) { | ||
191 | - return cfg.configurationsAt("ws-ports.port-interface"); | ||
192 | - } | ||
193 | - | ||
194 | - public static PortDescription parseWaveServerCienaOchPorts(long portNumber, long oduPortSpeed, | ||
195 | - HierarchicalConfiguration config, | ||
196 | - SparseAnnotations annotations) { | ||
197 | - final List<String> tunableType = Lists.newArrayList("Performance-Optimized", "Accelerated"); | ||
198 | - final String transmitterPath = "ptp-config.transmitter-state"; | ||
199 | - final String tunablePath = "ptp-config.adv-config.tx-tuning-mode"; | ||
200 | - final String gridTypePath = "ptp-config.adv-config.wl-spacing"; | ||
201 | - final String frequencyPath = "ptp-config.adv-config.frequency"; | ||
202 | - | ||
203 | - boolean isEnabled = config.getString(transmitterPath).equals("enabled"); | ||
204 | - boolean isTunable = tunableType.contains(config.getString(tunablePath)); | ||
205 | - | ||
206 | - //FIXME change when all optical types have two way information methods, see jira tickets | ||
207 | - final int speed100GbpsinMbps = 100000; | ||
208 | - OduSignalType oduSignalType = oduPortSpeed == speed100GbpsinMbps ? OduSignalType.ODU4 : null; | ||
209 | - GridType gridType = config.getString(gridTypePath).equals("FlexGrid") ? GridType.FLEX : null; | ||
210 | - ChannelSpacing chSpacing = gridType == GridType.FLEX ? ChannelSpacing.CHL_6P25GHZ : null; | ||
211 | - | ||
212 | - //Working in Ghz //(Nominal central frequency - 193.1)/channelSpacing = spacingMultiplier | ||
213 | - final int baseFrequency = 193100; | ||
214 | - int spacingMult = (int) (toGbps((Integer.parseInt(config.getString(frequencyPath)) - | ||
215 | - baseFrequency)) / toGbpsFromHz(chSpacing.frequency().asHz())); //FIXME is there a better way ? | ||
216 | - | ||
217 | - return ochPortDescription(PortNumber.portNumber(portNumber), isEnabled, oduSignalType, isTunable, | ||
218 | - new OchSignal(gridType, chSpacing, spacingMult, 1), annotations); | ||
219 | - } | ||
220 | - | ||
221 | - //FIXME remove when all optical types have two way information methods, see jira tickets | ||
222 | - private static long toGbps(long speed) { | ||
223 | - return speed * 1000; | ||
224 | - } | ||
225 | - | ||
226 | - private static long toGbpsFromHz(long speed) { | ||
227 | - return speed / 1000; | ||
228 | - } | ||
229 | //TODO implement mor methods for parsing configuration when you need them | 189 | //TODO implement mor methods for parsing configuration when you need them |
230 | 190 | ||
231 | /** | 191 | /** | ... | ... |
-
Please register or login to post a comment