blob: 3fa7bca400b42f5b3d6a06226735eed02f9eb864 [file] [log] [blame]
Thomas Vachuska7d693f52014-10-21 19:17:57 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska7d693f52014-10-21 19:17:57 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska7d693f52014-10-21 19:17:57 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska7d693f52014-10-21 19:17:57 -070015 */
tom9710fb42014-09-29 11:35:28 -070016package org.onlab.onos.cli;
17
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import org.onlab.onos.cluster.ClusterAdminService;
21import org.onlab.onos.cluster.NodeId;
Pavlin Radoslavov444b5192014-10-28 10:45:19 -070022import org.onlab.packet.IpAddress;
tom9710fb42014-09-29 11:35:28 -070023
24/**
25 * Adds a new controller cluster node.
26 */
27@Command(scope = "onos", name = "add-node",
28 description = "Adds a new controller cluster node")
29public class NodeAddCommand extends AbstractShellCommand {
30
31 @Argument(index = 0, name = "nodeId", description = "Node ID",
32 required = true, multiValued = false)
33 String nodeId = null;
34
35 @Argument(index = 1, name = "ip", description = "Node IP address",
36 required = true, multiValued = false)
37 String ip = null;
38
39 @Argument(index = 2, name = "tcpPort", description = "Node TCP listen port",
40 required = false, multiValued = false)
41 int tcpPort = 9876;
42
43 @Override
44 protected void execute() {
45 ClusterAdminService service = get(ClusterAdminService.class);
Pavlin Radoslavov444b5192014-10-28 10:45:19 -070046 service.addNode(new NodeId(nodeId), IpAddress.valueOf(ip), tcpPort);
tom9710fb42014-09-29 11:35:28 -070047 }
48
49}