blob: 328d4700dde07ab406b5edf7a0d0e92b762dcc83 [file] [log] [blame]
andreaed976a42015-10-05 14:38:25 -07001/*
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.ControllerConfig;
23import org.onosproject.net.driver.DriverHandler;
24import org.onosproject.net.driver.DriverService;
25
26/**
27 * Sets role of the controller node for the given infrastructure device.
28 */
29@Command(scope = "onos", name = "device-controllers",
30 description = "gets the list of controllers for the given infrastructure device")
31public class DeviceControllersCommand extends AbstractShellCommand {
32
33 @Argument(index = 0, name = "uri", description = "Device ID",
34 required = true, multiValued = false)
35 String uri = null;
36 private DeviceId deviceId;
37
38 @Override
39 protected void execute() {
40 DriverService service = get(DriverService.class);
41 deviceId = DeviceId.deviceId(uri);
42 DriverHandler h = service.createHandler(deviceId);
43 ControllerConfig config = h.behaviour(ControllerConfig.class);
44 config.getControllers().forEach(c -> print(c.target()));
45 }
46
47}