Aaron Kruglikov | 12faf8d | 2016-01-04 16:24:07 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2016-present Open Networking Foundation |
Aaron Kruglikov | 12faf8d | 2016-01-04 16:24:07 -0800 | [diff] [blame] | 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.cli.net; |
| 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.ConfigGetter; |
| 23 | import org.onosproject.net.driver.DriverHandler; |
| 24 | import org.onosproject.net.driver.DriverService; |
| 25 | |
| 26 | /** |
| 27 | * Command that gets the configuration of the specified type from the specified |
| 28 | * device. If configuration cannot be retrieved it prints an error string. |
| 29 | * |
| 30 | * This is a temporary development tool for use until yang integration is complete. |
| 31 | * This uses a not properly specified behavior. DO NOT USE AS AN EXAMPLE. |
Yuta HIGUCHI | 57ba1e1 | 2017-04-26 15:51:47 -0700 | [diff] [blame] | 32 | * |
| 33 | * @deprecated in 1.10.0 |
Aaron Kruglikov | 12faf8d | 2016-01-04 16:24:07 -0800 | [diff] [blame] | 34 | */ |
| 35 | |
| 36 | //FIXME this should eventually be removed. |
Yuta HIGUCHI | 57ba1e1 | 2017-04-26 15:51:47 -0700 | [diff] [blame] | 37 | @Deprecated |
Aaron Kruglikov | 12faf8d | 2016-01-04 16:24:07 -0800 | [diff] [blame] | 38 | @Command(scope = "onos", name = "device-configuration", |
Yuta HIGUCHI | 57ba1e1 | 2017-04-26 15:51:47 -0700 | [diff] [blame] | 39 | description = "[Deprecated]Gets the configuration of the specified type from the" + |
Aaron Kruglikov | 12faf8d | 2016-01-04 16:24:07 -0800 | [diff] [blame] | 40 | "specified device.") |
| 41 | public class DeviceConfigGetterCommand extends AbstractShellCommand { |
| 42 | |
| 43 | @Argument(index = 0, name = "uri", description = "Device ID", |
| 44 | required = true, multiValued = false) |
| 45 | String uri = null; |
| 46 | @Argument(index = 1, name = "cfgType", description = "Configuration type", |
| 47 | required = true, multiValued = false) |
| 48 | String cfgType = null; |
| 49 | private DeviceId deviceId; |
| 50 | |
| 51 | @Override |
| 52 | protected void execute() { |
Yuta HIGUCHI | 57ba1e1 | 2017-04-26 15:51:47 -0700 | [diff] [blame] | 53 | print("[WARN] This command was marked deprecated in 1.10.0"); |
Aaron Kruglikov | 12faf8d | 2016-01-04 16:24:07 -0800 | [diff] [blame] | 54 | DriverService service = get(DriverService.class); |
| 55 | deviceId = DeviceId.deviceId(uri); |
| 56 | DriverHandler h = service.createHandler(deviceId); |
| 57 | ConfigGetter config = h.behaviour(ConfigGetter.class); |
| 58 | print(config.getConfiguration(cfgType)); |
| 59 | } |
| 60 | |
| 61 | } |