blob: 4b8826687b030ceb0bbc8bcc0d96af8bce8b10ff [file] [log] [blame]
Andreas Papazoisc93117d2016-01-13 15:19:27 +02001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Andreas Papazoisc93117d2016-01-13 15:19:27 +02003 *
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.cli.net;
17
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import 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.
Yuta HIGUCHI57ba1e12017-04-26 15:51:47 -070034 *
35 * @deprecated in 1.10.0
Andreas Papazoisc93117d2016-01-13 15:19:27 +020036 */
37//Temporary Developer tool, NOT TO BE USED in production or as example for
38// future commands.
39//FIXME this should eventually be removed.
Yuta HIGUCHI57ba1e12017-04-26 15:51:47 -070040@Deprecated
Andreas Papazoisc93117d2016-01-13 15:19:27 +020041@Command(scope = "onos", name = "device-setconfiguration",
Yuta HIGUCHI57ba1e12017-04-26 15:51:47 -070042 description = "[Deprecated]Sets the configuration of the specified file to the " +
Andreas Papazoisc93117d2016-01-13 15:19:27 +020043 "specified device.")
44public class DeviceConfigSetterCommand extends AbstractShellCommand {
45
46 @Argument(index = 0, name = "uri", description = "Device ID",
47 required = true, multiValued = false)
48 private String uri = null;
49 @Argument(index = 1, name = "cfgFile", description = "Configuration file",
50 required = true, multiValued = false)
51 private String cfgFile = null;
52 private DeviceId deviceId;
53
54 @Override
55 protected void execute() {
Yuta HIGUCHI57ba1e12017-04-26 15:51:47 -070056 print("[WARN] This command was marked deprecated in 1.10.0");
Andreas Papazoisc93117d2016-01-13 15:19:27 +020057 DriverService service = get(DriverService.class);
58 deviceId = DeviceId.deviceId(uri);
59 DriverHandler h = service.createHandler(deviceId);
60 ConfigSetter config = h.behaviour(ConfigSetter.class);
61 checkNotNull(cfgFile, "Configuration file cannot be null");
62 print(config.setConfiguration(cfgFile));
63 }
64
65}