Committed by
Gerrit Code Review
ONOS-3754 Create driver/behavior for Ciena waveserver
Change-Id: I2e8741f0ad858eb712f7fe4f4a5fdf5e146aefd6
Showing
16 changed files
with
311 additions
and
22 deletions
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.cli.net; | ||
17 | + | ||
18 | +import org.apache.karaf.shell.commands.Argument; | ||
19 | +import org.apache.karaf.shell.commands.Command; | ||
20 | +import org.onosproject.cli.AbstractShellCommand; | ||
21 | +import org.onosproject.net.DeviceId; | ||
22 | +import org.onosproject.net.behaviour.PortDiscovery; | ||
23 | +import org.onosproject.net.driver.DriverHandler; | ||
24 | +import org.onosproject.net.driver.DriverService; | ||
25 | + | ||
26 | +/** | ||
27 | + * Command that gets the configuration of the specified type from the specified | ||
28 | + * device. If configuration cannot be retrieved it prints an error string. | ||
29 | + * | ||
30 | + * This is a temporary development tool for use until yang integration is complete. | ||
31 | + * This uses a not properly specified behavior. DO NOT USE AS AN EXAMPLE. | ||
32 | + */ | ||
33 | + | ||
34 | +@Command(scope = "onos", name = "device-ports", | ||
35 | + description = "Gets the ports of the specified device.") | ||
36 | +public class DevicePortGetterCommand extends AbstractShellCommand { | ||
37 | + | ||
38 | + @Argument(index = 0, name = "uri", description = "Device ID", | ||
39 | + required = true, multiValued = false) | ||
40 | + String uri = null; | ||
41 | + private DeviceId deviceId; | ||
42 | + | ||
43 | + @Override | ||
44 | + protected void execute() { | ||
45 | + DriverService service = get(DriverService.class); | ||
46 | + deviceId = DeviceId.deviceId(uri); | ||
47 | + DriverHandler h = service.createHandler(deviceId); | ||
48 | + PortDiscovery portConfig = h.behaviour(PortDiscovery.class); | ||
49 | + print(portConfig.getPorts().toString()); | ||
50 | + } | ||
51 | + | ||
52 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -127,6 +127,12 @@ | ... | @@ -127,6 +127,12 @@ |
127 | </completers> | 127 | </completers> |
128 | </command> | 128 | </command> |
129 | <command> | 129 | <command> |
130 | + <action class="org.onosproject.cli.net.DevicePortGetterCommand"/> | ||
131 | + <completers> | ||
132 | + <ref component-id="deviceIdCompleter"/> | ||
133 | + </completers> | ||
134 | + </command> | ||
135 | + <command> | ||
130 | <action class="org.onosproject.cli.net.DeviceRemoveCommand"/> | 136 | <action class="org.onosproject.cli.net.DeviceRemoveCommand"/> |
131 | <completers> | 137 | <completers> |
132 | <ref component-id="deviceIdCompleter"/> | 138 | <ref component-id="deviceIdCompleter"/> | ... | ... |
1 | +/* | ||
2 | + * | ||
3 | + * * Copyright 2016 Open Networking Laboratory | ||
4 | + * * | ||
5 | + * * Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | + * * you may not use this file except in compliance with the License. | ||
7 | + * * You may obtain a copy of the License at | ||
8 | + * * | ||
9 | + * * http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | + * * | ||
11 | + * * Unless required by applicable law or agreed to in writing, software | ||
12 | + * * distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | + * * See the License for the specific language governing permissions and | ||
15 | + * * limitations under the License. | ||
16 | + * | ||
17 | + */ | ||
18 | + | ||
19 | +package org.onosproject.net.behaviour; | ||
20 | + | ||
21 | +import org.onosproject.net.device.PortDescription; | ||
22 | +import org.onosproject.net.driver.HandlerBehaviour; | ||
23 | + | ||
24 | +import java.util.List; | ||
25 | + | ||
26 | +/** | ||
27 | + * Discovers the set of ports from a device through a device specific protocol. | ||
28 | + * The returned ports are not retrieved from the information stored in ONOS. | ||
29 | + */ | ||
30 | +public interface PortDiscovery extends HandlerBehaviour { | ||
31 | + | ||
32 | + /** | ||
33 | + * Retrieves the set of ports from a device. | ||
34 | + * @return a set of port descriptions. | ||
35 | + */ | ||
36 | + List<PortDescription> getPorts(); | ||
37 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -25,5 +25,7 @@ | ... | @@ -25,5 +25,7 @@ |
25 | <bundle>mvn:${project.groupId}/onos-ovsdb-rfc/${project.version}</bundle> | 25 | <bundle>mvn:${project.groupId}/onos-ovsdb-rfc/${project.version}</bundle> |
26 | 26 | ||
27 | <bundle>mvn:${project.groupId}/onos-netconf-api/${project.version}</bundle> | 27 | <bundle>mvn:${project.groupId}/onos-netconf-api/${project.version}</bundle> |
28 | + | ||
29 | + <bundle>mvn:${project.groupId}/onos-restsb-api/${project.version}</bundle> | ||
28 | </feature> | 30 | </feature> |
29 | </features> | 31 | </features> | ... | ... |
... | @@ -69,6 +69,11 @@ | ... | @@ -69,6 +69,11 @@ |
69 | </dependency> | 69 | </dependency> |
70 | <dependency> | 70 | <dependency> |
71 | <groupId>org.onosproject</groupId> | 71 | <groupId>org.onosproject</groupId> |
72 | + <artifactId>onos-restsb-api</artifactId> | ||
73 | + <version>${project.version}</version> | ||
74 | + </dependency> | ||
75 | + <dependency> | ||
76 | + <groupId>org.onosproject</groupId> | ||
72 | <artifactId>onos-netconf-api</artifactId> | 77 | <artifactId>onos-netconf-api</artifactId> |
73 | <version>${project.version}</version> | 78 | <version>${project.version}</version> |
74 | </dependency> | 79 | </dependency> | ... | ... |
... | @@ -14,14 +14,23 @@ | ... | @@ -14,14 +14,23 @@ |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | -package org.onosproject.driver.netconf; | 17 | +package org.onosproject.driver; |
18 | 18 | ||
19 | +import com.google.common.collect.Lists; | ||
19 | import org.apache.commons.configuration.ConfigurationException; | 20 | import org.apache.commons.configuration.ConfigurationException; |
20 | import org.apache.commons.configuration.HierarchicalConfiguration; | 21 | import org.apache.commons.configuration.HierarchicalConfiguration; |
21 | import org.apache.commons.configuration.XMLConfiguration; | 22 | import org.apache.commons.configuration.XMLConfiguration; |
22 | import org.apache.commons.configuration.tree.ConfigurationNode; | 23 | import org.apache.commons.configuration.tree.ConfigurationNode; |
23 | import org.onlab.packet.IpAddress; | 24 | import org.onlab.packet.IpAddress; |
25 | +import org.onosproject.net.ChannelSpacing; | ||
26 | +import org.onosproject.net.GridType; | ||
27 | +import org.onosproject.net.OchSignal; | ||
28 | +import org.onosproject.net.OduSignalType; | ||
29 | +import org.onosproject.net.PortNumber; | ||
30 | +import org.onosproject.net.SparseAnnotations; | ||
24 | import org.onosproject.net.behaviour.ControllerInfo; | 31 | import org.onosproject.net.behaviour.ControllerInfo; |
32 | +import org.onosproject.net.device.OchPortDescription; | ||
33 | +import org.onosproject.net.device.PortDescription; | ||
25 | import org.slf4j.Logger; | 34 | import org.slf4j.Logger; |
26 | import org.slf4j.LoggerFactory; | 35 | import org.slf4j.LoggerFactory; |
27 | 36 | ||
... | @@ -33,7 +42,7 @@ import java.util.List; | ... | @@ -33,7 +42,7 @@ import java.util.List; |
33 | /** | 42 | /** |
34 | * Parser for Netconf XML configurations and replys. | 43 | * Parser for Netconf XML configurations and replys. |
35 | */ | 44 | */ |
36 | -final class XmlConfigParser { | 45 | +public final class XmlConfigParser { |
37 | public static final Logger log = LoggerFactory | 46 | public static final Logger log = LoggerFactory |
38 | .getLogger(XmlConfigParser.class); | 47 | .getLogger(XmlConfigParser.class); |
39 | 48 | ||
... | @@ -42,7 +51,7 @@ final class XmlConfigParser { | ... | @@ -42,7 +51,7 @@ final class XmlConfigParser { |
42 | } | 51 | } |
43 | 52 | ||
44 | 53 | ||
45 | - protected static HierarchicalConfiguration loadXml(InputStream xmlStream) { | 54 | + public static HierarchicalConfiguration loadXml(InputStream xmlStream) { |
46 | XMLConfiguration cfg = new XMLConfiguration(); | 55 | XMLConfiguration cfg = new XMLConfiguration(); |
47 | try { | 56 | try { |
48 | cfg.load(xmlStream); | 57 | cfg.load(xmlStream); |
... | @@ -52,7 +61,7 @@ final class XmlConfigParser { | ... | @@ -52,7 +61,7 @@ final class XmlConfigParser { |
52 | } | 61 | } |
53 | } | 62 | } |
54 | 63 | ||
55 | - protected static List<ControllerInfo> parseStreamControllers(HierarchicalConfiguration cfg) { | 64 | + public static List<ControllerInfo> parseStreamControllers(HierarchicalConfiguration cfg) { |
56 | List<ControllerInfo> controllers = new ArrayList<>(); | 65 | List<ControllerInfo> controllers = new ArrayList<>(); |
57 | List<HierarchicalConfiguration> fields = | 66 | List<HierarchicalConfiguration> fields = |
58 | cfg.configurationsAt("data.capable-switch." + | 67 | cfg.configurationsAt("data.capable-switch." + |
... | @@ -67,7 +76,7 @@ final class XmlConfigParser { | ... | @@ -67,7 +76,7 @@ final class XmlConfigParser { |
67 | return controllers; | 76 | return controllers; |
68 | } | 77 | } |
69 | 78 | ||
70 | - protected static String parseSwitchId(HierarchicalConfiguration cfg) { | 79 | + public static String parseSwitchId(HierarchicalConfiguration cfg) { |
71 | HierarchicalConfiguration field = | 80 | HierarchicalConfiguration field = |
72 | cfg.configurationAt("data.capable-switch." + | 81 | cfg.configurationAt("data.capable-switch." + |
73 | "logical-switches." + | 82 | "logical-switches." + |
... | @@ -75,13 +84,13 @@ final class XmlConfigParser { | ... | @@ -75,13 +84,13 @@ final class XmlConfigParser { |
75 | return field.getProperty("id").toString(); | 84 | return field.getProperty("id").toString(); |
76 | } | 85 | } |
77 | 86 | ||
78 | - protected static String parseCapableSwitchId(HierarchicalConfiguration cfg) { | 87 | + public static String parseCapableSwitchId(HierarchicalConfiguration cfg) { |
79 | HierarchicalConfiguration field = | 88 | HierarchicalConfiguration field = |
80 | cfg.configurationAt("data.capable-switch"); | 89 | cfg.configurationAt("data.capable-switch"); |
81 | return field.getProperty("id").toString(); | 90 | return field.getProperty("id").toString(); |
82 | } | 91 | } |
83 | 92 | ||
84 | - protected static String createControllersConfig(HierarchicalConfiguration cfg, | 93 | + public static String createControllersConfig(HierarchicalConfiguration cfg, |
85 | HierarchicalConfiguration actualCfg, | 94 | HierarchicalConfiguration actualCfg, |
86 | String target, String netconfOperation, | 95 | String target, String netconfOperation, |
87 | String controllerOperation, | 96 | String controllerOperation, |
... | @@ -122,5 +131,44 @@ final class XmlConfigParser { | ... | @@ -122,5 +131,44 @@ final class XmlConfigParser { |
122 | 131 | ||
123 | } | 132 | } |
124 | 133 | ||
134 | + public static List<HierarchicalConfiguration> parseWaveServerCienaPorts(HierarchicalConfiguration cfg) { | ||
135 | + return cfg.configurationsAt("ws-ports.port-interface"); | ||
136 | + } | ||
137 | + | ||
138 | + public static PortDescription parseWaveServerCienaOCHPorts(long portNumber, long oduPortSpeed, | ||
139 | + HierarchicalConfiguration config, | ||
140 | + SparseAnnotations annotations) { | ||
141 | + final List<String> tunableType = Lists.newArrayList("Performance-Optimized", "Accelerated"); | ||
142 | + final String transmitterPath = "ptp-config.transmitter-state"; | ||
143 | + final String tunablePath = "ptp-config.adv-config.tx-tuning-mode"; | ||
144 | + final String gridTypePath = "ptp-config.adv-config.wl-spacing"; | ||
145 | + final String frequencyPath = "ptp-config.adv-config.frequency"; | ||
146 | + | ||
147 | + boolean isEnabled = config.getString(transmitterPath).equals("enabled"); | ||
148 | + boolean isTunable = tunableType.contains(config.getString(tunablePath)); | ||
149 | + | ||
150 | + //FIXME change when all optical types have two way information methods, see jira tickets | ||
151 | + final int speed100GbpsinMbps = 100000; | ||
152 | + OduSignalType oduSignalType = oduPortSpeed == speed100GbpsinMbps ? OduSignalType.ODU4 : null; | ||
153 | + GridType gridType = config.getString(gridTypePath).equals("FlexGrid") ? GridType.FLEX : null; | ||
154 | + ChannelSpacing chSpacing = gridType == GridType.FLEX ? ChannelSpacing.CHL_6P25GHZ : null; | ||
155 | + | ||
156 | + //Working in Ghz //(Nominal central frequency - 193.1)/channelSpacing = spacingMultiplier | ||
157 | + final int baseFrequency = 193100; | ||
158 | + int spacingMult = (int) (toGbps((Integer.parseInt(config.getString(frequencyPath)) - | ||
159 | + baseFrequency)) / toGbpsFromHz(chSpacing.frequency().asHz())); //FIXME is there a better way ? | ||
160 | + | ||
161 | + return new OchPortDescription(PortNumber.portNumber(portNumber), isEnabled, oduSignalType, isTunable, | ||
162 | + new OchSignal(gridType, chSpacing, spacingMult, 1), annotations); | ||
163 | + } | ||
164 | + | ||
165 | + //FIXME remove when all optical types have two way information methods, see jira tickets | ||
166 | + private static long toGbps(long speed) { | ||
167 | + return speed * 1000; | ||
168 | + } | ||
169 | + | ||
170 | + private static long toGbpsFromHz(long speed) { | ||
171 | + return speed / 1000; | ||
172 | + } | ||
125 | //TODO implement mor methods for parsing configuration when you need them | 173 | //TODO implement mor methods for parsing configuration when you need them |
126 | } | 174 | } | ... | ... |
... | @@ -17,6 +17,7 @@ | ... | @@ -17,6 +17,7 @@ |
17 | package org.onosproject.driver.netconf; | 17 | package org.onosproject.driver.netconf; |
18 | 18 | ||
19 | import com.google.common.base.Preconditions; | 19 | import com.google.common.base.Preconditions; |
20 | +import org.onosproject.driver.XmlConfigParser; | ||
20 | import org.onosproject.net.DeviceId; | 21 | import org.onosproject.net.DeviceId; |
21 | import org.onosproject.net.behaviour.ControllerConfig; | 22 | import org.onosproject.net.behaviour.ControllerConfig; |
22 | import org.onosproject.net.behaviour.ControllerInfo; | 23 | import org.onosproject.net.behaviour.ControllerInfo; | ... | ... |
1 | +/* | ||
2 | + * | ||
3 | + * * Copyright 2016 Open Networking Laboratory | ||
4 | + * * | ||
5 | + * * Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | + * * you may not use this file except in compliance with the License. | ||
7 | + * * You may obtain a copy of the License at | ||
8 | + * * | ||
9 | + * * http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | + * * | ||
11 | + * * Unless required by applicable law or agreed to in writing, software | ||
12 | + * * distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | + * * See the License for the specific language governing permissions and | ||
15 | + * * limitations under the License. | ||
16 | + * | ||
17 | + */ | ||
18 | + | ||
19 | +package org.onosproject.driver.rest; | ||
20 | + | ||
21 | +import com.google.common.collect.Lists; | ||
22 | +import org.apache.commons.configuration.HierarchicalConfiguration; | ||
23 | +import org.onosproject.driver.XmlConfigParser; | ||
24 | +import org.onosproject.net.AnnotationKeys; | ||
25 | +import org.onosproject.net.CltSignalType; | ||
26 | +import org.onosproject.net.DefaultAnnotations; | ||
27 | +import org.onosproject.net.DeviceId; | ||
28 | +import org.onosproject.net.PortNumber; | ||
29 | +import org.onosproject.net.SparseAnnotations; | ||
30 | +import org.onosproject.net.behaviour.PortDiscovery; | ||
31 | +import org.onosproject.net.device.OduCltPortDescription; | ||
32 | +import org.onosproject.net.device.PortDescription; | ||
33 | +import org.onosproject.net.driver.AbstractHandlerBehaviour; | ||
34 | +import org.onosproject.net.driver.DriverHandler; | ||
35 | +import org.onosproject.protocol.rest.RestSBController; | ||
36 | + | ||
37 | +import java.util.ArrayList; | ||
38 | +import java.util.List; | ||
39 | + | ||
40 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
41 | + | ||
42 | +/** | ||
43 | + * Discovers the ports from a Ciena WaveServer Rest device. | ||
44 | + */ | ||
45 | +public class PortDiscoveryCienaWaveserverImpl extends AbstractHandlerBehaviour | ||
46 | + implements PortDiscovery { | ||
47 | + | ||
48 | + private static final String SPEED = "speed"; | ||
49 | + private static final String GBPS = "Gbps"; | ||
50 | + private static final String PORT_ID = "port-id"; | ||
51 | + private static final String XML = "xml"; | ||
52 | + private static final String ENABLED = "enabled"; | ||
53 | + private static final String EMPTY_STRING = ""; | ||
54 | + private static final String NAME = "name"; | ||
55 | + private static final String ADMIN_STATE = "admin-state"; | ||
56 | + | ||
57 | + private static final ArrayList<String> LINESIDE = Lists.newArrayList( | ||
58 | + "1.1", "1.2", "12.1", "12.2"); | ||
59 | + | ||
60 | + private static final String GENERAL_PORT_REQUEST = | ||
61 | + "yang-api/datastore/ws-ports?config=true&format=xml&depth=unbounded"; | ||
62 | + private static final String SPECIFIC_PORT_PATH = "yang-api/datastore/ws-ptps/ptp/"; | ||
63 | + private static final String SPECIFIC_PORT_CONFIG = | ||
64 | + "/ptp-config?config=true&format=xml&depth=unbounded"; | ||
65 | + | ||
66 | + | ||
67 | + @Override | ||
68 | + public List<PortDescription> getPorts() { | ||
69 | + List<PortDescription> ports = Lists.newArrayList(); | ||
70 | + DriverHandler handler = handler(); | ||
71 | + RestSBController controller = checkNotNull(handler.get(RestSBController.class)); | ||
72 | + DeviceId deviceId = handler.data().deviceId(); | ||
73 | + | ||
74 | + | ||
75 | + HierarchicalConfiguration config = XmlConfigParser. | ||
76 | + loadXml(controller.get(deviceId, GENERAL_PORT_REQUEST, XML)); | ||
77 | + List<HierarchicalConfiguration> portsConfig = | ||
78 | + XmlConfigParser.parseWaveServerCienaPorts(config); | ||
79 | + | ||
80 | + portsConfig.stream().forEach(sub -> { | ||
81 | + String name = sub.getString(NAME); | ||
82 | + SparseAnnotations annotations = DefaultAnnotations.builder() | ||
83 | + .set(AnnotationKeys.NAME, String.valueOf(name)).build(); | ||
84 | + if (LINESIDE.contains(name)) { | ||
85 | + String wsportInfoRequest = SPECIFIC_PORT_PATH + sub.getLong(PORT_ID) + | ||
86 | + SPECIFIC_PORT_CONFIG; | ||
87 | + ports.add(XmlConfigParser.parseWaveServerCienaOCHPorts( | ||
88 | + sub.getLong(PORT_ID), | ||
89 | + toGbps(Long.parseLong(sub.getString(SPEED).replace(GBPS, EMPTY_STRING))), | ||
90 | + XmlConfigParser.loadXml(controller.get(deviceId, wsportInfoRequest, XML)), | ||
91 | + annotations)); | ||
92 | + } else { | ||
93 | + //FIXME change when all optical types have two way information methods, see jira tickets | ||
94 | + final int speed100GbpsinMbps = 100000; | ||
95 | + CltSignalType cltType = toGbps(Long.parseLong( | ||
96 | + sub.getString(SPEED).replace(GBPS, EMPTY_STRING))) == speed100GbpsinMbps ? | ||
97 | + CltSignalType.CLT_100GBE : null; | ||
98 | + ports.add(new OduCltPortDescription(PortNumber.portNumber(sub.getLong(PORT_ID)), | ||
99 | + sub.getString(ADMIN_STATE).equals(ENABLED), | ||
100 | + cltType, annotations)); | ||
101 | + } | ||
102 | + }); | ||
103 | + return ports; | ||
104 | + } | ||
105 | + | ||
106 | + //FIXME remove when all optical types have two way information methods, see jira tickets | ||
107 | + private long toGbps(long speed) { | ||
108 | + return speed * 1000; | ||
109 | + } | ||
110 | +} | ||
111 | + |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +/** | ||
18 | + * Implementations of the REST driver behaviours. | ||
19 | + */ | ||
20 | +package org.onosproject.driver.rest; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -128,7 +128,9 @@ | ... | @@ -128,7 +128,9 @@ |
128 | <behaviour api="org.onosproject.net.behaviour.Pipeliner" | 128 | <behaviour api="org.onosproject.net.behaviour.Pipeliner" |
129 | impl="org.onosproject.driver.pipeline.OltPipeline"/> | 129 | impl="org.onosproject.driver.pipeline.OltPipeline"/> |
130 | </driver> | 130 | </driver> |
131 | - <driver name="rest" manufacturer="" hwVersion="" swVersion=""> | 131 | + <driver name="restCiena" manufacturer="Ciena" hwVersion="1.0.0" swVersion="1.0.0"> |
132 | + <behaviour api="org.onosproject.net.behaviour.PortDiscovery" | ||
133 | + impl="org.onosproject.driver.rest.PortDiscoveryCienaWaveserverImpl"/> | ||
132 | </driver> | 134 | </driver> |
133 | <!-- The SoftRouter driver is meant to be used by any software/NPU based | 135 | <!-- The SoftRouter driver is meant to be used by any software/NPU based |
134 | ~ switch that wishes to implement a simple 2-table router. To use this | 136 | ~ switch that wishes to implement a simple 2-table router. To use this | ... | ... |
... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | -package org.onosproject.driver.netconf; | 17 | +package org.onosproject.driver; |
18 | 18 | ||
19 | import org.junit.Test; | 19 | import org.junit.Test; |
20 | import org.onlab.packet.IpAddress; | 20 | import org.onlab.packet.IpAddress; |
... | @@ -27,9 +27,7 @@ import java.util.Arrays; | ... | @@ -27,9 +27,7 @@ import java.util.Arrays; |
27 | import java.util.List; | 27 | import java.util.List; |
28 | 28 | ||
29 | import static org.junit.Assert.assertTrue; | 29 | import static org.junit.Assert.assertTrue; |
30 | -import static org.onosproject.driver.netconf.XmlConfigParser.*; | 30 | +import static org.onosproject.driver.XmlConfigParser.*; |
31 | - | ||
32 | -//import static org.junit.Assert.*; | ||
33 | 31 | ||
34 | /** | 32 | /** |
35 | * Test the XML document Parsing for netconf configuration. | 33 | * Test the XML document Parsing for netconf configuration. | ... | ... |
... | @@ -128,6 +128,7 @@ public class RestSBControllerImpl implements RestSBController { | ... | @@ -128,6 +128,7 @@ public class RestSBControllerImpl implements RestSBController { |
128 | 128 | ||
129 | @Override | 129 | @Override |
130 | public boolean put(DeviceId device, String request, InputStream payload, String mediaType) { | 130 | public boolean put(DeviceId device, String request, InputStream payload, String mediaType) { |
131 | + | ||
131 | WebResource webResource = getWebResource(device, request); | 132 | WebResource webResource = getWebResource(device, request); |
132 | ClientResponse response = null; | 133 | ClientResponse response = null; |
133 | if (payload != null) { | 134 | if (payload != null) { | ... | ... |
... | @@ -31,6 +31,7 @@ import org.onosproject.net.Device; | ... | @@ -31,6 +31,7 @@ import org.onosproject.net.Device; |
31 | import org.onosproject.net.DeviceId; | 31 | import org.onosproject.net.DeviceId; |
32 | import org.onosproject.net.MastershipRole; | 32 | import org.onosproject.net.MastershipRole; |
33 | import org.onosproject.net.SparseAnnotations; | 33 | import org.onosproject.net.SparseAnnotations; |
34 | +import org.onosproject.net.behaviour.PortDiscovery; | ||
34 | import org.onosproject.net.config.ConfigFactory; | 35 | import org.onosproject.net.config.ConfigFactory; |
35 | import org.onosproject.net.config.NetworkConfigEvent; | 36 | import org.onosproject.net.config.NetworkConfigEvent; |
36 | import org.onosproject.net.config.NetworkConfigListener; | 37 | import org.onosproject.net.config.NetworkConfigListener; |
... | @@ -40,7 +41,8 @@ import org.onosproject.net.device.DeviceDescription; | ... | @@ -40,7 +41,8 @@ import org.onosproject.net.device.DeviceDescription; |
40 | import org.onosproject.net.device.DeviceProvider; | 41 | import org.onosproject.net.device.DeviceProvider; |
41 | import org.onosproject.net.device.DeviceProviderRegistry; | 42 | import org.onosproject.net.device.DeviceProviderRegistry; |
42 | import org.onosproject.net.device.DeviceProviderService; | 43 | import org.onosproject.net.device.DeviceProviderService; |
43 | -import org.onosproject.net.device.PortDescription; | 44 | +import org.onosproject.net.driver.DriverHandler; |
45 | +import org.onosproject.net.driver.DriverService; | ||
44 | import org.onosproject.net.provider.AbstractProvider; | 46 | import org.onosproject.net.provider.AbstractProvider; |
45 | import org.onosproject.net.provider.ProviderId; | 47 | import org.onosproject.net.provider.ProviderId; |
46 | import org.onosproject.protocol.rest.RestSBController; | 48 | import org.onosproject.protocol.rest.RestSBController; |
... | @@ -51,7 +53,6 @@ import java.io.IOException; | ... | @@ -51,7 +53,6 @@ import java.io.IOException; |
51 | import java.net.HttpURLConnection; | 53 | import java.net.HttpURLConnection; |
52 | import java.net.URL; | 54 | import java.net.URL; |
53 | import java.util.HashSet; | 55 | import java.util.HashSet; |
54 | -import java.util.List; | ||
55 | import java.util.Set; | 56 | import java.util.Set; |
56 | 57 | ||
57 | import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_ADDED; | 58 | import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_ADDED; |
... | @@ -84,6 +85,9 @@ public class RestDeviceProvider extends AbstractProvider | ... | @@ -84,6 +85,9 @@ public class RestDeviceProvider extends AbstractProvider |
84 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 85 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
85 | protected CoreService coreService; | 86 | protected CoreService coreService; |
86 | 87 | ||
88 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
89 | + protected DriverService driverService; | ||
90 | + | ||
87 | 91 | ||
88 | private DeviceProviderService providerService; | 92 | private DeviceProviderService providerService; |
89 | protected static final String ISNOTNULL = "Rest device is not null"; | 93 | protected static final String ISNOTNULL = "Rest device is not null"; |
... | @@ -170,11 +174,6 @@ public class RestDeviceProvider extends AbstractProvider | ... | @@ -170,11 +174,6 @@ public class RestDeviceProvider extends AbstractProvider |
170 | controller.addDevice(nodeId); | 174 | controller.addDevice(nodeId); |
171 | } | 175 | } |
172 | 176 | ||
173 | - private void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) { | ||
174 | - // TODO get driver and call behavior to get ports | ||
175 | - //signal the ports to onos | ||
176 | - } | ||
177 | - | ||
178 | //when do I call it ? | 177 | //when do I call it ? |
179 | public void deviceRemoved(RestSBDevice nodeId) { | 178 | public void deviceRemoved(RestSBDevice nodeId) { |
180 | Preconditions.checkNotNull(nodeId, ISNOTNULL); | 179 | Preconditions.checkNotNull(nodeId, ISNOTNULL); |
... | @@ -204,8 +203,15 @@ public class RestDeviceProvider extends AbstractProvider | ... | @@ -204,8 +203,15 @@ public class RestDeviceProvider extends AbstractProvider |
204 | log.error("Configuration error {}", e); | 203 | log.error("Configuration error {}", e); |
205 | } | 204 | } |
206 | log.info("REST Devices {}", controller.getDevices()); | 205 | log.info("REST Devices {}", controller.getDevices()); |
207 | - //TODO ask for ports then call update ports. | 206 | + controller.getDevices().keySet().forEach(deviceId -> { |
208 | - | 207 | + DriverHandler h = driverService.createHandler(deviceId); |
208 | + PortDiscovery portConfig = h.behaviour(PortDiscovery.class); | ||
209 | + if (portConfig != null) { | ||
210 | + providerService.updatePorts(deviceId, portConfig.getPorts()); | ||
211 | + } else { | ||
212 | + log.warn("No portGetter behaviour for device {}", deviceId); | ||
213 | + } | ||
214 | + }); | ||
209 | } | 215 | } |
210 | 216 | ||
211 | private boolean testDeviceConnection(RestSBDevice device) { | 217 | private boolean testDeviceConnection(RestSBDevice device) { | ... | ... |
-
Please register or login to post a comment