Move Fujitsu device specific code out to Fujitsu driver bundle.
Change-Id: I5c2960378541e27ffb2087a05acbbf3a3f44bd1e
Showing
2 changed files
with
65 additions
and
63 deletions
| ... | @@ -16,7 +16,16 @@ | ... | @@ -16,7 +16,16 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.drivers.fujitsu; | 17 | package org.onosproject.drivers.fujitsu; |
| 18 | 18 | ||
| 19 | +import org.apache.commons.configuration.HierarchicalConfiguration; | ||
| 19 | import org.onosproject.drivers.utilities.XmlConfigParser; | 20 | import org.onosproject.drivers.utilities.XmlConfigParser; |
| 21 | +import org.onosproject.net.AnnotationKeys; | ||
| 22 | +import org.onosproject.net.ChannelSpacing; | ||
| 23 | +import org.onosproject.net.CltSignalType; | ||
| 24 | +import org.onosproject.net.DefaultAnnotations; | ||
| 25 | +import org.onosproject.net.GridType; | ||
| 26 | +import org.onosproject.net.OchSignal; | ||
| 27 | +import org.onosproject.net.OduSignalType; | ||
| 28 | +import org.onosproject.net.PortNumber; | ||
| 20 | import org.onosproject.net.behaviour.PortDiscovery; | 29 | import org.onosproject.net.behaviour.PortDiscovery; |
| 21 | import org.onosproject.net.device.PortDescription; | 30 | import org.onosproject.net.device.PortDescription; |
| 22 | import org.onosproject.net.driver.AbstractHandlerBehaviour; | 31 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| ... | @@ -25,11 +34,16 @@ import org.onosproject.netconf.NetconfException; | ... | @@ -25,11 +34,16 @@ import org.onosproject.netconf.NetconfException; |
| 25 | import org.onosproject.netconf.NetconfSession; | 34 | import org.onosproject.netconf.NetconfSession; |
| 26 | import org.slf4j.Logger; | 35 | import org.slf4j.Logger; |
| 27 | 36 | ||
| 37 | +import com.google.common.collect.Lists; | ||
| 38 | + | ||
| 28 | import java.io.ByteArrayInputStream; | 39 | import java.io.ByteArrayInputStream; |
| 29 | import java.io.IOException; | 40 | import java.io.IOException; |
| 30 | import java.util.List; | 41 | import java.util.List; |
| 42 | +import java.util.concurrent.atomic.AtomicInteger; | ||
| 31 | 43 | ||
| 32 | import static com.google.common.base.Preconditions.checkNotNull; | 44 | import static com.google.common.base.Preconditions.checkNotNull; |
| 45 | +import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | ||
| 46 | +import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription; | ||
| 33 | import static org.slf4j.LoggerFactory.getLogger; | 47 | import static org.slf4j.LoggerFactory.getLogger; |
| 34 | 48 | ||
| 35 | /** | 49 | /** |
| ... | @@ -50,7 +64,7 @@ public class PortGetterFujitsuImpl extends AbstractHandlerBehaviour | ... | @@ -50,7 +64,7 @@ public class PortGetterFujitsuImpl extends AbstractHandlerBehaviour |
| 50 | } catch (IOException e) { | 64 | } catch (IOException e) { |
| 51 | throw new RuntimeException(new NetconfException("Failed to retrieve configuration.", e)); | 65 | throw new RuntimeException(new NetconfException("Failed to retrieve configuration.", e)); |
| 52 | } | 66 | } |
| 53 | - List<PortDescription> descriptions = XmlConfigParser. | 67 | + List<PortDescription> descriptions = |
| 54 | parseFujitsuT100Ports(XmlConfigParser. | 68 | parseFujitsuT100Ports(XmlConfigParser. |
| 55 | loadXml(new ByteArrayInputStream(reply.getBytes()))); | 69 | loadXml(new ByteArrayInputStream(reply.getBytes()))); |
| 56 | return descriptions; | 70 | return descriptions; |
| ... | @@ -74,4 +88,54 @@ public class PortGetterFujitsuImpl extends AbstractHandlerBehaviour | ... | @@ -74,4 +88,54 @@ public class PortGetterFujitsuImpl extends AbstractHandlerBehaviour |
| 74 | rpc.append("</rpc>"); | 88 | rpc.append("</rpc>"); |
| 75 | return rpc.toString(); | 89 | return rpc.toString(); |
| 76 | } | 90 | } |
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * Parses a configuration and returns a set of ports for the fujitsu T100. | ||
| 94 | + * @param cfg a hierarchical configuration | ||
| 95 | + * @return a list of port descriptions | ||
| 96 | + */ | ||
| 97 | + private static List<PortDescription> parseFujitsuT100Ports(HierarchicalConfiguration cfg) { | ||
| 98 | + AtomicInteger counter = new AtomicInteger(1); | ||
| 99 | + List<PortDescription> portDescriptions = Lists.newArrayList(); | ||
| 100 | + List<HierarchicalConfiguration> subtrees = | ||
| 101 | + cfg.configurationsAt("data.interfaces.interface"); | ||
| 102 | + for (HierarchicalConfiguration portConfig : subtrees) { | ||
| 103 | + if (!portConfig.getString("name").contains("LCN") && | ||
| 104 | + !portConfig.getString("name").contains("LMP") && | ||
| 105 | + portConfig.getString("type").equals("ianaift:ethernetCsmacd")) { | ||
| 106 | + portDescriptions.add(parseT100OduPort(portConfig, counter.getAndIncrement())); | ||
| 107 | + } else if (portConfig.getString("type").equals("ianaift:otnOtu")) { | ||
| 108 | + portDescriptions.add(parseT100OchPort(portConfig, counter.getAndIncrement())); | ||
| 109 | + } | ||
| 110 | + } | ||
| 111 | + return portDescriptions; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + private static PortDescription parseT100OchPort(HierarchicalConfiguration cfg, long count) { | ||
| 115 | + PortNumber portNumber = PortNumber.portNumber(count); | ||
| 116 | + HierarchicalConfiguration otuConfig = cfg.configurationAt("otu"); | ||
| 117 | + boolean enabled = otuConfig.getString("administrative-state").equals("up"); | ||
| 118 | + OduSignalType signalType = otuConfig.getString("rate").equals("OTU4") ? OduSignalType.ODU4 : null; | ||
| 119 | + //Unsure how to retreive, outside knowledge it is tunable. | ||
| 120 | + boolean isTunable = true; | ||
| 121 | + OchSignal lambda = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4); | ||
| 122 | + DefaultAnnotations annotations = DefaultAnnotations.builder(). | ||
| 123 | + set(AnnotationKeys.PORT_NAME, cfg.getString("name")). | ||
| 124 | + build(); | ||
| 125 | + return ochPortDescription(portNumber, enabled, signalType, isTunable, lambda, annotations); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + private static PortDescription parseT100OduPort(HierarchicalConfiguration cfg, long count) { | ||
| 129 | + PortNumber portNumber = PortNumber.portNumber(count); | ||
| 130 | + HierarchicalConfiguration ethernetConfig = cfg.configurationAt("ethernet"); | ||
| 131 | + boolean enabled = ethernetConfig.getString("administrative-state").equals("up"); | ||
| 132 | + //Rate is in kbps | ||
| 133 | + CltSignalType signalType = ethernetConfig.getString("rate").equals("100000000") ? | ||
| 134 | + CltSignalType.CLT_100GBE : null; | ||
| 135 | + DefaultAnnotations annotations = DefaultAnnotations.builder(). | ||
| 136 | + set(AnnotationKeys.PORT_NAME, cfg.getString("name")). | ||
| 137 | + build(); | ||
| 138 | + return oduCltPortDescription(portNumber, enabled, signalType, annotations); | ||
| 139 | + } | ||
| 140 | + | ||
| 77 | } | 141 | } | ... | ... |
| ... | @@ -16,33 +16,19 @@ | ... | @@ -16,33 +16,19 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.drivers.utilities; | 17 | package org.onosproject.drivers.utilities; |
| 18 | 18 | ||
| 19 | -import com.google.common.collect.Lists; | ||
| 20 | import org.apache.commons.configuration.ConfigurationException; | 19 | import org.apache.commons.configuration.ConfigurationException; |
| 21 | import org.apache.commons.configuration.HierarchicalConfiguration; | 20 | import org.apache.commons.configuration.HierarchicalConfiguration; |
| 22 | import org.apache.commons.configuration.XMLConfiguration; | 21 | import org.apache.commons.configuration.XMLConfiguration; |
| 23 | import org.apache.commons.configuration.tree.ConfigurationNode; | 22 | import org.apache.commons.configuration.tree.ConfigurationNode; |
| 24 | import org.onlab.packet.IpAddress; | 23 | import org.onlab.packet.IpAddress; |
| 25 | -import org.onosproject.net.AnnotationKeys; | ||
| 26 | -import org.onosproject.net.ChannelSpacing; | ||
| 27 | -import org.onosproject.net.CltSignalType; | ||
| 28 | -import org.onosproject.net.DefaultAnnotations; | ||
| 29 | -import org.onosproject.net.GridType; | ||
| 30 | -import org.onosproject.net.OchSignal; | ||
| 31 | -import org.onosproject.net.OduSignalType; | ||
| 32 | -import org.onosproject.net.PortNumber; | ||
| 33 | import org.onosproject.net.behaviour.ControllerInfo; | 24 | import org.onosproject.net.behaviour.ControllerInfo; |
| 34 | -import org.onosproject.net.device.PortDescription; | ||
| 35 | import org.slf4j.Logger; | 25 | import org.slf4j.Logger; |
| 36 | import org.slf4j.LoggerFactory; | 26 | import org.slf4j.LoggerFactory; |
| 37 | 27 | ||
| 38 | -import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | ||
| 39 | -import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription; | ||
| 40 | - | ||
| 41 | import java.io.InputStream; | 28 | import java.io.InputStream; |
| 42 | import java.io.StringWriter; | 29 | import java.io.StringWriter; |
| 43 | import java.util.ArrayList; | 30 | import java.util.ArrayList; |
| 44 | import java.util.List; | 31 | import java.util.List; |
| 45 | -import java.util.concurrent.atomic.AtomicInteger; | ||
| 46 | 32 | ||
| 47 | 33 | ||
| 48 | /** | 34 | /** |
| ... | @@ -82,54 +68,6 @@ public final class XmlConfigParser { | ... | @@ -82,54 +68,6 @@ public final class XmlConfigParser { |
| 82 | return controllers; | 68 | return controllers; |
| 83 | } | 69 | } |
| 84 | 70 | ||
| 85 | - /** | ||
| 86 | - * Parses a configuration and returns a set of ports for the fujitsu T100. | ||
| 87 | - * @param cfg a hierarchical configuration | ||
| 88 | - * @return a list of port descriptions | ||
| 89 | - */ | ||
| 90 | - public static List<PortDescription> parseFujitsuT100Ports(HierarchicalConfiguration cfg) { | ||
| 91 | - AtomicInteger counter = new AtomicInteger(1); | ||
| 92 | - List<PortDescription> portDescriptions = Lists.newArrayList(); | ||
| 93 | - List<HierarchicalConfiguration> subtrees = | ||
| 94 | - cfg.configurationsAt("data.interfaces.interface"); | ||
| 95 | - for (HierarchicalConfiguration portConfig : subtrees) { | ||
| 96 | - if (!portConfig.getString("name").contains("LCN") && | ||
| 97 | - !portConfig.getString("name").contains("LMP") && | ||
| 98 | - portConfig.getString("type").equals("ianaift:ethernetCsmacd")) { | ||
| 99 | - portDescriptions.add(parseT100OduPort(portConfig, counter.getAndIncrement())); | ||
| 100 | - } else if (portConfig.getString("type").equals("ianaift:otnOtu")) { | ||
| 101 | - portDescriptions.add(parseT100OchPort(portConfig, counter.getAndIncrement())); | ||
| 102 | - } | ||
| 103 | - } | ||
| 104 | - return portDescriptions; | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - private static PortDescription parseT100OchPort(HierarchicalConfiguration cfg, long count) { | ||
| 108 | - PortNumber portNumber = PortNumber.portNumber(count); | ||
| 109 | - HierarchicalConfiguration otuConfig = cfg.configurationAt("otu"); | ||
| 110 | - boolean enabled = otuConfig.getString("administrative-state").equals("up"); | ||
| 111 | - OduSignalType signalType = otuConfig.getString("rate").equals("OTU4") ? OduSignalType.ODU4 : null; | ||
| 112 | - //Unsure how to retreive, outside knowledge it is tunable. | ||
| 113 | - boolean isTunable = true; | ||
| 114 | - OchSignal lambda = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4); | ||
| 115 | - DefaultAnnotations annotations = DefaultAnnotations.builder(). | ||
| 116 | - set(AnnotationKeys.PORT_NAME, cfg.getString("name")). | ||
| 117 | - build(); | ||
| 118 | - return ochPortDescription(portNumber, enabled, signalType, isTunable, lambda, annotations); | ||
| 119 | - } | ||
| 120 | - | ||
| 121 | - private static PortDescription parseT100OduPort(HierarchicalConfiguration cfg, long count) { | ||
| 122 | - PortNumber portNumber = PortNumber.portNumber(count); | ||
| 123 | - HierarchicalConfiguration ethernetConfig = cfg.configurationAt("ethernet"); | ||
| 124 | - boolean enabled = ethernetConfig.getString("administrative-state").equals("up"); | ||
| 125 | - //Rate is in kbps | ||
| 126 | - CltSignalType signalType = ethernetConfig.getString("rate").equals("100000000") ? | ||
| 127 | - CltSignalType.CLT_100GBE : null; | ||
| 128 | - DefaultAnnotations annotations = DefaultAnnotations.builder(). | ||
| 129 | - set(AnnotationKeys.PORT_NAME, cfg.getString("name")). | ||
| 130 | - build(); | ||
| 131 | - return oduCltPortDescription(portNumber, enabled, signalType, annotations); | ||
| 132 | - } | ||
| 133 | 71 | ||
| 134 | protected static String parseSwitchId(HierarchicalConfiguration cfg) { | 72 | protected static String parseSwitchId(HierarchicalConfiguration cfg) { |
| 135 | HierarchicalConfiguration field = | 73 | HierarchicalConfiguration field = | ... | ... |
-
Please register or login to post a comment