blob: 81440d0d96a3405079d5843b0201c4925ce87f64 [file] [log] [blame]
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -08001/*
2 * Copyright 2014 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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.cli;
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080017
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
alshabib4785eec2014-12-04 16:45:45 -080020import org.onlab.packet.IpAddress;
Brian O'Connorabafb502014-12-02 22:26:20 -080021import org.onosproject.cluster.ControllerNode;
22import org.onosproject.cluster.DefaultControllerNode;
23import org.onosproject.cluster.NodeId;
24import org.onosproject.store.service.DatabaseAdminService;
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080025
26/**
27 * Adds a new controller cluster node.
28 */
29@Command(scope = "onos", name = "tablet-add",
30 description = "Adds a new member to tablet")
31public class TabletAddCommand extends AbstractShellCommand {
32
33 @Argument(index = 0, name = "nodeId", description = "Node ID",
34 required = true, multiValued = false)
35 String nodeId = null;
36
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080037 @Argument(index = 1, name = "ip", description = "Node IP address",
38 required = true, multiValued = false)
39 String ip = null;
40
41 @Argument(index = 2, name = "tcpPort", description = "Node TCP listen port",
42 required = false, multiValued = false)
43 int tcpPort = 9876;
44
45 // TODO add tablet name argument when we support multiple tablets
46
47 @Override
48 protected void execute() {
49 DatabaseAdminService service = get(DatabaseAdminService.class);
50 ControllerNode node = new DefaultControllerNode(new NodeId(nodeId),
51 IpAddress.valueOf(ip),
52 tcpPort);
53 service.addMember(node);
54 }
55}