Committed by
Gerrit Code Review
[ONOS-4795] NETCONF function for FUJITSU OLT #3
[Done] - Add vOLT ponlink commands for FUJITSU OLT - Add new implementation with respect to the commands - Move those commands to Fujitsu drivers directory - Modify BUCK to avoid an error Change-Id: I7a61234e18367aa74445800dd09f98c10edc35c4
Showing
11 changed files
with
534 additions
and
13 deletions
1 | +/* | ||
2 | + * Copyright 2016-present 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.net.behaviour; | ||
17 | + | ||
18 | +import org.onosproject.net.driver.HandlerBehaviour; | ||
19 | + | ||
20 | +/** | ||
21 | + * Device behaviour to obtain and set parameters of PON links in vOLT. | ||
22 | + */ | ||
23 | +public interface VoltPonLinkConfig extends HandlerBehaviour { | ||
24 | + | ||
25 | + /** | ||
26 | + * Obtain all GPON PON links or a specific PON link in the device. | ||
27 | + * | ||
28 | + * @param target input data in string | ||
29 | + * @return response string | ||
30 | + */ | ||
31 | + String getPonLinks(String target); | ||
32 | + | ||
33 | + /** | ||
34 | + * Set a parameter value of PON link in the device. | ||
35 | + * | ||
36 | + * @param target input data in string | ||
37 | + * | ||
38 | + */ | ||
39 | + void setPonLink(String target); | ||
40 | + | ||
41 | +} |
... | @@ -2,6 +2,8 @@ COMPILE_DEPS = [ | ... | @@ -2,6 +2,8 @@ COMPILE_DEPS = [ |
2 | '//lib:CORE_DEPS', | 2 | '//lib:CORE_DEPS', |
3 | '//drivers/utilities:onos-drivers-utilities', | 3 | '//drivers/utilities:onos-drivers-utilities', |
4 | '//protocols/netconf/api:onos-protocols-netconf-api', | 4 | '//protocols/netconf/api:onos-protocols-netconf-api', |
5 | + '//lib:org.apache.karaf.shell.console', | ||
6 | + '//cli:onos-cli', | ||
5 | ] | 7 | ] |
6 | 8 | ||
7 | TEST_DEPS = [ | 9 | TEST_DEPS = [ | ... | ... |
... | @@ -52,6 +52,16 @@ | ... | @@ -52,6 +52,16 @@ |
52 | <artifactId>onos-drivers-utilities</artifactId> | 52 | <artifactId>onos-drivers-utilities</artifactId> |
53 | <version>${project.version}</version> | 53 | <version>${project.version}</version> |
54 | </dependency> | 54 | </dependency> |
55 | + <dependency> | ||
56 | + <groupId>org.onosproject</groupId> | ||
57 | + <artifactId>onos-cli</artifactId> | ||
58 | + <version>${project.version}</version> | ||
59 | + </dependency> | ||
60 | + <dependency> | ||
61 | + <groupId>org.apache.karaf.shell</groupId> | ||
62 | + <artifactId>org.apache.karaf.shell.console</artifactId> | ||
63 | + <scope>provided</scope> | ||
64 | + </dependency> | ||
55 | </dependencies> | 65 | </dependencies> |
56 | 66 | ||
57 | </project> | 67 | </project> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfig.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present 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.drivers.fujitsu; | ||
18 | + | ||
19 | +import org.onosproject.mastership.MastershipService; | ||
20 | +import org.onosproject.net.DeviceId; | ||
21 | +import org.onosproject.net.behaviour.VoltPonLinkConfig; | ||
22 | +import org.onosproject.net.driver.AbstractHandlerBehaviour; | ||
23 | +import org.onosproject.net.driver.DriverHandler; | ||
24 | +import org.onosproject.netconf.NetconfController; | ||
25 | +import org.slf4j.Logger; | ||
26 | + | ||
27 | +import java.io.IOException; | ||
28 | +import java.util.Set; | ||
29 | + | ||
30 | +import com.google.common.collect.ImmutableSet; | ||
31 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
32 | +import static org.onosproject.drivers.fujitsu.FujitsuVoltXmlUtility.*; | ||
33 | +import static org.slf4j.LoggerFactory.getLogger; | ||
34 | + | ||
35 | +/** | ||
36 | + * Implementation to get and set parameters available in vOLT | ||
37 | + * through the Netconf protocol. | ||
38 | + */ | ||
39 | +public class FujitsuVoltPonLinkConfig extends AbstractHandlerBehaviour | ||
40 | + implements VoltPonLinkConfig { | ||
41 | + | ||
42 | + private final Logger log = getLogger(FujitsuVoltPonLinkConfig.class); | ||
43 | + private final Set<String> ponLinkParams = ImmutableSet.of( | ||
44 | + "admin-state", "onu-discovery-mode", "onu-discovery-interval", | ||
45 | + "dba-cycle-time", "mac-age-time", "lof-threshold", | ||
46 | + "los-threshold", "pm-enable"); | ||
47 | + private static final String VOLT_PORTS = "volt-ports"; | ||
48 | + private static final String GPON_PONLINK_PORTS = "gpon-ponlink-ports"; | ||
49 | + private static final String GPON_PONLINK_PORT = "gpon-ponlink-port"; | ||
50 | + private int pon; | ||
51 | + | ||
52 | + @Override | ||
53 | + public String getPonLinks(String target) { | ||
54 | + DriverHandler handler = handler(); | ||
55 | + NetconfController controller = handler.get(NetconfController.class); | ||
56 | + MastershipService mastershipService = handler.get(MastershipService.class); | ||
57 | + DeviceId ncDeviceId = handler.data().deviceId(); | ||
58 | + checkNotNull(controller, "Netconf controller is null"); | ||
59 | + String reply = null; | ||
60 | + | ||
61 | + if (!mastershipService.isLocalMaster(ncDeviceId)) { | ||
62 | + log.warn("Not master for {} Use {} to execute command", | ||
63 | + ncDeviceId, | ||
64 | + mastershipService.getMasterFor(ncDeviceId)); | ||
65 | + return reply; | ||
66 | + } | ||
67 | + | ||
68 | + try { | ||
69 | + StringBuilder request = new StringBuilder(); | ||
70 | + request.append(VOLT_NE_OPEN).append(VOLT_NE_NAMESPACE); | ||
71 | + request.append(ANGLE_RIGHT).append(NEW_LINE); | ||
72 | + request.append(buildStartTag(VOLT_PORTS)); | ||
73 | + if (target != null) { | ||
74 | + try { | ||
75 | + pon = Integer.parseInt(target); | ||
76 | + } catch (NumberFormatException e) { | ||
77 | + log.error("Non-number input"); | ||
78 | + return reply; | ||
79 | + } | ||
80 | + request.append(buildStartTag(GPON_PONLINK_PORTS)); | ||
81 | + request.append(buildStartTag(GPON_PONLINK_PORT)); | ||
82 | + request.append(buildStartTag(PONLINK_ID, false)); | ||
83 | + request.append(target); | ||
84 | + request.append(buildEndTag(PONLINK_ID)); | ||
85 | + | ||
86 | + request.append(buildEndTag(GPON_PONLINK_PORT)); | ||
87 | + request.append(buildEndTag(GPON_PONLINK_PORTS)); | ||
88 | + } else { | ||
89 | + request.append(buildEmptyTag(GPON_PONLINK_PORTS)); | ||
90 | + } | ||
91 | + request.append(buildEndTag(VOLT_PORTS)); | ||
92 | + request.append(VOLT_NE_CLOSE); | ||
93 | + | ||
94 | + reply = controller. | ||
95 | + getDevicesMap().get(ncDeviceId).getSession(). | ||
96 | + get(request.toString(), REPORT_ALL); | ||
97 | + } catch (IOException e) { | ||
98 | + log.error("Cannot communicate to device {} exception ", ncDeviceId, e); | ||
99 | + } | ||
100 | + return reply; | ||
101 | + } | ||
102 | + | ||
103 | + @Override | ||
104 | + public void setPonLink(String target) { | ||
105 | + DriverHandler handler = handler(); | ||
106 | + NetconfController controller = handler.get(NetconfController.class); | ||
107 | + MastershipService mastershipService = handler.get(MastershipService.class); | ||
108 | + DeviceId ncDeviceId = handler.data().deviceId(); | ||
109 | + checkNotNull(controller, "Netconf controller is null"); | ||
110 | + | ||
111 | + if (!mastershipService.isLocalMaster(ncDeviceId)) { | ||
112 | + log.warn("Not master for {} Use {} to execute command", | ||
113 | + ncDeviceId, | ||
114 | + mastershipService.getMasterFor(ncDeviceId)); | ||
115 | + return; | ||
116 | + } | ||
117 | + | ||
118 | + String[] data = target.split(COLON); | ||
119 | + if (data.length != 3) { | ||
120 | + log.error("Invalid number of arguments"); | ||
121 | + return; | ||
122 | + } | ||
123 | + | ||
124 | + try { | ||
125 | + pon = Integer.parseInt(data[0]); | ||
126 | + } catch (NumberFormatException e) { | ||
127 | + log.error("Non-number input"); | ||
128 | + return; | ||
129 | + } | ||
130 | + | ||
131 | + if (!ponLinkParams.contains(data[1])) { | ||
132 | + log.error("Unsupported parameter: {} ", data[1]); | ||
133 | + return; | ||
134 | + } | ||
135 | + | ||
136 | + try { | ||
137 | + StringBuilder request = new StringBuilder(); | ||
138 | + request.append(VOLT_NE_OPEN).append(VOLT_NE_NAMESPACE); | ||
139 | + request.append(ANGLE_RIGHT).append(NEW_LINE); | ||
140 | + request.append(buildStartTag(VOLT_PORTS)); | ||
141 | + request.append(buildStartTag(GPON_PONLINK_PORTS)); | ||
142 | + request.append(buildStartTag(GPON_PONLINK_PORT)); | ||
143 | + request.append(buildStartTag(PONLINK_ID, false)); | ||
144 | + request.append(data[0]); | ||
145 | + request.append(buildEndTag(PONLINK_ID)); | ||
146 | + | ||
147 | + request.append(buildStartTag(data[1], false)); | ||
148 | + request.append(data[2]); | ||
149 | + request.append(buildEndTag(data[1])); | ||
150 | + | ||
151 | + request.append(buildEndTag(GPON_PONLINK_PORT)); | ||
152 | + request.append(buildEndTag(GPON_PONLINK_PORTS)); | ||
153 | + request.append(buildEndTag(VOLT_PORTS)); | ||
154 | + request.append(VOLT_NE_CLOSE); | ||
155 | + | ||
156 | + controller.getDevicesMap().get(ncDeviceId).getSession(). | ||
157 | + editConfig(RUNNING, null, request.toString()); | ||
158 | + } catch (IOException e) { | ||
159 | + log.error("Cannot communicate to device {} exception ", ncDeviceId, e); | ||
160 | + } | ||
161 | + } | ||
162 | + | ||
163 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present 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.drivers.fujitsu; | ||
18 | + | ||
19 | +/** | ||
20 | + * Defines common XML constants and methods for Fujitsu vOLT. | ||
21 | + */ | ||
22 | +public final class FujitsuVoltXmlUtility { | ||
23 | + | ||
24 | + public static final String COLON = ":"; | ||
25 | + public static final String HYPHEN = "-"; | ||
26 | + public static final String SLASH = "/"; | ||
27 | + public static final String SPACE = " "; | ||
28 | + public static final String NEW_LINE = "\n"; | ||
29 | + public static final String ANGLE_LEFT = "<"; | ||
30 | + public static final String ANGLE_RIGHT = ">"; | ||
31 | + | ||
32 | + public static final String REPORT_ALL = "report-all"; | ||
33 | + public static final String EDIT_CONFIG = "edit-config"; | ||
34 | + public static final String RUNNING = "running"; | ||
35 | + | ||
36 | + public static final String VOLT_NE_NAMESPACE = | ||
37 | + "xmlns=\"http://fujitsu.com/ns/volt/1.1\""; | ||
38 | + public static final String VOLT_NE = "volt-ne"; | ||
39 | + public static final String PONLINK_ID = "ponlink-id"; | ||
40 | + public static final String ONU_ID = "onu-id"; | ||
41 | + | ||
42 | + public static final String VOLT_NE_OPEN = ANGLE_LEFT + VOLT_NE + SPACE; | ||
43 | + public static final String VOLT_NE_CLOSE = ANGLE_LEFT + SLASH + VOLT_NE + ANGLE_RIGHT; | ||
44 | + | ||
45 | + private FujitsuVoltXmlUtility() { | ||
46 | + // Preventing any allocation | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * Builds XML start tag with name provided. | ||
51 | + * | ||
52 | + * @param name tag name | ||
53 | + * @return string | ||
54 | + */ | ||
55 | + public static String buildStartTag(String name) { | ||
56 | + return buildStartTag(name, true); | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * Builds XML end tag with name provided. | ||
61 | + * | ||
62 | + * @param name tag name | ||
63 | + * @return string | ||
64 | + */ | ||
65 | + public static String buildEndTag(String name) { | ||
66 | + return buildEndTag(name, true); | ||
67 | + } | ||
68 | + | ||
69 | + /** | ||
70 | + * Builds XML empty tag with name provided. | ||
71 | + * | ||
72 | + * @param name tag name | ||
73 | + * @return string | ||
74 | + */ | ||
75 | + public static String buildEmptyTag(String name) { | ||
76 | + return buildEmptyTag(name, true); | ||
77 | + } | ||
78 | + | ||
79 | + /** | ||
80 | + * Builds XML start tag with name provided. | ||
81 | + * | ||
82 | + * @param name tag name | ||
83 | + * @param addNewLine option to add new line character after tag | ||
84 | + * @return string | ||
85 | + */ | ||
86 | + public static String buildStartTag(String name, boolean addNewLine) { | ||
87 | + if (addNewLine) { | ||
88 | + return (ANGLE_LEFT + name + ANGLE_RIGHT + NEW_LINE); | ||
89 | + } else { | ||
90 | + return (ANGLE_LEFT + name + ANGLE_RIGHT); | ||
91 | + } | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Builds XML end tag with name provided. | ||
96 | + * | ||
97 | + * @param name tag name | ||
98 | + * @param addNewLine option to add new line character after tag | ||
99 | + * @return string | ||
100 | + */ | ||
101 | + public static String buildEndTag(String name, boolean addNewLine) { | ||
102 | + if (addNewLine) { | ||
103 | + return (ANGLE_LEFT + SLASH + name + ANGLE_RIGHT + NEW_LINE); | ||
104 | + } else { | ||
105 | + return (ANGLE_LEFT + SLASH + name + ANGLE_RIGHT); | ||
106 | + } | ||
107 | + } | ||
108 | + | ||
109 | + /** | ||
110 | + * Builds XML empty element tag with name provided. | ||
111 | + * | ||
112 | + * @param name tag name | ||
113 | + * @param addNewLine option to add new line character after tag | ||
114 | + * @return string | ||
115 | + */ | ||
116 | + public static String buildEmptyTag(String name, boolean addNewLine) { | ||
117 | + if (addNewLine) { | ||
118 | + return (ANGLE_LEFT + name + SLASH + ANGLE_RIGHT + NEW_LINE); | ||
119 | + } else { | ||
120 | + return (ANGLE_LEFT + name + SLASH + ANGLE_RIGHT); | ||
121 | + } | ||
122 | + } | ||
123 | + | ||
124 | +} |
drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/cli/VoltGetPonLinksCommand.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present Open tworking 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.drivers.fujitsu.cli; | ||
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.VoltPonLinkConfig; | ||
23 | +import org.onosproject.net.driver.DriverHandler; | ||
24 | +import org.onosproject.net.driver.DriverService; | ||
25 | + | ||
26 | +/** | ||
27 | + * Gets PON links in vOLT. | ||
28 | + */ | ||
29 | +@Command(scope = "onos", name = "volt-ponlinks", | ||
30 | + description = "Gets PON links in vOLT") | ||
31 | +public class VoltGetPonLinksCommand extends AbstractShellCommand { | ||
32 | + | ||
33 | + @Argument(index = 0, name = "uri", description = "Device ID", | ||
34 | + required = true, multiValued = false) | ||
35 | + String uri = null; | ||
36 | + | ||
37 | + @Argument(index = 1, name = "target", description = "PON link ID", | ||
38 | + required = false, multiValued = false) | ||
39 | + String target = null; | ||
40 | + | ||
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 | + VoltPonLinkConfig volt = h.behaviour(VoltPonLinkConfig.class); | ||
49 | + String reply = volt.getPonLinks(target); | ||
50 | + if (reply != null) { | ||
51 | + print("%s", reply); | ||
52 | + } else { | ||
53 | + print("No replay from %s", deviceId.toString()); | ||
54 | + } | ||
55 | + } | ||
56 | + | ||
57 | +} |
drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/cli/VoltSetPonLinkCommand.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present Open tworking 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.drivers.fujitsu.cli; | ||
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.VoltPonLinkConfig; | ||
23 | +import org.onosproject.net.driver.DriverHandler; | ||
24 | +import org.onosproject.net.driver.DriverService; | ||
25 | + | ||
26 | +/** | ||
27 | + * Sets a parameter of a PON link in vOLT. | ||
28 | + */ | ||
29 | +@Command(scope = "onos", name = "volt-setponlink", | ||
30 | + description = "Sets a parameter of a PON link in vOLT") | ||
31 | +public class VoltSetPonLinkCommand extends AbstractShellCommand { | ||
32 | + | ||
33 | + @Argument(index = 0, name = "uri", description = "Device ID", | ||
34 | + required = true, multiValued = false) | ||
35 | + String uri = null; | ||
36 | + | ||
37 | + @Argument(index = 1, name = "target", description = "PON link ID:parameter:value", | ||
38 | + required = true, multiValued = false) | ||
39 | + String target = null; | ||
40 | + | ||
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 | + VoltPonLinkConfig volt = h.behaviour(VoltPonLinkConfig.class); | ||
49 | + volt.setPonLink(target); | ||
50 | + } | ||
51 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present 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 | + * Administrative console command-line extensions for interacting with the | ||
19 | + * network model - vOLT. | ||
20 | + */ | ||
21 | +package org.onosproject.drivers.fujitsu.cli; |
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 | +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> | ||
17 | + | ||
18 | + <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> | ||
19 | + <!--volt commands --> | ||
20 | + <command> | ||
21 | + <action class="org.onosproject.drivers.fujitsu.cli.VoltGetPonLinksCommand"/> | ||
22 | + <completers> | ||
23 | + <ref component-id="deviceIdCompleter"/> | ||
24 | + </completers> | ||
25 | + </command> | ||
26 | + | ||
27 | + <command> | ||
28 | + <action class="org.onosproject.drivers.fujitsu.cli.VoltSetPonLinkCommand"/> | ||
29 | + <completers> | ||
30 | + <ref component-id="deviceIdCompleter"/> | ||
31 | + </completers> | ||
32 | + </command> | ||
33 | + </command-bundle> | ||
34 | + | ||
35 | + <bean id="deviceIdCompleter" class="org.onosproject.cli.net.DeviceIdCompleter"/> | ||
36 | + | ||
37 | +</blueprint> |
... | @@ -24,5 +24,7 @@ | ... | @@ -24,5 +24,7 @@ |
24 | <driver name="fujitsu-volt-netconf" manufacturer="Fujitsu" hwVersion="svkOLT" swVersion="v1.0"> | 24 | <driver name="fujitsu-volt-netconf" manufacturer="Fujitsu" hwVersion="svkOLT" swVersion="v1.0"> |
25 | <behaviour api="org.onosproject.net.behaviour.ControllerConfig" | 25 | <behaviour api="org.onosproject.net.behaviour.ControllerConfig" |
26 | impl="org.onosproject.drivers.fujitsu.FujitsuVoltControllerConfig"/> | 26 | impl="org.onosproject.drivers.fujitsu.FujitsuVoltControllerConfig"/> |
27 | + <behaviour api="org.onosproject.net.behaviour.VoltPonLinkConfig" | ||
28 | + impl="org.onosproject.drivers.fujitsu.FujitsuVoltPonLinkConfig"/> | ||
27 | </driver> | 29 | </driver> |
28 | </drivers> | 30 | </drivers> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -64,8 +64,16 @@ public class NetconfSessionImpl implements NetconfSession { | ... | @@ -64,8 +64,16 @@ public class NetconfSessionImpl implements NetconfSession { |
64 | private static final String GET_CLOSE = "</get>"; | 64 | private static final String GET_CLOSE = "</get>"; |
65 | private static final String WITH_DEFAULT_OPEN = "<with-defaults "; | 65 | private static final String WITH_DEFAULT_OPEN = "<with-defaults "; |
66 | private static final String WITH_DEFAULT_CLOSE = "</with-defaults>"; | 66 | private static final String WITH_DEFAULT_CLOSE = "</with-defaults>"; |
67 | + private static final String DEFAULT_OPERATION_OPEN = "<default-operation>"; | ||
68 | + private static final String DEFAULT_OPERATION_CLOSE = "</default-operation>"; | ||
67 | private static final String FILTER_OPEN = "<filter type=\"subtree\">"; | 69 | private static final String FILTER_OPEN = "<filter type=\"subtree\">"; |
68 | private static final String FILTER_CLOSE = "</filter>"; | 70 | private static final String FILTER_CLOSE = "</filter>"; |
71 | + private static final String EDIT_CONFIG_OPEN = "<edit-config>"; | ||
72 | + private static final String EDIT_CONFIG_CLOSE = "</edit-config>"; | ||
73 | + private static final String TARGET_OPEN = "<target>"; | ||
74 | + private static final String TARGET_CLOSE = "</target>"; | ||
75 | + private static final String CONFIG_OPEN = "<config>"; | ||
76 | + private static final String CONFIG_CLOSE = "</config>"; | ||
69 | private static final String XML_HEADER = | 77 | private static final String XML_HEADER = |
70 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; | 78 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; |
71 | private static final String NETCONF_BASE_NAMESPACE = | 79 | private static final String NETCONF_BASE_NAMESPACE = |
... | @@ -355,28 +363,31 @@ public class NetconfSessionImpl implements NetconfSession { | ... | @@ -355,28 +363,31 @@ public class NetconfSessionImpl implements NetconfSession { |
355 | throws NetconfException { | 363 | throws NetconfException { |
356 | newConfiguration = newConfiguration.trim(); | 364 | newConfiguration = newConfiguration.trim(); |
357 | StringBuilder rpc = new StringBuilder(XML_HEADER); | 365 | StringBuilder rpc = new StringBuilder(XML_HEADER); |
358 | - rpc.append("<rpc "); | 366 | + rpc.append(RPC_OPEN); |
359 | rpc.append(MESSAGE_ID_STRING); | 367 | rpc.append(MESSAGE_ID_STRING); |
360 | rpc.append(EQUAL); | 368 | rpc.append(EQUAL); |
361 | rpc.append("\""); | 369 | rpc.append("\""); |
362 | rpc.append(messageIdInteger.get()); | 370 | rpc.append(messageIdInteger.get()); |
363 | rpc.append("\" "); | 371 | rpc.append("\" "); |
364 | - rpc.append("xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"); | 372 | + rpc.append(NETCONF_BASE_NAMESPACE).append(">\n"); |
365 | - rpc.append("<edit-config>\n"); | 373 | + rpc.append(EDIT_CONFIG_OPEN).append("\n"); |
366 | - rpc.append("<target>"); | 374 | + rpc.append(TARGET_OPEN); |
367 | rpc.append("<").append(targetConfiguration).append("/>"); | 375 | rpc.append("<").append(targetConfiguration).append("/>"); |
368 | - rpc.append("</target>\n"); | 376 | + rpc.append(TARGET_CLOSE).append("\n"); |
369 | - rpc.append("<default-operation>"); | 377 | + if (mode != null) { |
370 | - rpc.append(mode); | 378 | + rpc.append(DEFAULT_OPERATION_OPEN); |
371 | - rpc.append("</default-operation>\n"); | 379 | + rpc.append(mode); |
372 | - rpc.append("<config>\n"); | 380 | + rpc.append(DEFAULT_OPERATION_CLOSE).append("\n"); |
381 | + } | ||
382 | + rpc.append(CONFIG_OPEN).append("\n"); | ||
373 | rpc.append(newConfiguration); | 383 | rpc.append(newConfiguration); |
374 | - rpc.append("</config>\n"); | 384 | + rpc.append(CONFIG_CLOSE).append("\n"); |
375 | - rpc.append("</edit-config>\n"); | 385 | + rpc.append(EDIT_CONFIG_CLOSE).append("\n"); |
376 | - rpc.append("</rpc>"); | 386 | + rpc.append(RPC_CLOSE); |
377 | rpc.append(ENDPATTERN); | 387 | rpc.append(ENDPATTERN); |
378 | log.info(rpc.toString()); | 388 | log.info(rpc.toString()); |
379 | - return checkReply(sendRequest(rpc.toString())); | 389 | + String reply = sendRequest(rpc.toString()); |
390 | + return checkReply(reply); | ||
380 | } | 391 | } |
381 | 392 | ||
382 | @Override | 393 | @Override |
... | @@ -521,10 +532,12 @@ public class NetconfSessionImpl implements NetconfSession { | ... | @@ -521,10 +532,12 @@ public class NetconfSessionImpl implements NetconfSession { |
521 | private boolean checkReply(String reply) throws NetconfException { | 532 | private boolean checkReply(String reply) throws NetconfException { |
522 | if (reply != null) { | 533 | if (reply != null) { |
523 | if (!reply.contains("<rpc-error>")) { | 534 | if (!reply.contains("<rpc-error>")) { |
535 | + log.debug("Device {} sent reply {}", deviceInfo, reply); | ||
524 | return true; | 536 | return true; |
525 | } else if (reply.contains("<ok/>") | 537 | } else if (reply.contains("<ok/>") |
526 | || (reply.contains("<rpc-error>") | 538 | || (reply.contains("<rpc-error>") |
527 | && reply.contains("warning"))) { | 539 | && reply.contains("warning"))) { |
540 | + log.debug("Device {} sent reply {}", deviceInfo, reply); | ||
528 | return true; | 541 | return true; |
529 | } | 542 | } |
530 | } | 543 | } | ... | ... |
-
Please register or login to post a comment