Yuta HIGUCHI | 60731cb | 2014-11-11 01:34:46 -0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onlab.onos.cli; |
| 17 | |
| 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onlab.onos.cluster.ClusterService; |
| 21 | import org.onlab.onos.cluster.ControllerNode; |
| 22 | import org.onlab.onos.cluster.NodeId; |
| 23 | import org.onlab.onos.store.service.DatabaseAdminService; |
| 24 | |
| 25 | /** |
| 26 | * Removes a controller cluster node. |
| 27 | */ |
| 28 | @Command(scope = "onos", name = "tablet-remove", |
| 29 | description = "Removes a member from tablet") |
| 30 | public class TabletRemoveCommand extends AbstractShellCommand { |
| 31 | |
| 32 | @Argument(index = 0, name = "nodeId", description = "Node ID", |
| 33 | required = true, multiValued = false) |
| 34 | String nodeId = null; |
| 35 | |
| 36 | // TODO add tablet name argument when we support multiple tablets |
| 37 | |
| 38 | @Override |
| 39 | protected void execute() { |
| 40 | DatabaseAdminService service = get(DatabaseAdminService.class); |
| 41 | ClusterService clusterService = get(ClusterService.class); |
| 42 | ControllerNode node = clusterService.getNode(new NodeId(nodeId)); |
| 43 | if (node != null) { |
| 44 | service.removeMember(node); |
| 45 | } |
| 46 | } |
| 47 | } |