blob: ddccdafcf0d42e4eddea4057a9d0c1a3773ceb8b [file] [log] [blame]
tom5f35f7c2014-09-08 18:38:19 -07001package org.onlab.onos.cli.net;
2
3import org.apache.karaf.shell.commands.Argument;
4import org.apache.karaf.shell.commands.Command;
5import org.onlab.onos.cli.AbstractShellCommand;
6import org.onlab.onos.net.DeviceId;
7import org.onlab.onos.net.MastershipRole;
8import org.onlab.onos.net.device.DeviceAdminService;
9
10/**
11 * Sets role of the controller node for the given infrastructure device.
12 */
13@Command(scope = "onos", name = "device-role",
14 description = "Sets role of the controller node for the given infrastructure device")
15public class DeviceRoleCommand extends AbstractShellCommand {
16
17 @Argument(index = 0, name = "uri", description = "Device ID",
18 required = true, multiValued = false)
19 String uri = null;
20
21 @Argument(index = 1, name = "role", description = "Mastership role",
22 required = true, multiValued = false)
23 String role = null;
24
25 @Override
tom0872a172014-09-23 11:24:26 -070026 protected void execute() {
tom5f35f7c2014-09-08 18:38:19 -070027 MastershipRole mastershipRole = MastershipRole.valueOf(role.toUpperCase());
28 getService(DeviceAdminService.class).setRole(DeviceId.deviceId(uri),
29 mastershipRole);
tom5f35f7c2014-09-08 18:38:19 -070030 }
31
32}