Committed by
Yuta HIGUCHI
[ONOS-4837] NETCONF function for FUJITSU OLT #4 and #5
- Add the following commands for FJ OLT volt-onus <netconf:target> <ONU ID> volt-setonu <netconf:target> <ONU-ID:parameter type:parameter value> volt-onustats <netconf:target> {ONU-ID} volt-rebootonu <netconf:target> <ONU-ID> volt-ethloopback <netconf:target> <ONU-ETH-ID[:loopback mode]> - Add the method of doUserRpc() in Netconfsession/NetconfSessionImpl *If you dont allow to implement the method, i can move it to our XmlUtility method. - Add new behaviours in /core/.../net/behaviour, and @Beta in the interface. - Move those behaviour interface to fujitsu driver directory. * VoltPonLinkConfig.java as well. - Update fujitsu-drivers.xml - Change the method name from doUserRpc to doWrappedRpc Change-Id: Ic39d3a11ba35d2377e552af097eda65c5554c63f
Showing
18 changed files
with
623 additions
and
6 deletions
This diff is collapsed. Click to expand it.
drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuOperConfig.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.drivers.fujitsu.behaviour.VoltOnuOperConfig; | ||
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 | + | ||
29 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
30 | +import static org.onosproject.drivers.fujitsu.FujitsuVoltXmlUtility.*; | ||
31 | +import static org.slf4j.LoggerFactory.getLogger; | ||
32 | + | ||
33 | +/** | ||
34 | + * Implementation to take actions on ONU available in vOLT | ||
35 | + * through the Netconf protocol. | ||
36 | + */ | ||
37 | +public class FujitsuVoltOnuOperConfig extends AbstractHandlerBehaviour | ||
38 | + implements VoltOnuOperConfig { | ||
39 | + | ||
40 | + private final Logger log = getLogger(FujitsuVoltOnuOperConfig.class); | ||
41 | + private static final String ONU_REBOOT = "onu-reboot"; | ||
42 | + private static final String ONU_ETHPORT_LOOPBACK = "onu-ethport-loopback"; | ||
43 | + private static final String ETHPORT_ID = "ethport-id"; | ||
44 | + private int pon; | ||
45 | + private int onu; | ||
46 | + private int eth; | ||
47 | + | ||
48 | + | ||
49 | + @Override | ||
50 | + public String rebootOnu(String target) { | ||
51 | + DriverHandler handler = handler(); | ||
52 | + NetconfController controller = handler.get(NetconfController.class); | ||
53 | + MastershipService mastershipService = handler.get(MastershipService.class); | ||
54 | + DeviceId ncDeviceId = handler.data().deviceId(); | ||
55 | + checkNotNull(controller, "Netconf controller is null"); | ||
56 | + String reply = null; | ||
57 | + String[] onuId = null; | ||
58 | + | ||
59 | + if (!mastershipService.isLocalMaster(ncDeviceId)) { | ||
60 | + log.warn("Not master for {} Use {} to execute command", | ||
61 | + ncDeviceId, | ||
62 | + mastershipService.getMasterFor(ncDeviceId)); | ||
63 | + return reply; | ||
64 | + } | ||
65 | + | ||
66 | + onuId = target.split(HYPHEN); | ||
67 | + if (onuId.length != 2) { | ||
68 | + log.error("Invalid number of arguments"); | ||
69 | + return reply; | ||
70 | + } | ||
71 | + try { | ||
72 | + pon = Integer.parseInt(onuId[0]); | ||
73 | + onu = Integer.parseInt(onuId[1]); | ||
74 | + } catch (NumberFormatException e) { | ||
75 | + log.error("Non-number input"); | ||
76 | + return reply; | ||
77 | + } | ||
78 | + | ||
79 | + try { | ||
80 | + StringBuilder request = new StringBuilder(); | ||
81 | + request.append(ANGLE_LEFT).append(ONU_REBOOT).append(SPACE); | ||
82 | + request.append(VOLT_NE_NAMESPACE).append(ANGLE_RIGHT).append(NEW_LINE); | ||
83 | + request.append(buildStartTag(PONLINK_ID, false)); | ||
84 | + request.append(onuId[0]); | ||
85 | + request.append(buildEndTag(PONLINK_ID)); | ||
86 | + request.append(buildStartTag(ONU_ID, false)); | ||
87 | + request.append(onuId[1]); | ||
88 | + request.append(buildEndTag(ONU_ID)); | ||
89 | + request.append(buildEndTag(ONU_REBOOT)); | ||
90 | + | ||
91 | + reply = controller. | ||
92 | + getDevicesMap().get(ncDeviceId).getSession(). | ||
93 | + doWrappedRpc(request.toString()); | ||
94 | + } catch (IOException e) { | ||
95 | + log.error("Cannot communicate to device {} exception ", ncDeviceId, e); | ||
96 | + } | ||
97 | + return reply; | ||
98 | + } | ||
99 | + | ||
100 | + @Override | ||
101 | + public String loopbackEthOnu(String target) { | ||
102 | + DriverHandler handler = handler(); | ||
103 | + NetconfController controller = handler.get(NetconfController.class); | ||
104 | + MastershipService mastershipService = handler.get(MastershipService.class); | ||
105 | + DeviceId ncDeviceId = handler.data().deviceId(); | ||
106 | + checkNotNull(controller, "Netconf controller is null"); | ||
107 | + String reply = null; | ||
108 | + String[] ethId = null; | ||
109 | + | ||
110 | + if (!mastershipService.isLocalMaster(ncDeviceId)) { | ||
111 | + log.warn("Not master for {} Use {} to execute command", | ||
112 | + ncDeviceId, | ||
113 | + mastershipService.getMasterFor(ncDeviceId)); | ||
114 | + return reply; | ||
115 | + } | ||
116 | + | ||
117 | + ethId = target.split(HYPHEN); | ||
118 | + if (ethId.length != 3) { | ||
119 | + log.error("Invalid number of arguments"); | ||
120 | + return reply; | ||
121 | + } | ||
122 | + try { | ||
123 | + pon = Integer.parseInt(ethId[0]); | ||
124 | + onu = Integer.parseInt(ethId[1]); | ||
125 | + eth = Integer.parseInt(ethId[2]); | ||
126 | + } catch (NumberFormatException e) { | ||
127 | + log.error("Non-number input"); | ||
128 | + return reply; | ||
129 | + } | ||
130 | + | ||
131 | + try { | ||
132 | + StringBuilder request = new StringBuilder(); | ||
133 | + request.append(ANGLE_LEFT).append(ONU_ETHPORT_LOOPBACK).append(SPACE); | ||
134 | + request.append(VOLT_NE_NAMESPACE).append(ANGLE_RIGHT).append(NEW_LINE); | ||
135 | + request.append(buildStartTag(PONLINK_ID, false)); | ||
136 | + request.append(ethId[0]); | ||
137 | + request.append(buildEndTag(PONLINK_ID)); | ||
138 | + request.append(buildStartTag(ONU_ID, false)); | ||
139 | + request.append(ethId[1]); | ||
140 | + request.append(buildEndTag(ONU_ID)); | ||
141 | + request.append(buildStartTag(ETHPORT_ID, false)); | ||
142 | + request.append(ethId[2]); | ||
143 | + request.append(buildEndTag(ETHPORT_ID)); | ||
144 | + request.append(buildEndTag(ONU_ETHPORT_LOOPBACK)); | ||
145 | + | ||
146 | + reply = controller. | ||
147 | + getDevicesMap().get(ncDeviceId).getSession(). | ||
148 | + doWrappedRpc(request.toString()); | ||
149 | + } catch (IOException e) { | ||
150 | + log.error("Cannot communicate to device {} exception ", ncDeviceId, e); | ||
151 | + } | ||
152 | + return reply; | ||
153 | + } | ||
154 | + | ||
155 | +} |
... | @@ -18,7 +18,7 @@ package org.onosproject.drivers.fujitsu; | ... | @@ -18,7 +18,7 @@ package org.onosproject.drivers.fujitsu; |
18 | 18 | ||
19 | import org.onosproject.mastership.MastershipService; | 19 | import org.onosproject.mastership.MastershipService; |
20 | import org.onosproject.net.DeviceId; | 20 | import org.onosproject.net.DeviceId; |
21 | -import org.onosproject.net.behaviour.VoltPonLinkConfig; | 21 | +import org.onosproject.drivers.fujitsu.behaviour.VoltPonLinkConfig; |
22 | import org.onosproject.net.driver.AbstractHandlerBehaviour; | 22 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
23 | import org.onosproject.net.driver.DriverHandler; | 23 | import org.onosproject.net.driver.DriverHandler; |
24 | import org.onosproject.netconf.NetconfController; | 24 | import org.onosproject.netconf.NetconfController; | ... | ... |
drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/behaviour/VoltOnuConfig.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 | +package org.onosproject.drivers.fujitsu.behaviour; | ||
17 | + | ||
18 | +import com.google.common.annotations.Beta; | ||
19 | +import org.onosproject.net.driver.HandlerBehaviour; | ||
20 | + | ||
21 | +/** | ||
22 | + * Device behaviour to obtain and set parameters of ONUs in vOLT. | ||
23 | + */ | ||
24 | +@Beta | ||
25 | +public interface VoltOnuConfig extends HandlerBehaviour { | ||
26 | + | ||
27 | + /** | ||
28 | + * Obtain all ONUs or a specific ONU in the device. | ||
29 | + * | ||
30 | + * @param target input data in string | ||
31 | + * @return response string | ||
32 | + */ | ||
33 | + String getOnus(String target); | ||
34 | + | ||
35 | + /** | ||
36 | + * Set a parameter value of an ONU in the device. | ||
37 | + * | ||
38 | + * @param target input data in string | ||
39 | + * @return response string | ||
40 | + */ | ||
41 | + String setOnu(String target); | ||
42 | + | ||
43 | + /** | ||
44 | + * Obtain all or a specific ONU statistics in the device. | ||
45 | + * | ||
46 | + * @param target input data in string | ||
47 | + * @return response string | ||
48 | + */ | ||
49 | + String getOnuStatistics(String target); | ||
50 | + | ||
51 | +} |
drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/behaviour/VoltOnuOperConfig.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 | +package org.onosproject.drivers.fujitsu.behaviour; | ||
17 | + | ||
18 | +import com.google.common.annotations.Beta; | ||
19 | +import org.onosproject.net.driver.HandlerBehaviour; | ||
20 | + | ||
21 | +/** | ||
22 | + * Device behaviour to perform actions in an ONU in vOLT. | ||
23 | + */ | ||
24 | +@Beta | ||
25 | +public interface VoltOnuOperConfig extends HandlerBehaviour { | ||
26 | + | ||
27 | + /** | ||
28 | + * Reboot an ONU in the device. | ||
29 | + * | ||
30 | + * @param target input data in string | ||
31 | + */ | ||
32 | + String rebootOnu(String target); | ||
33 | + | ||
34 | + /** | ||
35 | + * Operate/release loopback on Ethernet port an ONU in the device. | ||
36 | + * | ||
37 | + * @param target input data in string | ||
38 | + */ | ||
39 | + String loopbackEthOnu(String target); | ||
40 | + | ||
41 | +} |
... | @@ -13,13 +13,15 @@ | ... | @@ -13,13 +13,15 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.behaviour; | 16 | +package org.onosproject.drivers.fujitsu.behaviour; |
17 | 17 | ||
18 | +import com.google.common.annotations.Beta; | ||
18 | import org.onosproject.net.driver.HandlerBehaviour; | 19 | import org.onosproject.net.driver.HandlerBehaviour; |
19 | 20 | ||
20 | /** | 21 | /** |
21 | * Device behaviour to obtain and set parameters of PON links in vOLT. | 22 | * Device behaviour to obtain and set parameters of PON links in vOLT. |
22 | */ | 23 | */ |
24 | +@Beta | ||
23 | public interface VoltPonLinkConfig extends HandlerBehaviour { | 25 | public interface VoltPonLinkConfig extends HandlerBehaviour { |
24 | 26 | ||
25 | /** | 27 | /** | ... | ... |
drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/behaviour/package-info.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 | + | ||
18 | +/** | ||
19 | + * Abstractions of various device configuration or device adaptation behaviours; | ||
20 | + * counterpart to the device driver subsystem. -vOLT | ||
21 | + */ | ||
22 | +package org.onosproject.drivers.fujitsu.behaviour; |
drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/cli/VoltEthLoopbackCommand.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 | +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.drivers.fujitsu.behaviour.VoltOnuOperConfig; | ||
23 | +import org.onosproject.net.driver.DriverHandler; | ||
24 | +import org.onosproject.net.driver.DriverService; | ||
25 | + | ||
26 | +/** | ||
27 | + * Operates/releases loopback on Ethernet port of an ONU in vOLT. | ||
28 | + */ | ||
29 | +@Command(scope = "onos", name = "volt-ethloopback", | ||
30 | + description = "Operates/releases loopback on Ethernet port of an ONU in vOLT") | ||
31 | +public class VoltEthLoopbackCommand 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-ONU ID-Eth port ID[:(operate:release)]", | ||
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 | + VoltOnuOperConfig volt = h.behaviour(VoltOnuOperConfig.class); | ||
49 | + String reply = volt.loopbackEthOnu(target); | ||
50 | + if (reply != null) { | ||
51 | + print("%s", reply); | ||
52 | + } else { | ||
53 | + print("No reply from %s", deviceId.toString()); | ||
54 | + } | ||
55 | + } | ||
56 | + | ||
57 | +} |
drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/cli/VoltGetOnuStatsCommand.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.drivers.fujitsu.behaviour.VoltOnuConfig; | ||
23 | +import org.onosproject.net.driver.DriverHandler; | ||
24 | +import org.onosproject.net.driver.DriverService; | ||
25 | + | ||
26 | +/** | ||
27 | + * Gets ONU statistics in vOLT. | ||
28 | + */ | ||
29 | +@Command(scope = "onos", name = "volt-onustats", | ||
30 | + description = "Gets ONU statistics in vOLT") | ||
31 | +public class VoltGetOnuStatsCommand 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-ONU 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 | + VoltOnuConfig volt = h.behaviour(VoltOnuConfig.class); | ||
49 | + String reply = volt.getOnuStatistics(target); | ||
50 | + if (reply != null) { | ||
51 | + print("%s", reply); | ||
52 | + } else { | ||
53 | + print("No reply from %s", deviceId.toString()); | ||
54 | + } | ||
55 | + } | ||
56 | + | ||
57 | +} |
drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/cli/VoltGetOnusCommand.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.drivers.fujitsu.behaviour.VoltOnuConfig; | ||
23 | +import org.onosproject.net.driver.DriverHandler; | ||
24 | +import org.onosproject.net.driver.DriverService; | ||
25 | + | ||
26 | +/** | ||
27 | + * Gets ONUs available in vOLT. | ||
28 | + */ | ||
29 | +@Command(scope = "onos", name = "volt-onus", | ||
30 | + description = "Gets ONUs available in vOLT") | ||
31 | +public class VoltGetOnusCommand 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 or PON link ID-ONU 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 | + VoltOnuConfig volt = h.behaviour(VoltOnuConfig.class); | ||
49 | + String reply = volt.getOnus(target); | ||
50 | + if (reply != null) { | ||
51 | + print("%s", reply); | ||
52 | + } else { | ||
53 | + print("No reply from %s", deviceId.toString()); | ||
54 | + } | ||
55 | + } | ||
56 | + | ||
57 | +} |
... | @@ -19,7 +19,7 @@ import org.apache.karaf.shell.commands.Argument; | ... | @@ -19,7 +19,7 @@ import org.apache.karaf.shell.commands.Argument; |
19 | import org.apache.karaf.shell.commands.Command; | 19 | import org.apache.karaf.shell.commands.Command; |
20 | import org.onosproject.cli.AbstractShellCommand; | 20 | import org.onosproject.cli.AbstractShellCommand; |
21 | import org.onosproject.net.DeviceId; | 21 | import org.onosproject.net.DeviceId; |
22 | -import org.onosproject.net.behaviour.VoltPonLinkConfig; | 22 | +import org.onosproject.drivers.fujitsu.behaviour.VoltPonLinkConfig; |
23 | import org.onosproject.net.driver.DriverHandler; | 23 | import org.onosproject.net.driver.DriverHandler; |
24 | import org.onosproject.net.driver.DriverService; | 24 | import org.onosproject.net.driver.DriverService; |
25 | 25 | ... | ... |
drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/cli/VoltRebootOnuCommand.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 | +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.drivers.fujitsu.behaviour.VoltOnuOperConfig; | ||
23 | +import org.onosproject.net.driver.DriverHandler; | ||
24 | +import org.onosproject.net.driver.DriverService; | ||
25 | + | ||
26 | +/** | ||
27 | + * Reboots an ONU in vOLT. | ||
28 | + */ | ||
29 | +@Command(scope = "onos", name = "volt-rebootonu", | ||
30 | + description = "Reboots an ONU in vOLT") | ||
31 | +public class VoltRebootOnuCommand 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-ONU ID", | ||
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 | + VoltOnuOperConfig volt = h.behaviour(VoltOnuOperConfig.class); | ||
49 | + String reply = volt.rebootOnu(target); | ||
50 | + if (reply != null) { | ||
51 | + print("%s", reply); | ||
52 | + } else { | ||
53 | + print("No reply from %s", deviceId.toString()); | ||
54 | + } | ||
55 | + } | ||
56 | + | ||
57 | +} |
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.drivers.fujitsu.behaviour.VoltOnuConfig; | ||
23 | +import org.onosproject.net.driver.DriverHandler; | ||
24 | +import org.onosproject.net.driver.DriverService; | ||
25 | + | ||
26 | +/** | ||
27 | + * Sets a parameter value of an ONU in vOLT. | ||
28 | + */ | ||
29 | +@Command(scope = "onos", name = "volt-setonu", | ||
30 | + description = "Sets a parameter value of an ONU in vOLT") | ||
31 | +public class VoltSetOnuCommand 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-ONU 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 | + VoltOnuConfig volt = h.behaviour(VoltOnuConfig.class); | ||
49 | + String reply = volt.setOnu(target); | ||
50 | + if (reply != null) { | ||
51 | + print("%s", reply); | ||
52 | + } else { | ||
53 | + print("No reply from %s", deviceId.toString()); | ||
54 | + } | ||
55 | + } | ||
56 | + | ||
57 | +} |
... | @@ -19,7 +19,7 @@ import org.apache.karaf.shell.commands.Argument; | ... | @@ -19,7 +19,7 @@ import org.apache.karaf.shell.commands.Argument; |
19 | import org.apache.karaf.shell.commands.Command; | 19 | import org.apache.karaf.shell.commands.Command; |
20 | import org.onosproject.cli.AbstractShellCommand; | 20 | import org.onosproject.cli.AbstractShellCommand; |
21 | import org.onosproject.net.DeviceId; | 21 | import org.onosproject.net.DeviceId; |
22 | -import org.onosproject.net.behaviour.VoltPonLinkConfig; | 22 | +import org.onosproject.drivers.fujitsu.behaviour.VoltPonLinkConfig; |
23 | import org.onosproject.net.driver.DriverHandler; | 23 | import org.onosproject.net.driver.DriverHandler; |
24 | import org.onosproject.net.driver.DriverService; | 24 | import org.onosproject.net.driver.DriverService; |
25 | 25 | ... | ... |
... | @@ -23,13 +23,42 @@ | ... | @@ -23,13 +23,42 @@ |
23 | <ref component-id="deviceIdCompleter"/> | 23 | <ref component-id="deviceIdCompleter"/> |
24 | </completers> | 24 | </completers> |
25 | </command> | 25 | </command> |
26 | - | ||
27 | <command> | 26 | <command> |
28 | <action class="org.onosproject.drivers.fujitsu.cli.VoltSetPonLinkCommand"/> | 27 | <action class="org.onosproject.drivers.fujitsu.cli.VoltSetPonLinkCommand"/> |
29 | <completers> | 28 | <completers> |
30 | <ref component-id="deviceIdCompleter"/> | 29 | <ref component-id="deviceIdCompleter"/> |
31 | </completers> | 30 | </completers> |
32 | </command> | 31 | </command> |
32 | + <command> | ||
33 | + <action class="org.onosproject.drivers.fujitsu.cli.VoltGetOnusCommand"/> | ||
34 | + <completers> | ||
35 | + <ref component-id="deviceIdCompleter"/> | ||
36 | + </completers> | ||
37 | + </command> | ||
38 | + <command> | ||
39 | + <action class="org.onosproject.drivers.fujitsu.cli.VoltSetOnuCommand"/> | ||
40 | + <completers> | ||
41 | + <ref component-id="deviceIdCompleter"/> | ||
42 | + </completers> | ||
43 | + </command> | ||
44 | + <command> | ||
45 | + <action class="org.onosproject.drivers.fujitsu.cli.VoltGetOnuStatsCommand"/> | ||
46 | + <completers> | ||
47 | + <ref component-id="deviceIdCompleter"/> | ||
48 | + </completers> | ||
49 | + </command> | ||
50 | + <command> | ||
51 | + <action class="org.onosproject.drivers.fujitsu.cli.VoltEthLoopbackCommand"/> | ||
52 | + <completers> | ||
53 | + <ref component-id="deviceIdCompleter"/> | ||
54 | + </completers> | ||
55 | + </command> | ||
56 | + <command> | ||
57 | + <action class="org.onosproject.drivers.fujitsu.cli.VoltRebootOnuCommand"/> | ||
58 | + <completers> | ||
59 | + <ref component-id="deviceIdCompleter"/> | ||
60 | + </completers> | ||
61 | + </command> | ||
33 | </command-bundle> | 62 | </command-bundle> |
34 | 63 | ||
35 | <bean id="deviceIdCompleter" class="org.onosproject.cli.net.DeviceIdCompleter"/> | 64 | <bean id="deviceIdCompleter" class="org.onosproject.cli.net.DeviceIdCompleter"/> | ... | ... |
... | @@ -24,7 +24,11 @@ | ... | @@ -24,7 +24,11 @@ |
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" | 27 | + <behaviour api="org.onosproject.drivers.fujitsu.behaviour.VoltPonLinkConfig" |
28 | impl="org.onosproject.drivers.fujitsu.FujitsuVoltPonLinkConfig"/> | 28 | impl="org.onosproject.drivers.fujitsu.FujitsuVoltPonLinkConfig"/> |
29 | + <behaviour api="org.onosproject.drivers.fujitsu.behaviour.VoltOnuConfig" | ||
30 | + impl="org.onosproject.drivers.fujitsu.FujitsuVoltOnuConfig"/> | ||
31 | + <behaviour api="org.onosproject.drivers.fujitsu.behaviour.VoltOnuOperConfig" | ||
32 | + impl="org.onosproject.drivers.fujitsu.FujitsuVoltOnuOperConfig"/> | ||
29 | </driver> | 33 | </driver> |
30 | </drivers> | 34 | </drivers> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -60,6 +60,16 @@ public interface NetconfSession { | ... | @@ -60,6 +60,16 @@ public interface NetconfSession { |
60 | throws NetconfException; | 60 | throws NetconfException; |
61 | 61 | ||
62 | /** | 62 | /** |
63 | + * Executes an RPC to the server and wrap the request in RPC header. | ||
64 | + * | ||
65 | + * @param request the XML containing the request to the server. | ||
66 | + * @return Server response or ERROR | ||
67 | + * @throws NetconfException when there is a problem in the communication process on | ||
68 | + * the underlying connection | ||
69 | + */ | ||
70 | + String doWrappedRpc(String request) throws NetconfException; | ||
71 | + | ||
72 | + /** | ||
63 | * Executes an synchronous RPC to the server. | 73 | * Executes an synchronous RPC to the server. |
64 | * | 74 | * |
65 | * @param request the XML containing the RPC for the server. | 75 | * @param request the XML containing the RPC for the server. | ... | ... |
... | @@ -289,6 +289,24 @@ public class NetconfSessionImpl implements NetconfSession { | ... | @@ -289,6 +289,24 @@ public class NetconfSessionImpl implements NetconfSession { |
289 | } | 289 | } |
290 | 290 | ||
291 | @Override | 291 | @Override |
292 | + public String doWrappedRpc(String request) throws NetconfException { | ||
293 | + StringBuilder rpc = new StringBuilder(XML_HEADER); | ||
294 | + rpc.append(RPC_OPEN); | ||
295 | + rpc.append(MESSAGE_ID_STRING); | ||
296 | + rpc.append(EQUAL); | ||
297 | + rpc.append("\""); | ||
298 | + rpc.append(messageIdInteger.get()); | ||
299 | + rpc.append("\" "); | ||
300 | + rpc.append(NETCONF_BASE_NAMESPACE).append(">\n"); | ||
301 | + rpc.append(request); | ||
302 | + rpc.append(RPC_CLOSE).append(NEW_LINE); | ||
303 | + rpc.append(ENDPATTERN); | ||
304 | + String reply = sendRequest(rpc.toString()); | ||
305 | + checkReply(reply); | ||
306 | + return reply; | ||
307 | + } | ||
308 | + | ||
309 | + @Override | ||
292 | public String get(String request) throws NetconfException { | 310 | public String get(String request) throws NetconfException { |
293 | return requestSync(request); | 311 | return requestSync(request); |
294 | } | 312 | } | ... | ... |
-
Please register or login to post a comment