blob: fd5a04ca2d471fabea46b16618953ab880843cf3 [file] [log] [blame]
Yuta HIGUCHI57ba1e12017-04-26 15:51:47 -07001/*
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 */
16package org.onosproject.netconf.cli.impl;
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 Remove dependency to ConfigGetter.
35
36@Command(scope = "onos", name = "netconf-get-config",
37 description = "Gets the configuration of the specified type from the" +
38 "specified device.")
39public class NetconfConfigGetCommand extends AbstractShellCommand {
40
41 @Argument(index = 0, name = "uri", description = "Device ID",
42 required = true, multiValued = false)
43 String uri = null;
44
45 @Argument(index = 1, name = "cfgType",
46 description = "Configuration datastore name (RUNNING, etc.)",
47 required = true, multiValued = false)
48 String cfgType = null;
49
50
51 private DeviceId deviceId;
52
53 @Override
54 protected void execute() {
55 DriverService service = get(DriverService.class);
56 deviceId = DeviceId.deviceId(uri);
57 DriverHandler h = service.createHandler(deviceId);
58 ConfigGetter config = h.behaviour(ConfigGetter.class);
59 print(config.getConfiguration(cfgType));
60 }
61
62}