blob: 31ec9f44dac769eb3cc619d5d45a102fc72ccccb [file] [log] [blame]
Aaron Kruglikov12faf8d2016-01-04 16:24:07 -08001/*
2 * Copyright 2015 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 */
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.ConfigGetter;
23import org.onosproject.net.driver.DriverHandler;
24import 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.
32 */
33
34//FIXME this should eventually be removed.
35
36@Command(scope = "onos", name = "device-configuration",
37 description = "Gets the configuration of the specified type from the" +
38 "specified device.")
39public class DeviceConfigGetterCommand extends AbstractShellCommand {
40
41 @Argument(index = 0, name = "uri", description = "Device ID",
42 required = true, multiValued = false)
43 String uri = null;
44 @Argument(index = 1, name = "cfgType", description = "Configuration type",
45 required = true, multiValued = false)
46 String cfgType = null;
47 private DeviceId deviceId;
48
49 @Override
50 protected void execute() {
51 DriverService service = get(DriverService.class);
52 deviceId = DeviceId.deviceId(uri);
53 DriverHandler h = service.createHandler(deviceId);
54 ConfigGetter config = h.behaviour(ConfigGetter.class);
55 print(config.getConfiguration(cfgType));
56 }
57
58}