Committed by
Gerrit Code Review
[ONOS-3253/3144] Insert support for Netconf device configuration, set and get controllers commands
Change-Id: I99188aa18207b9d0b0d935b9f9e61e547f4ddab1
Showing
33 changed files
with
1300 additions
and
184 deletions
... | @@ -59,8 +59,11 @@ public class DeviceSetControllersCommand extends AbstractShellCommand { | ... | @@ -59,8 +59,11 @@ public class DeviceSetControllersCommand extends AbstractShellCommand { |
59 | ControllerConfig config = h.behaviour(ControllerConfig.class); | 59 | ControllerConfig config = h.behaviour(ControllerConfig.class); |
60 | print("before:"); | 60 | print("before:"); |
61 | config.getControllers().forEach(c -> print(c.target())); | 61 | config.getControllers().forEach(c -> print(c.target())); |
62 | - | 62 | + try { |
63 | - config.setControllers(newControllers); | 63 | + config.setControllers(newControllers); |
64 | + } catch (NullPointerException e) { | ||
65 | + print("No Device with requested parameters {} ", uri); | ||
66 | + } | ||
64 | print("after:"); | 67 | print("after:"); |
65 | config.getControllers().forEach(c -> print(c.target())); | 68 | config.getControllers().forEach(c -> print(c.target())); |
66 | print("size %d", config.getControllers().size()); | 69 | print("size %d", config.getControllers().size()); | ... | ... |
... | @@ -24,5 +24,7 @@ | ... | @@ -24,5 +24,7 @@ |
24 | 24 | ||
25 | <bundle>mvn:${project.groupId}/onos-ovsdb-api/${project.version}</bundle> | 25 | <bundle>mvn:${project.groupId}/onos-ovsdb-api/${project.version}</bundle> |
26 | <bundle>mvn:${project.groupId}/onos-ovsdb-rfc/${project.version}</bundle> | 26 | <bundle>mvn:${project.groupId}/onos-ovsdb-rfc/${project.version}</bundle> |
27 | + | ||
28 | + <bundle>mvn:${project.groupId}/onos-netconf-api/${project.version}</bundle> | ||
27 | </feature> | 29 | </feature> |
28 | </features> | 30 | </features> | ... | ... |
... | @@ -67,6 +67,11 @@ | ... | @@ -67,6 +67,11 @@ |
67 | <artifactId>easymock</artifactId> | 67 | <artifactId>easymock</artifactId> |
68 | <scope>test</scope> | 68 | <scope>test</scope> |
69 | </dependency> | 69 | </dependency> |
70 | + <dependency> | ||
71 | + <groupId>org.onosproject</groupId> | ||
72 | + <artifactId>onos-netconf-api</artifactId> | ||
73 | + <version>${project.version}</version> | ||
74 | + </dependency> | ||
70 | 75 | ||
71 | <dependency> | 76 | <dependency> |
72 | <groupId>org.apache.felix</groupId> | 77 | <groupId>org.apache.felix</groupId> | ... | ... |
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 | + | ||
17 | +package org.onosproject.driver.netconf; | ||
18 | + | ||
19 | +import com.google.common.base.Preconditions; | ||
20 | +import org.onosproject.net.DeviceId; | ||
21 | +import org.onosproject.net.behaviour.ControllerConfig; | ||
22 | +import org.onosproject.net.behaviour.ControllerInfo; | ||
23 | +import org.onosproject.net.driver.AbstractHandlerBehaviour; | ||
24 | +import org.onosproject.net.driver.DriverHandler; | ||
25 | +import org.onosproject.netconf.NetconfController; | ||
26 | +import org.onosproject.netconf.NetconfDevice; | ||
27 | +import org.slf4j.Logger; | ||
28 | + | ||
29 | +import java.io.ByteArrayInputStream; | ||
30 | +import java.nio.charset.StandardCharsets; | ||
31 | +import java.util.ArrayList; | ||
32 | +import java.util.List; | ||
33 | + | ||
34 | +import static org.slf4j.LoggerFactory.getLogger; | ||
35 | + | ||
36 | +/** | ||
37 | + * Implementation of controller config which allows to get and set controllers | ||
38 | + * through the Netconf protocol. | ||
39 | + */ | ||
40 | +public class NetconfControllerConfig extends AbstractHandlerBehaviour | ||
41 | + implements ControllerConfig { | ||
42 | + | ||
43 | + private final Logger log = getLogger(NetconfControllerConfig.class); | ||
44 | + | ||
45 | + @Override | ||
46 | + public List<ControllerInfo> getControllers() { | ||
47 | + DriverHandler handler = handler(); | ||
48 | + NetconfController controller = handler.get(NetconfController.class); | ||
49 | + DeviceId ofDeviceId = handler.data().deviceId(); | ||
50 | + Preconditions.checkNotNull(controller, "Netconf controller is null"); | ||
51 | + List<ControllerInfo> controllers = new ArrayList<>(); | ||
52 | + controllers.addAll(XmlConfigParser.parseStreamControllers(XmlConfigParser. | ||
53 | + loadXml(new ByteArrayInputStream(controller. | ||
54 | + getDevicesMap().get(ofDeviceId).getSession(). | ||
55 | + getConfig("running").getBytes(StandardCharsets.UTF_8))))); | ||
56 | + return controllers; | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public void setControllers(List<ControllerInfo> controllers) { | ||
61 | + DriverHandler handler = handler(); | ||
62 | + NetconfController controller = handler.get(NetconfController.class); | ||
63 | + DeviceId deviceId = handler.data().deviceId(); | ||
64 | + Preconditions.checkNotNull(controller, "Netconf controller is null"); | ||
65 | + try { | ||
66 | + NetconfDevice device = controller.getNetconfDevice(deviceId); | ||
67 | + log.warn("provider map {}", controller.getDevicesMap()); | ||
68 | + String config = XmlConfigParser.createControllersConfig( | ||
69 | + XmlConfigParser.loadXml(getClass().getResourceAsStream("controllers.xml")), | ||
70 | + XmlConfigParser.loadXml( | ||
71 | + new ByteArrayInputStream(device.getSession() | ||
72 | + .getConfig("running") | ||
73 | + .getBytes( | ||
74 | + StandardCharsets.UTF_8))), | ||
75 | + "running", "merge", "create", controllers | ||
76 | + ); | ||
77 | + device.getSession().editConfig(config.substring(config.indexOf("-->") + 3)); | ||
78 | + } catch (NullPointerException e) { | ||
79 | + log.warn("No NETCONF device with requested parameters " + e); | ||
80 | + throw new NullPointerException("No NETCONF device with requested parameters " + e); | ||
81 | + } | ||
82 | + | ||
83 | + } | ||
84 | + | ||
85 | + //TODO maybe put method getNetconfClientService like in ovsdb if we need it | ||
86 | + | ||
87 | +} | ||
88 | + | ||
89 | + |
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 | + | ||
17 | +package org.onosproject.driver.netconf; | ||
18 | + | ||
19 | +import org.apache.commons.configuration.ConfigurationException; | ||
20 | +import org.apache.commons.configuration.HierarchicalConfiguration; | ||
21 | +import org.apache.commons.configuration.XMLConfiguration; | ||
22 | +import org.apache.commons.configuration.tree.ConfigurationNode; | ||
23 | +import org.onlab.packet.IpAddress; | ||
24 | +import org.onosproject.net.behaviour.ControllerInfo; | ||
25 | +import org.slf4j.Logger; | ||
26 | +import org.slf4j.LoggerFactory; | ||
27 | + | ||
28 | +import java.io.InputStream; | ||
29 | +import java.io.StringWriter; | ||
30 | +import java.util.ArrayList; | ||
31 | +import java.util.List; | ||
32 | + | ||
33 | +/** | ||
34 | + * Parser for Netconf XML configurations and replys. | ||
35 | + */ | ||
36 | +final class XmlConfigParser { | ||
37 | + public static final Logger log = LoggerFactory | ||
38 | + .getLogger(XmlConfigParser.class); | ||
39 | + | ||
40 | + private XmlConfigParser() { | ||
41 | + //not called, preventing any allocation | ||
42 | + } | ||
43 | + | ||
44 | + | ||
45 | + protected static HierarchicalConfiguration loadXml(InputStream xmlStream) { | ||
46 | + XMLConfiguration cfg = new XMLConfiguration(); | ||
47 | + try { | ||
48 | + cfg.load(xmlStream); | ||
49 | + return cfg; | ||
50 | + } catch (ConfigurationException e) { | ||
51 | + throw new IllegalArgumentException("Cannot load xml from Stream", e); | ||
52 | + } | ||
53 | + } | ||
54 | + | ||
55 | + protected static List<ControllerInfo> parseStreamControllers(HierarchicalConfiguration cfg) { | ||
56 | + List<ControllerInfo> controllers = new ArrayList<>(); | ||
57 | + List<HierarchicalConfiguration> fields = | ||
58 | + cfg.configurationsAt("data.capable-switch." + | ||
59 | + "logical-switches." + | ||
60 | + "switch.controllers.controller"); | ||
61 | + for (HierarchicalConfiguration sub : fields) { | ||
62 | + controllers.add(new ControllerInfo( | ||
63 | + IpAddress.valueOf(sub.getString("ip-address")), | ||
64 | + Integer.parseInt(sub.getString("port")), | ||
65 | + sub.getString("protocol"))); | ||
66 | + } | ||
67 | + return controllers; | ||
68 | + } | ||
69 | + | ||
70 | + protected static String parseSwitchId(HierarchicalConfiguration cfg) { | ||
71 | + HierarchicalConfiguration field = | ||
72 | + cfg.configurationAt("data.capable-switch." + | ||
73 | + "logical-switches." + | ||
74 | + "switch"); | ||
75 | + return field.getProperty("id").toString(); | ||
76 | + } | ||
77 | + | ||
78 | + protected static String parseCapableSwitchId(HierarchicalConfiguration cfg) { | ||
79 | + HierarchicalConfiguration field = | ||
80 | + cfg.configurationAt("data.capable-switch"); | ||
81 | + return field.getProperty("id").toString(); | ||
82 | + } | ||
83 | + | ||
84 | + protected static String createControllersConfig(HierarchicalConfiguration cfg, | ||
85 | + HierarchicalConfiguration actualCfg, | ||
86 | + String target, String netconfOperation, | ||
87 | + String controllerOperation, | ||
88 | + List<ControllerInfo> controllers) { | ||
89 | + //cfg.getKeys().forEachRemaining(key -> System.out.println(key)); | ||
90 | + cfg.setProperty("edit-config.target", target); | ||
91 | + cfg.setProperty("edit-config.default-operation", netconfOperation); | ||
92 | + cfg.setProperty("edit-config.config.capable-switch.id", | ||
93 | + parseCapableSwitchId(actualCfg)); | ||
94 | + cfg.setProperty("edit-config.config.capable-switch." + | ||
95 | + "logical-switches.switch.id", parseSwitchId(actualCfg)); | ||
96 | + List<ConfigurationNode> newControllers = new ArrayList<>(); | ||
97 | + for (ControllerInfo ci : controllers) { | ||
98 | + XMLConfiguration controller = new XMLConfiguration(); | ||
99 | + controller.setRoot(new HierarchicalConfiguration.Node("controller")); | ||
100 | + String id = ci.type() + ":" + ci.ip() + ":" + ci.port(); | ||
101 | + controller.setProperty("id", id); | ||
102 | + controller.setProperty("ip-address", ci.ip()); | ||
103 | + controller.setProperty("port", ci.port()); | ||
104 | + controller.setProperty("protocol", ci.type()); | ||
105 | + newControllers.add(controller.getRootNode()); | ||
106 | + } | ||
107 | + cfg.addNodes("edit-config.config.capable-switch.logical-switches." + | ||
108 | + "switch.controllers", newControllers); | ||
109 | + XMLConfiguration editcfg = (XMLConfiguration) cfg; | ||
110 | + StringWriter stringWriter = new StringWriter(); | ||
111 | + try { | ||
112 | + editcfg.save(stringWriter); | ||
113 | + } catch (ConfigurationException e) { | ||
114 | + e.printStackTrace(); | ||
115 | + } | ||
116 | + String s = stringWriter.toString() | ||
117 | + .replaceAll("<controller>", | ||
118 | + "<controller nc:operation=\"" + controllerOperation + "\">"); | ||
119 | + s = s.replace("<target>" + target + "</target>", | ||
120 | + "<target><" + target + "/></target>"); | ||
121 | + return s; | ||
122 | + | ||
123 | + } | ||
124 | + | ||
125 | + //TODO implement mor methods for parsing configuration when you need them | ||
126 | +} |
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 | + | ||
17 | +/** | ||
18 | + * Implementations of the Netconf driver behaviours. | ||
19 | + */ | ||
20 | +package org.onosproject.driver.netconf; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -37,6 +37,13 @@ | ... | @@ -37,6 +37,13 @@ |
37 | <behaviour api="org.onosproject.net.behaviour.ExtensionResolver" | 37 | <behaviour api="org.onosproject.net.behaviour.ExtensionResolver" |
38 | impl="org.onosproject.driver.extensions.NiciraExtensionInterpreter" /> | 38 | impl="org.onosproject.driver.extensions.NiciraExtensionInterpreter" /> |
39 | </driver> | 39 | </driver> |
40 | + <driver name="ovs-netconf" extends="default" | ||
41 | + manufacturer="Nicira, Inc\." hwVersion="Open vSwitch" swVersion="2\..*"> | ||
42 | + <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver" | ||
43 | + impl="org.onosproject.driver.handshaker.NiciraSwitchHandshaker"/> | ||
44 | + <behaviour api="org.onosproject.net.behaviour.ControllerConfig" | ||
45 | + impl="org.onosproject.driver.netconf.NetconfControllerConfig"/> | ||
46 | + </driver> | ||
40 | <driver name="ovs-corsa" extends="ovs" | 47 | <driver name="ovs-corsa" extends="ovs" |
41 | manufacturer="Corsa" hwVersion="emulation" swVersion="0.0.0"> | 48 | manufacturer="Corsa" hwVersion="emulation" swVersion="0.0.0"> |
42 | <behaviour api="org.onosproject.net.behaviour.Pipeliner" | 49 | <behaviour api="org.onosproject.net.behaviour.Pipeliner" | ... | ... |
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 | + | ||
17 | +<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> | ||
18 | + <edit-config> | ||
19 | + <target> | ||
20 | + </target> | ||
21 | + <default-operation> | ||
22 | + </default-operation> | ||
23 | + <config> | ||
24 | + <capable-switch xmlns="urn:onf:config:yang"> | ||
25 | + <id></id> | ||
26 | + <logical-switches> | ||
27 | + <switch> | ||
28 | + <id></id> | ||
29 | + <controllers> | ||
30 | + </controllers> | ||
31 | + </switch> | ||
32 | + </logical-switches> | ||
33 | + </capable-switch> | ||
34 | + </config> | ||
35 | + </edit-config> | ||
36 | +</rpc> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | + | ||
17 | +package org.onosproject.driver.netconf; | ||
18 | + | ||
19 | +import org.junit.Test; | ||
20 | +import org.onlab.packet.IpAddress; | ||
21 | +import org.onosproject.net.behaviour.ControllerInfo; | ||
22 | + | ||
23 | +import java.io.IOException; | ||
24 | +import java.io.InputStream; | ||
25 | +import java.util.ArrayList; | ||
26 | +import java.util.Arrays; | ||
27 | +import java.util.List; | ||
28 | + | ||
29 | +import static org.junit.Assert.assertTrue; | ||
30 | +import static org.onosproject.driver.netconf.XmlConfigParser.*; | ||
31 | + | ||
32 | +//import static org.junit.Assert.*; | ||
33 | + | ||
34 | +/** | ||
35 | + * Test the XML document Parsing for netconf configuration. | ||
36 | + */ | ||
37 | +public class XmlConfigParserTest { | ||
38 | + | ||
39 | + | ||
40 | + @Test | ||
41 | + public void basics() throws IOException { | ||
42 | + InputStream stream = getClass().getResourceAsStream("testConfig.xml"); | ||
43 | + List<ControllerInfo> controllers = parseStreamControllers(loadXml(stream)); | ||
44 | + assertTrue(controllers.get(0).equals(new ControllerInfo( | ||
45 | + IpAddress.valueOf("10.128.12.1"), 6653, "tcp"))); | ||
46 | + assertTrue(controllers.get(1).equals(new ControllerInfo( | ||
47 | + IpAddress.valueOf("10.128.12.2"), 6654, "tcp"))); | ||
48 | + | ||
49 | + } | ||
50 | + | ||
51 | + @Test | ||
52 | + public void switchId() { | ||
53 | + InputStream stream = getClass().getResourceAsStream("testConfig.xml"); | ||
54 | + String switchId = parseSwitchId(loadXml(stream)); | ||
55 | + assertTrue(switchId.equals("ofc-bridge")); | ||
56 | + } | ||
57 | + | ||
58 | + @Test | ||
59 | + public void capableSwitchId() { | ||
60 | + InputStream stream = getClass().getResourceAsStream("testConfig.xml"); | ||
61 | + String capableSwitchId = parseCapableSwitchId(loadXml(stream)); | ||
62 | + assertTrue(capableSwitchId.equals("openvswitch")); | ||
63 | + } | ||
64 | + | ||
65 | + @Test | ||
66 | + public void controllersConfig() { | ||
67 | + InputStream streamOrig = getClass().getResourceAsStream("testConfig.xml"); | ||
68 | + InputStream streamCFG = XmlConfigParser.class | ||
69 | + .getResourceAsStream("controllers.xml"); | ||
70 | + String config = createControllersConfig(loadXml(streamCFG), | ||
71 | + loadXml(streamOrig), "running", "merge", | ||
72 | + "create", new ArrayList<>(Arrays.asList( | ||
73 | + new ControllerInfo(IpAddress.valueOf("192.168.1.1"), | ||
74 | + 5000, "tcp")))); | ||
75 | + assertTrue(config.contains("192.168.1.1")); | ||
76 | + assertTrue(config.contains("tcp")); | ||
77 | + assertTrue(config.contains("5000")); | ||
78 | + | ||
79 | + } | ||
80 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!-- | ||
3 | + ~ Copyright 2015 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 | +<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="7"> | ||
19 | + <data> | ||
20 | + <capable-switch xmlns="urn:onf:config:yang"> | ||
21 | + <id>openvswitch</id> | ||
22 | + <resources> | ||
23 | + <port> | ||
24 | + <name>ofc-bridge</name> | ||
25 | + <requested-number>666</requested-number> | ||
26 | + <configuration> | ||
27 | + <admin-state>down</admin-state> | ||
28 | + <no-receive>false</no-receive> | ||
29 | + <no-forward>false</no-forward> | ||
30 | + <no-packet-in>false</no-packet-in> | ||
31 | + </configuration> | ||
32 | + </port> | ||
33 | + </resources> | ||
34 | + <logical-switches> | ||
35 | + <switch> | ||
36 | + <id>ofc-bridge</id> | ||
37 | + <datapath-id>00:01:02:03:04:05:06:07</datapath-id> | ||
38 | + <lost-connection-behavior>failSecureMode</lost-connection-behavior> | ||
39 | + <controllers> | ||
40 | + <controller> | ||
41 | + <id>(null)</id> | ||
42 | + <ip-address>10.128.12.1</ip-address> | ||
43 | + <port>6653</port> | ||
44 | + <protocol>tcp</protocol> | ||
45 | + </controller> | ||
46 | + <controller> | ||
47 | + <id>(null)</id> | ||
48 | + <ip-address>10.128.12.2</ip-address> | ||
49 | + <port>6654</port> | ||
50 | + <protocol>tcp</protocol> | ||
51 | + </controller> | ||
52 | + </controllers> | ||
53 | + <resources> | ||
54 | + <port>ofc-bridge</port> | ||
55 | + </resources> | ||
56 | + </switch> | ||
57 | + </logical-switches> | ||
58 | + </capable-switch> | ||
59 | + </data> | ||
60 | +</rpc-reply> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -40,11 +40,6 @@ | ... | @@ -40,11 +40,6 @@ |
40 | <artifactId>netty-transport-native-epoll</artifactId> | 40 | <artifactId>netty-transport-native-epoll</artifactId> |
41 | <version>${netty4.version}</version> | 41 | <version>${netty4.version}</version> |
42 | </dependency> | 42 | </dependency> |
43 | - <dependency> | ||
44 | - <groupId>org.onosproject</groupId> | ||
45 | - <artifactId>onos-netconf-rfc</artifactId> | ||
46 | - <version>${project.version}</version> | ||
47 | - </dependency> | ||
48 | </dependencies> | 43 | </dependencies> |
49 | 44 | ||
50 | </project> | 45 | </project> | ... | ... |
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 | + | ||
17 | +package org.onosproject.netconf; | ||
18 | + | ||
19 | +import org.onlab.packet.IpAddress; | ||
20 | +import org.onosproject.net.DeviceId; | ||
21 | + | ||
22 | +import java.util.Map; | ||
23 | + | ||
24 | +/** | ||
25 | + * Abstraction of an NETCONF controller. Serves as a one stop shop for obtaining | ||
26 | + * NetconfDevice and (un)register listeners on NETCONF device events. | ||
27 | + */ | ||
28 | +public interface NetconfController { | ||
29 | + | ||
30 | + /** | ||
31 | + * Adds Device Event Listener. | ||
32 | + * | ||
33 | + * @param listener node listener | ||
34 | + */ | ||
35 | + void addDeviceListener(NetconfDeviceListener listener); | ||
36 | + | ||
37 | + /** | ||
38 | + * Removes Device Listener. | ||
39 | + * | ||
40 | + * @param listener node listener | ||
41 | + */ | ||
42 | + void removeDeviceListener(NetconfDeviceListener listener); | ||
43 | + | ||
44 | + /** | ||
45 | + * Tries to connect to a specific NETCONF device, if the connection is succesful | ||
46 | + * it creates and adds the device to the ONOS core as a NetconfDevice. | ||
47 | + * | ||
48 | + * @param deviceInfo info about the device to add | ||
49 | + * @return NetconfDevice Netconf device | ||
50 | + */ | ||
51 | + NetconfDevice connectDevice(NetconfDeviceInfo deviceInfo); | ||
52 | + | ||
53 | + /** | ||
54 | + * Removes a Netconf device. | ||
55 | + * | ||
56 | + * @param deviceInfo info about the device to remove | ||
57 | + */ | ||
58 | + void removeDevice(NetconfDeviceInfo deviceInfo); | ||
59 | + | ||
60 | + /** | ||
61 | + * Gets all the nodes information. | ||
62 | + * | ||
63 | + * @return map of devices | ||
64 | + */ | ||
65 | + Map<DeviceId, NetconfDevice> getDevicesMap(); | ||
66 | + | ||
67 | + /** | ||
68 | + * Gets a Netconf Device by node identifier. | ||
69 | + * | ||
70 | + * @param deviceInfo node identifier | ||
71 | + * @return NetconfDevice Netconf device | ||
72 | + */ | ||
73 | + NetconfDevice getNetconfDevice(DeviceId deviceInfo); | ||
74 | + | ||
75 | + /** | ||
76 | + * Gets a Netconf Device by node identifier. | ||
77 | + * | ||
78 | + * @param ip device ip | ||
79 | + * @param port device port | ||
80 | + * @return NetconfDevice Netconf device | ||
81 | + */ | ||
82 | + NetconfDevice getNetconfDevice(IpAddress ip, int port); | ||
83 | + | ||
84 | +} |
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 | + | ||
17 | +package org.onosproject.netconf; | ||
18 | + | ||
19 | +/** | ||
20 | + * Interface representing a NETCONF device. | ||
21 | + */ | ||
22 | +public interface NetconfDevice { | ||
23 | + | ||
24 | + | ||
25 | + /** | ||
26 | + * Returns whether a device is a NETCONF device with a capabilities list | ||
27 | + * and is accessible. | ||
28 | + * | ||
29 | + * @return true if device is accessible, false otherwise | ||
30 | + */ | ||
31 | + boolean isActive(); | ||
32 | + | ||
33 | + /** | ||
34 | + * Returns a NETCONF session context for this device. | ||
35 | + * | ||
36 | + * @return netconf session | ||
37 | + */ | ||
38 | + NetconfSession getSession(); | ||
39 | + | ||
40 | + /** | ||
41 | + * Ensures that all sessions are closed. | ||
42 | + * A device cannot be used after disconnect is called. | ||
43 | + */ | ||
44 | + void disconnect(); | ||
45 | + | ||
46 | + /** | ||
47 | + * return all the info associated with this device. | ||
48 | + * @return NetconfDeviceInfo | ||
49 | + */ | ||
50 | + NetconfDeviceInfo getDeviceInfo(); | ||
51 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | + | ||
17 | +package org.onosproject.netconf; | ||
18 | + | ||
19 | +import com.google.common.base.Preconditions; | ||
20 | +import org.onlab.packet.IpAddress; | ||
21 | +import org.onosproject.net.DeviceId; | ||
22 | +import org.slf4j.Logger; | ||
23 | +import org.slf4j.LoggerFactory; | ||
24 | + | ||
25 | +import java.io.File; | ||
26 | +import java.net.URI; | ||
27 | +import java.net.URISyntaxException; | ||
28 | +import java.util.Objects; | ||
29 | + | ||
30 | +/** | ||
31 | + * Represents a Netconf device information. | ||
32 | + */ | ||
33 | +public class NetconfDeviceInfo { | ||
34 | + | ||
35 | + public static final Logger log = LoggerFactory | ||
36 | + .getLogger(NetconfDeviceInfo.class); | ||
37 | + | ||
38 | + private String name; | ||
39 | + private String password; | ||
40 | + private IpAddress ipAddress; | ||
41 | + private int port; | ||
42 | + private File keyFile; | ||
43 | + | ||
44 | + | ||
45 | + /** | ||
46 | + * Information for contacting the controller. | ||
47 | + * | ||
48 | + * @param name the connection type | ||
49 | + * @param password the password for the device | ||
50 | + * @param ipAddress the ip address | ||
51 | + * @param port the tcp port | ||
52 | + */ | ||
53 | + public NetconfDeviceInfo(String name, String password, IpAddress ipAddress, | ||
54 | + int port) { | ||
55 | + Preconditions.checkArgument(!name.equals(""), "Empty device name"); | ||
56 | + Preconditions.checkNotNull(port > 0, "Negative port"); | ||
57 | + Preconditions.checkNotNull(ipAddress, "Null ip address"); | ||
58 | + this.name = name; | ||
59 | + this.password = password; | ||
60 | + this.ipAddress = ipAddress; | ||
61 | + this.port = port; | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * Information for contacting the controller. | ||
66 | + * | ||
67 | + * @param name the connection type | ||
68 | + * @param password the password for the device | ||
69 | + * @param ipAddress the ip address | ||
70 | + * @param port the tcp port | ||
71 | + * @param keyString the string cointaing the key. | ||
72 | + */ | ||
73 | + public NetconfDeviceInfo(String name, String password, IpAddress ipAddress, | ||
74 | + int port, String keyString) { | ||
75 | + Preconditions.checkArgument(!name.equals(""), "Empty device name"); | ||
76 | + Preconditions.checkNotNull(port > 0, "Negative port"); | ||
77 | + Preconditions.checkNotNull(ipAddress, "Null ip address"); | ||
78 | + this.name = name; | ||
79 | + this.password = password; | ||
80 | + this.ipAddress = ipAddress; | ||
81 | + this.port = port; | ||
82 | + this.keyFile = new File(keyString); | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * Exposes the name of the controller. | ||
87 | + * | ||
88 | + * @return String name | ||
89 | + */ | ||
90 | + public String name() { | ||
91 | + return name; | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Exposes the password of the controller. | ||
96 | + * | ||
97 | + * @return String password | ||
98 | + */ | ||
99 | + public String password() { | ||
100 | + return password; | ||
101 | + } | ||
102 | + | ||
103 | + /** | ||
104 | + * Exposes the ip address of the controller. | ||
105 | + * | ||
106 | + * @return IpAddress ip address | ||
107 | + */ | ||
108 | + public IpAddress ip() { | ||
109 | + return ipAddress; | ||
110 | + } | ||
111 | + | ||
112 | + /** | ||
113 | + * Exposes the port of the controller. | ||
114 | + * | ||
115 | + * @return int port address | ||
116 | + */ | ||
117 | + public int port() { | ||
118 | + return port; | ||
119 | + } | ||
120 | + | ||
121 | + /** | ||
122 | + * Exposes the keyFile of the controller. | ||
123 | + * | ||
124 | + * @return int port address | ||
125 | + */ | ||
126 | + public File getKeyFile() { | ||
127 | + return keyFile; | ||
128 | + } | ||
129 | + | ||
130 | + /** | ||
131 | + * Return the info about the device in a string. | ||
132 | + * String format: "netconf:name@ip:port" | ||
133 | + * | ||
134 | + * @return String device info | ||
135 | + */ | ||
136 | + public String toString() { | ||
137 | + return "netconf:" + name + "@" + ipAddress + ":" + port; | ||
138 | + } | ||
139 | + | ||
140 | + /** | ||
141 | + * Return the DeviceId about the device containing the URI. | ||
142 | + * | ||
143 | + * @return DeviceId | ||
144 | + */ | ||
145 | + public DeviceId getDeviceId() { | ||
146 | + | ||
147 | + try { | ||
148 | + return DeviceId.deviceId(new URI(this.toString())); | ||
149 | + } catch (URISyntaxException e) { | ||
150 | + log.debug("Unable to build deviceID for device {} ", this, e); | ||
151 | + } | ||
152 | + return null; | ||
153 | + } | ||
154 | + | ||
155 | + @Override | ||
156 | + public int hashCode() { | ||
157 | + return Objects.hash(ipAddress, port, name); | ||
158 | + } | ||
159 | + | ||
160 | + @Override | ||
161 | + public boolean equals(Object toBeCompared) { | ||
162 | + if (toBeCompared instanceof NetconfDeviceInfo) { | ||
163 | + NetconfDeviceInfo netconfDeviceInfo = (NetconfDeviceInfo) toBeCompared; | ||
164 | + if (netconfDeviceInfo.name().equals(name) | ||
165 | + && netconfDeviceInfo.ip().equals(ipAddress) | ||
166 | + && netconfDeviceInfo.port() == port | ||
167 | + && netconfDeviceInfo.password().equals(password)) { | ||
168 | + return true; | ||
169 | + } | ||
170 | + } | ||
171 | + return false; | ||
172 | + } | ||
173 | +} |
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 | + | ||
17 | +package org.onosproject.netconf; | ||
18 | + | ||
19 | +/** | ||
20 | + * Allows for providers interested in node events to be notified. | ||
21 | + */ | ||
22 | +public interface NetconfDeviceListener { | ||
23 | + | ||
24 | + /** | ||
25 | + * Notifies that the node was added. | ||
26 | + * | ||
27 | + * @param nodeId the node where the event occurred | ||
28 | + */ | ||
29 | + void deviceAdded(NetconfDeviceInfo nodeId); | ||
30 | + | ||
31 | + /** | ||
32 | + * Notifies that the node was removed. | ||
33 | + * | ||
34 | + * @param nodeId the node where the event occurred | ||
35 | + */ | ||
36 | + void deviceRemoved(NetconfDeviceInfo nodeId); | ||
37 | +} |
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 | + | ||
17 | +package org.onosproject.netconf; | ||
18 | + | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +/** | ||
22 | + * NETCONF session object that allows NETCONF operations on top with the physical | ||
23 | + * device on top of an SSH connection. | ||
24 | + */ | ||
25 | +// TODO change return type of methdos to <Capability, XMLdoc, string or yang obj> | ||
26 | +public interface NetconfSession { | ||
27 | + | ||
28 | + /** | ||
29 | + * Retrives the requested configuration, different from get-config. | ||
30 | + * @param request the XML containing the request to the server. | ||
31 | + * @return device running configuration | ||
32 | + */ | ||
33 | + String get(String request); | ||
34 | + | ||
35 | + /** | ||
36 | + * Executes an RPC to the server. | ||
37 | + * @param request the XML containing the RPC for the server. | ||
38 | + * @return Server response or ERROR | ||
39 | + */ | ||
40 | + String doRPC(String request); | ||
41 | + | ||
42 | + /** | ||
43 | + * Retrives the specified configuration. | ||
44 | + * | ||
45 | + * @param targetConfiguration the type of configuration to retrieve. | ||
46 | + * @return specified configuration. | ||
47 | + */ | ||
48 | + String getConfig(String targetConfiguration); | ||
49 | + | ||
50 | + /** | ||
51 | + * Retrives part of the specivied configuration based on the filterSchema. | ||
52 | + * | ||
53 | + * @param targetConfiguration the type of configuration to retrieve. | ||
54 | + * @param configurationFilterSchema XML schema to filter the configuration | ||
55 | + * elements we are interested in | ||
56 | + * @return device running configuration. | ||
57 | + */ | ||
58 | + String getConfig(String targetConfiguration, String configurationFilterSchema); | ||
59 | + | ||
60 | + /** | ||
61 | + * Retrives part of the specified configuration based on the filterSchema. | ||
62 | + * | ||
63 | + * @param newConfiguration configuration to set | ||
64 | + * @return true if the configuration was edited correctly | ||
65 | + */ | ||
66 | + | ||
67 | + boolean editConfig(String newConfiguration); | ||
68 | + | ||
69 | + /** | ||
70 | + * Copies the new configuration, an Url or a complete configuration xml tree | ||
71 | + * to the target configuration. | ||
72 | + * The target configuration can't be the running one | ||
73 | + * | ||
74 | + * @param targetConfiguration the type of configuration to retrieve. | ||
75 | + * @param newConfiguration configuration to set | ||
76 | + * @return true if the configuration was copied correctly | ||
77 | + */ | ||
78 | + boolean copyConfig(String targetConfiguration, String newConfiguration); | ||
79 | + | ||
80 | + /** | ||
81 | + * Deletes part of the specified configuration based on the filterSchema. | ||
82 | + * | ||
83 | + * @param targetConfiguration the name of the configuration to delete | ||
84 | + * @return true if the configuration was copied correctly | ||
85 | + */ | ||
86 | + boolean deleteConfig(String targetConfiguration); | ||
87 | + | ||
88 | + /** | ||
89 | + * Locks the candidate configuration. | ||
90 | + * | ||
91 | + * @return true if successful. | ||
92 | + */ | ||
93 | + boolean lock(); | ||
94 | + | ||
95 | + /** | ||
96 | + * Unlocks the candidate configuration. | ||
97 | + * | ||
98 | + * @return true if successful. | ||
99 | + */ | ||
100 | + boolean unlock(); | ||
101 | + | ||
102 | + /** | ||
103 | + * Closes the Netconf session with the device. | ||
104 | + * the first time it tries gracefully, then kills it forcefully | ||
105 | + * @return true if closed | ||
106 | + */ | ||
107 | + boolean close(); | ||
108 | + | ||
109 | + /** | ||
110 | + * Gets the session ID of the Netconf session. | ||
111 | + * | ||
112 | + * @return Session ID as a string. | ||
113 | + */ | ||
114 | + String getSessionId(); | ||
115 | + | ||
116 | + /** | ||
117 | + * Gets the capabilities of the Netconf server associated to this session. | ||
118 | + * | ||
119 | + * @return Network capabilities as a string. | ||
120 | + */ | ||
121 | + String getServerCapabilities(); | ||
122 | + | ||
123 | + /** | ||
124 | + * Sets the device capabilities. | ||
125 | + * @param capabilities list of capabilities the device has. | ||
126 | + */ | ||
127 | + void setDeviceCapabilities(List<String> capabilities); | ||
128 | + | ||
129 | +} |
... | @@ -39,9 +39,53 @@ | ... | @@ -39,9 +39,53 @@ |
39 | <version>${project.version}</version> | 39 | <version>${project.version}</version> |
40 | </dependency> | 40 | </dependency> |
41 | <dependency> | 41 | <dependency> |
42 | - <groupId>org.onosproject</groupId> | 42 | + <groupId>ch.ethz.ganymed</groupId> |
43 | - <artifactId>onos-netconf-rfc</artifactId> | 43 | + <artifactId>ganymed-ssh2</artifactId> |
44 | - <version>${project.version}</version> | 44 | + <version>262</version> |
45 | </dependency> | 45 | </dependency> |
46 | </dependencies> | 46 | </dependencies> |
47 | + | ||
48 | + <build> | ||
49 | + <plugins> | ||
50 | + <!--plugin> | ||
51 | + <groupId>org.apache.maven.plugins</groupId> | ||
52 | + <artifactId>maven-shade-plugin</artifactId> | ||
53 | + <version>2.3</version> | ||
54 | + <configuration> | ||
55 | + <filters> | ||
56 | + <filter> | ||
57 | + <artifact>ch.ethz.ganymed:ganymed-ssh2</artifact> | ||
58 | + <includes> | ||
59 | + <include>ch/ethz/ssh2/**</include> | ||
60 | + </includes> | ||
61 | + </filter> | ||
62 | + <filter> | ||
63 | + <artifact>org.jdom:jdom2</artifact> | ||
64 | + <includes> | ||
65 | + <include>org/jdom2/**</include> | ||
66 | + </includes> | ||
67 | + </filter> | ||
68 | + </filters> | ||
69 | + </configuration> | ||
70 | + <executions> | ||
71 | + <execution> | ||
72 | + <phase>package</phase> | ||
73 | + <goals> | ||
74 | + <goal>shade</goal> | ||
75 | + </goals> | ||
76 | + </execution> | ||
77 | + </executions> | ||
78 | + </plugin--> | ||
79 | + <plugin> | ||
80 | + <groupId>org.apache.felix</groupId> | ||
81 | + <artifactId>maven-bundle-plugin</artifactId> | ||
82 | + <configuration> | ||
83 | + <instructions> | ||
84 | + <Private-Package>ch.ethz.ssh2.*</Private-Package> | ||
85 | + <Embed-Dependecy>ganymed-ssh2</Embed-Dependecy> | ||
86 | + </instructions> | ||
87 | + </configuration> | ||
88 | + </plugin> | ||
89 | + </plugins> | ||
90 | + </build> | ||
47 | </project> | 91 | </project> | ... | ... |
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 | + | ||
17 | +package org.onosproject.netconf.ctl; | ||
18 | + | ||
19 | +import org.apache.felix.scr.annotations.Activate; | ||
20 | +import org.apache.felix.scr.annotations.Component; | ||
21 | +import org.apache.felix.scr.annotations.Deactivate; | ||
22 | +import org.apache.felix.scr.annotations.Service; | ||
23 | +import org.onlab.packet.IpAddress; | ||
24 | +import org.onosproject.net.DeviceId; | ||
25 | +import org.onosproject.netconf.NetconfController; | ||
26 | +import org.onosproject.netconf.NetconfDevice; | ||
27 | +import org.onosproject.netconf.NetconfDeviceInfo; | ||
28 | +import org.onosproject.netconf.NetconfDeviceListener; | ||
29 | +import org.osgi.service.component.ComponentContext; | ||
30 | +import org.slf4j.Logger; | ||
31 | +import org.slf4j.LoggerFactory; | ||
32 | + | ||
33 | +import java.io.IOException; | ||
34 | +import java.util.Map; | ||
35 | +import java.util.Set; | ||
36 | +import java.util.concurrent.ConcurrentHashMap; | ||
37 | +import java.util.concurrent.CopyOnWriteArraySet; | ||
38 | + | ||
39 | +/** | ||
40 | + * The implementation of NetconfController. | ||
41 | + */ | ||
42 | +@Component(immediate = true) | ||
43 | +@Service | ||
44 | +public class NetconfControllerImpl implements NetconfController { | ||
45 | + | ||
46 | + public static final Logger log = LoggerFactory | ||
47 | + .getLogger(NetconfControllerImpl.class); | ||
48 | + | ||
49 | + public Map<DeviceId, NetconfDevice> netconfDeviceMap = new ConcurrentHashMap<>(); | ||
50 | + | ||
51 | + protected Set<NetconfDeviceListener> netconfDeviceListeners = new CopyOnWriteArraySet<>(); | ||
52 | + | ||
53 | + @Activate | ||
54 | + public void activate(ComponentContext context) { | ||
55 | + log.info("Started"); | ||
56 | + } | ||
57 | + | ||
58 | + @Deactivate | ||
59 | + public void deactivate() { | ||
60 | + netconfDeviceMap.clear(); | ||
61 | + log.info("Stopped"); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public void addDeviceListener(NetconfDeviceListener listener) { | ||
66 | + if (!netconfDeviceListeners.contains(listener)) { | ||
67 | + netconfDeviceListeners.add(listener); | ||
68 | + } | ||
69 | + } | ||
70 | + | ||
71 | + @Override | ||
72 | + public void removeDeviceListener(NetconfDeviceListener listener) { | ||
73 | + netconfDeviceListeners.remove(listener); | ||
74 | + } | ||
75 | + | ||
76 | + @Override | ||
77 | + public NetconfDevice getNetconfDevice(DeviceId deviceInfo) { | ||
78 | + return netconfDeviceMap.get(deviceInfo); | ||
79 | + } | ||
80 | + | ||
81 | + @Override | ||
82 | + public NetconfDevice getNetconfDevice(IpAddress ip, int port) { | ||
83 | + NetconfDevice device = null; | ||
84 | + for (DeviceId info : netconfDeviceMap.keySet()) { | ||
85 | + if (IpAddress.valueOf(info.uri().getHost()).equals(ip) && | ||
86 | + info.uri().getPort() == port) { | ||
87 | + return netconfDeviceMap.get(info); | ||
88 | + } | ||
89 | + } | ||
90 | + return device; | ||
91 | + } | ||
92 | + | ||
93 | + @Override | ||
94 | + public NetconfDevice connectDevice(NetconfDeviceInfo deviceInfo) { | ||
95 | + if (netconfDeviceMap.containsKey(deviceInfo.getDeviceId())) { | ||
96 | + log.warn("Device {} is already present"); | ||
97 | + return netconfDeviceMap.get(deviceInfo.getDeviceId()); | ||
98 | + } else { | ||
99 | + log.info("Creating NETCONF device {}", deviceInfo); | ||
100 | + return createDevice(deviceInfo); | ||
101 | + } | ||
102 | + } | ||
103 | + | ||
104 | + @Override | ||
105 | + public void removeDevice(NetconfDeviceInfo deviceInfo) { | ||
106 | + if (netconfDeviceMap.containsKey(deviceInfo.getDeviceId())) { | ||
107 | + log.warn("Device {} is not present"); | ||
108 | + } else { | ||
109 | + stopDevice(deviceInfo); | ||
110 | + } | ||
111 | + } | ||
112 | + | ||
113 | + private NetconfDevice createDevice(NetconfDeviceInfo deviceInfo) { | ||
114 | + NetconfDevice netconfDevice = null; | ||
115 | + try { | ||
116 | + netconfDevice = new NetconfDeviceImpl(deviceInfo); | ||
117 | + for (NetconfDeviceListener l : netconfDeviceListeners) { | ||
118 | + l.deviceAdded(deviceInfo); | ||
119 | + } | ||
120 | + netconfDeviceMap.put(deviceInfo.getDeviceId(), netconfDevice); | ||
121 | + } catch (IOException e) { | ||
122 | + throw new IllegalStateException("Cannot create NETCONF device " + | ||
123 | + "with device Info: " + | ||
124 | + deviceInfo + " \n" + e); | ||
125 | + } | ||
126 | + return netconfDevice; | ||
127 | + } | ||
128 | + | ||
129 | + private void stopDevice(NetconfDeviceInfo deviceInfo) { | ||
130 | + netconfDeviceMap.get(deviceInfo.getDeviceId()).disconnect(); | ||
131 | + netconfDeviceMap.remove(deviceInfo.getDeviceId()); | ||
132 | + for (NetconfDeviceListener l : netconfDeviceListeners) { | ||
133 | + l.deviceRemoved(deviceInfo); | ||
134 | + } | ||
135 | + } | ||
136 | + | ||
137 | + @Override | ||
138 | + public Map<DeviceId, NetconfDevice> getDevicesMap() { | ||
139 | + return netconfDeviceMap; | ||
140 | + } | ||
141 | + | ||
142 | + | ||
143 | +} |
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 | + | ||
17 | +package org.onosproject.netconf.ctl; | ||
18 | + | ||
19 | +import org.onosproject.netconf.NetconfDevice; | ||
20 | +import org.onosproject.netconf.NetconfDeviceInfo; | ||
21 | +import org.onosproject.netconf.NetconfSession; | ||
22 | + | ||
23 | +import java.io.IOException; | ||
24 | + | ||
25 | +/** | ||
26 | + * Implementation of a NETCONF device. | ||
27 | + */ | ||
28 | +public class NetconfDeviceImpl implements NetconfDevice { | ||
29 | + | ||
30 | + private NetconfDeviceInfo netconfDeviceInfo; | ||
31 | + private boolean deviceState = false; | ||
32 | + private NetconfSession netconfSession; | ||
33 | + //private String config; | ||
34 | + | ||
35 | + public NetconfDeviceImpl(NetconfDeviceInfo deviceInfo) throws IOException { | ||
36 | + netconfDeviceInfo = deviceInfo; | ||
37 | + try { | ||
38 | + netconfSession = new NetconfSessionImpl(netconfDeviceInfo); | ||
39 | + } catch (IOException e) { | ||
40 | + throw new IOException("Cannot create connection and session", e); | ||
41 | + } | ||
42 | + deviceState = true; | ||
43 | + //config = netconfSession.getConfig("running"); | ||
44 | + } | ||
45 | + | ||
46 | + @Override | ||
47 | + public boolean isActive() { | ||
48 | + return deviceState; | ||
49 | + } | ||
50 | + | ||
51 | + @Override | ||
52 | + public NetconfSession getSession() { | ||
53 | + return netconfSession; | ||
54 | + } | ||
55 | + | ||
56 | + @Override | ||
57 | + public void disconnect() { | ||
58 | + deviceState = false; | ||
59 | + netconfSession.close(); | ||
60 | + } | ||
61 | + | ||
62 | + @Override | ||
63 | + public NetconfDeviceInfo getDeviceInfo() { | ||
64 | + return netconfDeviceInfo; | ||
65 | + } | ||
66 | +} |
This diff is collapsed. Click to expand it.
... | @@ -27,6 +27,12 @@ | ... | @@ -27,6 +27,12 @@ |
27 | <artifactId>onos-netconf</artifactId> | 27 | <artifactId>onos-netconf</artifactId> |
28 | <packaging>pom</packaging> | 28 | <packaging>pom</packaging> |
29 | 29 | ||
30 | + <modules> | ||
31 | + <module>api</module> | ||
32 | + <module>rfc</module> | ||
33 | + <module>ctl</module> | ||
34 | + </modules> | ||
35 | + | ||
30 | <description>ONOS NETCONF southbound libraries</description> | 36 | <description>ONOS NETCONF southbound libraries</description> |
31 | <dependencies> | 37 | <dependencies> |
32 | <dependency> | 38 | <dependency> |
... | @@ -54,6 +60,11 @@ | ... | @@ -54,6 +60,11 @@ |
54 | <groupId>org.apache.felix</groupId> | 60 | <groupId>org.apache.felix</groupId> |
55 | <artifactId>org.apache.felix.scr.annotations</artifactId> | 61 | <artifactId>org.apache.felix.scr.annotations</artifactId> |
56 | </dependency> | 62 | </dependency> |
63 | + <dependency> | ||
64 | + <groupId>org.onosproject</groupId> | ||
65 | + <artifactId>onos-core-net</artifactId> | ||
66 | + <version>${project.version}</version> | ||
67 | + </dependency> | ||
57 | </dependencies> | 68 | </dependencies> |
58 | 69 | ||
59 | <build> | 70 | <build> |
... | @@ -68,10 +79,4 @@ | ... | @@ -68,10 +79,4 @@ |
68 | </plugin> | 79 | </plugin> |
69 | </plugins> | 80 | </plugins> |
70 | </build> | 81 | </build> |
71 | - | ||
72 | - <modules> | ||
73 | - <module>api</module> | ||
74 | - <module>rfc</module> | ||
75 | - <module>ctl</module> | ||
76 | - </modules> | ||
77 | </project> | 82 | </project> | ... | ... |
... | @@ -19,6 +19,13 @@ | ... | @@ -19,6 +19,13 @@ |
19 | features="${project.artifactId}"> | 19 | features="${project.artifactId}"> |
20 | <description>${project.description}</description> | 20 | <description>${project.description}</description> |
21 | 21 | ||
22 | + <artifact>mvn:${project.groupId}/onos-netconf-rfc/${project.version}</artifact> | ||
23 | + <artifact>mvn:${project.groupId}/onos-netconf-api/${project.version}</artifact> | ||
24 | + <artifact>mvn:${project.groupId}/onos-netconf-ctl/${project.version}</artifact> | ||
25 | + <artifact>mvn:${project.groupId}/onos-drivers/${project.version}</artifact> | ||
26 | + | ||
22 | <artifact>mvn:${project.groupId}/onos-netconf-provider-device/${project.version}</artifact> | 27 | <artifact>mvn:${project.groupId}/onos-netconf-provider-device/${project.version}</artifact> |
28 | + | ||
29 | + <!--<artifact>mvn:${project.groupId}/onos-netconf-provider-device/${project.version}</artifact>--> | ||
23 | <!-- Question: should there be the jnc stuff here? Or is it just for testing --> | 30 | <!-- Question: should there be the jnc stuff here? Or is it just for testing --> |
24 | </app> | 31 | </app> | ... | ... |
... | @@ -20,6 +20,9 @@ | ... | @@ -20,6 +20,9 @@ |
20 | description="${project.description}"> | 20 | description="${project.description}"> |
21 | <feature>onos-api</feature> | 21 | <feature>onos-api</feature> |
22 | <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> | 22 | <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> |
23 | + <bundle>mvn:${project.groupId}/onos-netconf-api/${project.version}</bundle> | ||
24 | + <bundle>mvn:${project.groupId}/onos-netconf-ctl/${project.version}</bundle> | ||
25 | + | ||
23 | <bundle>mvn:${project.groupId}/onos-netconf-provider-device/${project.version}</bundle> | 26 | <bundle>mvn:${project.groupId}/onos-netconf-provider-device/${project.version}</bundle> |
24 | <!-- Question: should there be the jnc stuff here? Or is it just for testing --> | 27 | <!-- Question: should there be the jnc stuff here? Or is it just for testing --> |
25 | </feature> | 28 | </feature> | ... | ... |
... | @@ -33,129 +33,29 @@ | ... | @@ -33,129 +33,29 @@ |
33 | 33 | ||
34 | <dependencies> | 34 | <dependencies> |
35 | <dependency> | 35 | <dependency> |
36 | - <groupId>org.osgi</groupId> | ||
37 | - <artifactId>org.osgi.compendium</artifactId> | ||
38 | - </dependency> | ||
39 | - <dependency> | ||
40 | - <groupId>ch.ethz.ganymed</groupId> | ||
41 | - <artifactId>ganymed-ssh2</artifactId> | ||
42 | - <version>262</version> | ||
43 | - </dependency> | ||
44 | - <dependency> | ||
45 | - <!-- TODO: change this appropriately when the official TailF JNC is available --> | ||
46 | <groupId>org.onosproject</groupId> | 36 | <groupId>org.onosproject</groupId> |
47 | - <artifactId>jnc</artifactId> | 37 | + <artifactId>onlab-junit</artifactId> |
48 | - <version>1.0</version> | 38 | + <scope>test</scope> |
49 | - </dependency> | ||
50 | - <dependency> | ||
51 | - <groupId>org.jdom</groupId> | ||
52 | - <artifactId>jdom2</artifactId> | ||
53 | - <version>2.0.5</version> | ||
54 | - </dependency> | ||
55 | - <dependency> | ||
56 | - <groupId>jaxen</groupId> | ||
57 | - <artifactId>jaxen</artifactId> | ||
58 | - <version>1.1.4</version> | ||
59 | - <optional>true</optional> | ||
60 | - </dependency> | ||
61 | - <dependency> | ||
62 | - <groupId>org.osgi</groupId> | ||
63 | - <artifactId>org.osgi.core</artifactId> | ||
64 | </dependency> | 39 | </dependency> |
65 | <dependency> | 40 | <dependency> |
66 | <groupId>org.onosproject</groupId> | 41 | <groupId>org.onosproject</groupId> |
67 | - <artifactId>onlab-junit</artifactId> | 42 | + <artifactId>onos-netconf-api</artifactId> |
68 | - <scope>test</scope> | 43 | + <version>${project.version}</version> |
69 | </dependency> | 44 | </dependency> |
70 | <dependency> | 45 | <dependency> |
71 | - <groupId>org.easymock</groupId> | 46 | + <groupId>org.onosproject</groupId> |
72 | - <artifactId>easymock</artifactId> | 47 | + <artifactId>onos-netconf-ctl</artifactId> |
73 | - <scope>test</scope> | 48 | + <version>${project.version}</version> |
74 | </dependency> | 49 | </dependency> |
75 | </dependencies> | 50 | </dependencies> |
76 | 51 | ||
77 | <build> | 52 | <build> |
78 | <plugins> | 53 | <plugins> |
79 | <plugin> | 54 | <plugin> |
80 | - <groupId>org.apache.maven.plugins</groupId> | ||
81 | - <artifactId>maven-shade-plugin</artifactId> | ||
82 | - <version>2.3</version> | ||
83 | - <configuration> | ||
84 | - <filters> | ||
85 | - <filter> | ||
86 | - <artifact>com.tailf:JNC</artifact> | ||
87 | - <includes> | ||
88 | - <include>com/tailf/jnc/**</include> | ||
89 | - </includes> | ||
90 | - </filter> | ||
91 | - <filter> | ||
92 | - <artifact>ch.ethz.ganymed:ganymed-ssh2</artifact> | ||
93 | - <includes> | ||
94 | - <include>ch/ethz/ssh2/**</include> | ||
95 | - </includes> | ||
96 | - </filter> | ||
97 | - <filter> | ||
98 | - <artifact>org.jdom:jdom2</artifact> | ||
99 | - <includes> | ||
100 | - <include>org/jdom2/**</include> | ||
101 | - </includes> | ||
102 | - </filter> | ||
103 | - </filters> | ||
104 | - </configuration> | ||
105 | - <executions> | ||
106 | - <execution> | ||
107 | - <phase>package</phase> | ||
108 | - <goals> | ||
109 | - <goal>shade</goal> | ||
110 | - </goals> | ||
111 | - </execution> | ||
112 | - </executions> | ||
113 | - </plugin> | ||
114 | - <plugin> | ||
115 | <groupId>org.apache.felix</groupId> | 55 | <groupId>org.apache.felix</groupId> |
116 | <artifactId>maven-scr-plugin</artifactId> | 56 | <artifactId>maven-scr-plugin</artifactId> |
117 | </plugin> | 57 | </plugin> |
118 | <plugin> | 58 | <plugin> |
119 | - <groupId>org.apache.felix</groupId> | ||
120 | - <artifactId>maven-bundle-plugin</artifactId> | ||
121 | - <configuration> | ||
122 | - <instructions> | ||
123 | - <Export-Package> | ||
124 | - com.tailf.jnc, | ||
125 | - ch.ethz.ssh2, | ||
126 | - ch.ethz.ssh2.auth, | ||
127 | - ch.ethz.ssh2.channel, | ||
128 | - ch.ethz.ssh2.crypto, | ||
129 | - ch.ethz.ssh2.crypto.cipher, | ||
130 | - ch.ethz.ssh2.crypto.dh, | ||
131 | - ch.ethz.ssh2.crypto.digest, | ||
132 | - ch.ethz.ssh2.log, | ||
133 | - ch.ethz.ssh2.packets, | ||
134 | - ch.ethz.ssh2.server, | ||
135 | - ch.ethz.ssh2.sftp, | ||
136 | - ch.ethz.ssh2.signature, | ||
137 | - ch.ethz.ssh2.transport, | ||
138 | - ch.ethz.ssh2.util, | ||
139 | - org.jdom2, | ||
140 | - org.jdom2.input, | ||
141 | - org.jdom2.output, | ||
142 | - org.jdom2.adapters, | ||
143 | - org.jdom2.filter, | ||
144 | - org.jdom2.internal, | ||
145 | - org.jdom2.located, | ||
146 | - org.jdom2.transform, | ||
147 | - org.jdom2.util, | ||
148 | - org.jdom2.xpath, | ||
149 | - org.jdom2.input.sax, | ||
150 | - org.jdom2.input.stax, | ||
151 | - org.jdom2.output.support, | ||
152 | - org.jdom2.xpath.jaxen, | ||
153 | - org.jdom2.xpath.util | ||
154 | - </Export-Package> | ||
155 | - </instructions> | ||
156 | - </configuration> | ||
157 | - </plugin> | ||
158 | - <plugin> | ||
159 | <groupId>org.onosproject</groupId> | 59 | <groupId>org.onosproject</groupId> |
160 | <artifactId>onos-maven-plugin</artifactId> | 60 | <artifactId>onos-maven-plugin</artifactId> |
161 | </plugin> | 61 | </plugin> | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
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 | + | ||
17 | +package org.onosproject.provider.netconf.device.impl; | ||
18 | + | ||
19 | +import com.fasterxml.jackson.databind.JsonNode; | ||
20 | +import com.google.common.annotations.Beta; | ||
21 | +import com.google.common.collect.Sets; | ||
22 | +import org.onlab.packet.IpAddress; | ||
23 | +import org.onosproject.core.ApplicationId; | ||
24 | +import org.onosproject.incubator.net.config.basics.ConfigException; | ||
25 | +import org.onosproject.net.config.Config; | ||
26 | + | ||
27 | +import java.util.Set; | ||
28 | + | ||
29 | +/** | ||
30 | + * Configuration for Netconf provider. | ||
31 | + */ | ||
32 | +@Beta | ||
33 | +public class NetconfProviderConfig extends Config<ApplicationId> { | ||
34 | + | ||
35 | + public static final String CONFIG_VALUE_ERROR = "Error parsing config value"; | ||
36 | + private static final String IP = "ip"; | ||
37 | + private static final int DEFAULT_TCP_PORT = 830; | ||
38 | + private static final String PORT = "port"; | ||
39 | + private static final String NAME = "name"; | ||
40 | + private static final String PASSWORD = "password"; | ||
41 | + | ||
42 | + public Set<NetconfDeviceAddress> getDevicesAddresses() throws ConfigException { | ||
43 | + Set<NetconfDeviceAddress> devicesAddresses = Sets.newHashSet(); | ||
44 | + | ||
45 | + try { | ||
46 | + for (JsonNode node : array) { | ||
47 | + String ip = node.path(IP).asText(); | ||
48 | + IpAddress ipAddr = ip.isEmpty() ? null : IpAddress.valueOf(ip); | ||
49 | + int port = node.path(PORT).asInt(DEFAULT_TCP_PORT); | ||
50 | + String name = node.path(NAME).asText(); | ||
51 | + String password = node.path(PASSWORD).asText(); | ||
52 | + devicesAddresses.add(new NetconfDeviceAddress(ipAddr, port, name, password)); | ||
53 | + | ||
54 | + } | ||
55 | + } catch (IllegalArgumentException e) { | ||
56 | + throw new ConfigException(CONFIG_VALUE_ERROR, e); | ||
57 | + } | ||
58 | + | ||
59 | + return devicesAddresses; | ||
60 | + } | ||
61 | + | ||
62 | + public class NetconfDeviceAddress { | ||
63 | + private final IpAddress ip; | ||
64 | + private final int port; | ||
65 | + private final String name; | ||
66 | + private final String password; | ||
67 | + | ||
68 | + public NetconfDeviceAddress(IpAddress ip, int port, String name, String password) { | ||
69 | + this.ip = ip; | ||
70 | + this.port = port; | ||
71 | + this.name = name; | ||
72 | + this.password = password; | ||
73 | + } | ||
74 | + | ||
75 | + public IpAddress ip() { | ||
76 | + return ip; | ||
77 | + } | ||
78 | + | ||
79 | + public int port() { | ||
80 | + return port; | ||
81 | + } | ||
82 | + | ||
83 | + public String name() { | ||
84 | + return name; | ||
85 | + } | ||
86 | + | ||
87 | + public String password() { | ||
88 | + return password; | ||
89 | + } | ||
90 | + } | ||
91 | + | ||
92 | + | ||
93 | +} |
This diff is collapsed. Click to expand it.
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.provider.netconf.device.impl; | ||
17 | - | ||
18 | -public final class NetconfDeviceProviderTestConstant { | ||
19 | - | ||
20 | - private NetconfDeviceProviderTestConstant() { | ||
21 | - } | ||
22 | - | ||
23 | - public static final int ZERO = 0; | ||
24 | - public static final int EVENTINTERVAL = 5; | ||
25 | - public static final String DEV_CONFIG = "devConfigs"; | ||
26 | - public static final String CONFIG_WITH_INVALID_ENTRY_NUMBER = "cisco:cisco" | ||
27 | - + "@10.18.11.14:cisco:active"; | ||
28 | - public static final String CONFIG_WITH_NULL_ENTRY = "null:null@null:0:active"; | ||
29 | - public static final String CONFIG_WITH_DIFFERENT_DEVICE_STATE = "cisco:cisco@10.18.11.14:22:active," | ||
30 | - + "cisco:cisco@10.18.11.18:22:inactive,cisco:cisco@10.18.11.14:22:invalid," | ||
31 | - + "cisco:cisco@10.18.11.14:22:null"; | ||
32 | - public static final String CONFIG_WITH_ARRAY_OUT_OF_BOUNDEX = "@10.18.11.14:22:active"; | ||
33 | - public static final String CONFIG_ENTRY_FOR_DEACTIVATE = "netconf:cisco" | ||
34 | - + "@10.18.11.14:22:active"; | ||
35 | - public static final String DEVICE_IP = "10.18.14.19"; | ||
36 | - public static final int DEVICE_PORT = 22; | ||
37 | - public static final String DEVICE_USERNAME = "cisco"; | ||
38 | - public static final String DEVICE_PASSWORD = "cisco"; | ||
39 | - public static final String AT_THE_RATE = "@"; | ||
40 | - public static final String COLON = ":"; | ||
41 | - public static final String NULL = ""; | ||
42 | - public static final String NULL_NULL = "null,null"; | ||
43 | - public static final String SCHEME_NETCONF = "netconf"; | ||
44 | - public static final String DEVICE_ID = "of:0000000000000001"; | ||
45 | - | ||
46 | -} |
tools/test/configs/netconf-cfg.json
0 → 100644
1 | +{ | ||
2 | + "devices":{ | ||
3 | + "netconf:mininet@10.1.9.24:1830":{ | ||
4 | + "basic":{ | ||
5 | + "driver":"ovs-netconf" | ||
6 | + } | ||
7 | + } | ||
8 | + }, | ||
9 | + "apps":{ | ||
10 | + "org.onosproject.netconf":{ | ||
11 | + "devices":[{ | ||
12 | + "name":"mininet", | ||
13 | + "password":"mininet", | ||
14 | + "ip":"10.1.9.24", | ||
15 | + "port":1830 | ||
16 | + }] | ||
17 | + } | ||
18 | + } | ||
19 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment