blob: a7cdff76def069151b462ee6fc8fe8aa6ebf5e50 [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 */
16package org.onlab.onos.cli;
17
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import org.onlab.onos.cluster.ControllerNode;
21import org.onlab.onos.cluster.DefaultControllerNode;
22import org.onlab.onos.cluster.NodeId;
23import org.onlab.onos.store.service.DatabaseAdminService;
24import org.onlab.packet.IpAddress;
25
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
37 // TODO context aware completer to get IP from ClusterService?
38 @Argument(index = 1, name = "ip", description = "Node IP address",
39 required = true, multiValued = false)
40 String ip = null;
41
42 @Argument(index = 2, name = "tcpPort", description = "Node TCP listen port",
43 required = false, multiValued = false)
44 int tcpPort = 9876;
45
46 // TODO add tablet name argument when we support multiple tablets
47
48 @Override
49 protected void execute() {
50 DatabaseAdminService service = get(DatabaseAdminService.class);
51 ControllerNode node = new DefaultControllerNode(new NodeId(nodeId),
52 IpAddress.valueOf(ip),
53 tcpPort);
54 service.addMember(node);
55 }
56}