Thomas Vachuska | 7d693f5 | 2014-10-21 19:17:57 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Thomas Vachuska | 7d693f5 | 2014-10-21 19:17:57 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
Thomas Vachuska | 7d693f5 | 2014-10-21 19:17:57 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 7d693f5 | 2014-10-21 19:17:57 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.cli; |
tom | 9710fb4 | 2014-09-29 11:35:28 -0700 | [diff] [blame] | 17 | |
| 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.cluster.ClusterAdminService; |
Thomas Vachuska | de563cf | 2015-04-01 00:28:50 -0700 | [diff] [blame] | 21 | import org.onosproject.cluster.DefaultControllerNode; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 22 | import org.onosproject.cluster.NodeId; |
Pavlin Radoslavov | 444b519 | 2014-10-28 10:45:19 -0700 | [diff] [blame] | 23 | import org.onlab.packet.IpAddress; |
tom | 9710fb4 | 2014-09-29 11:35:28 -0700 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * Adds a new controller cluster node. |
| 27 | */ |
| 28 | @Command(scope = "onos", name = "add-node", |
| 29 | description = "Adds a new controller cluster node") |
| 30 | public class NodeAddCommand extends AbstractShellCommand { |
| 31 | |
| 32 | @Argument(index = 0, name = "nodeId", description = "Node ID", |
| 33 | required = true, multiValued = false) |
| 34 | String nodeId = null; |
| 35 | |
| 36 | @Argument(index = 1, name = "ip", description = "Node IP address", |
| 37 | required = true, multiValued = false) |
| 38 | String ip = null; |
| 39 | |
| 40 | @Argument(index = 2, name = "tcpPort", description = "Node TCP listen port", |
| 41 | required = false, multiValued = false) |
Thomas Vachuska | de563cf | 2015-04-01 00:28:50 -0700 | [diff] [blame] | 42 | int tcpPort = DefaultControllerNode.DEFAULT_PORT; |
tom | 9710fb4 | 2014-09-29 11:35:28 -0700 | [diff] [blame] | 43 | |
| 44 | @Override |
| 45 | protected void execute() { |
| 46 | ClusterAdminService service = get(ClusterAdminService.class); |
Pavlin Radoslavov | 444b519 | 2014-10-28 10:45:19 -0700 | [diff] [blame] | 47 | service.addNode(new NodeId(nodeId), IpAddress.valueOf(ip), tcpPort); |
tom | 9710fb4 | 2014-09-29 11:35:28 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | } |