blob: 385bd7f796ba3c1cf84ab1ff7326a1c2f24e1312 [file] [log] [blame]
Yuta HIGUCHI57ba1e12017-04-26 15:51:47 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Yuta HIGUCHI57ba1e12017-04-26 15:51:47 -07003 *
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 */
16package org.onosproject.netconf.cli.impl;
17
Ray Milkey86ad7bb2018-09-27 12:32:28 -070018import org.apache.karaf.shell.api.action.Argument;
19import org.apache.karaf.shell.api.action.Command;
Yuta HIGUCHI57ba1e12017-04-26 15:51:47 -070020import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.net.DeviceId;
22import org.onosproject.net.behaviour.ConfigSetter;
23import org.onosproject.net.driver.DriverHandler;
24import org.onosproject.net.driver.DriverService;
25
26import static com.google.common.base.Preconditions.checkNotNull;
27
28/**
29 * Command that sets the configuration included in the specified file to the
30 * specified device. It prints the response of the device.
31 *
32 * This is a temporary development tool for use until yang integration is complete.
33 * This uses a not properly specified behavior. DO NOT USE AS AN EXAMPLE.
34 */
35//Temporary Developer tool, NOT TO BE USED in production or as example for
36// future commands.
37//FIXME Remove dependency to ConfigSetter.
38
39@Command(scope = "onos", name = "netconf-rpc-test",
40 description = "Debug tool to send NETCONF RPC request")
41public class NetconfRpcTestCommand extends AbstractShellCommand {
42
43 @Argument(index = 0, name = "uri", description = "Device ID",
44 required = true, multiValued = false)
45 private String uri = null;
46
47 @Argument(index = 1, name = "cfgFile", description = "File path to RPC XML",
48 required = true, multiValued = false)
49 private String cfgFile = null;
50
51 private DeviceId deviceId;
52
53 @Override
Ray Milkeyd84f89b2018-08-17 14:54:17 -070054 protected void doExecute() {
Yuta HIGUCHI57ba1e12017-04-26 15:51:47 -070055 DriverService service = get(DriverService.class);
56 deviceId = DeviceId.deviceId(uri);
57 DriverHandler h = service.createHandler(deviceId);
58 ConfigSetter config = h.behaviour(ConfigSetter.class);
59 checkNotNull(cfgFile, "Configuration file cannot be null");
60 print(config.setConfiguration(cfgFile));
61 }
62
63}