Charles Chan | 7f987c5 | 2018-07-31 18:22:46 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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.onosproject.l2lb.cli; |
| 17 | |
| 18 | import org.apache.karaf.shell.api.action.Argument; |
| 19 | import org.apache.karaf.shell.api.action.Command; |
| 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
| 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.onosproject.l2lb.api.L2LbAdminService; |
| 23 | import org.onosproject.net.DeviceId; |
| 24 | |
| 25 | /** |
| 26 | * Command to remove a L2 load balancer. |
| 27 | */ |
| 28 | @Service |
| 29 | @Command(scope = "onos", name = "l2lb-remove", description = "Remove L2 load balancers ") |
| 30 | public class L2LbRemoveCommand extends AbstractShellCommand { |
| 31 | @Argument(index = 0, name = "deviceId", |
| 32 | description = "Device ID", |
| 33 | required = true, multiValued = false) |
| 34 | private String deviceIdStr; |
| 35 | |
| 36 | @Argument(index = 1, name = "key", |
| 37 | description = "L2 load balancer key", |
| 38 | required = true, multiValued = false) |
| 39 | private String keyStr; |
| 40 | |
| 41 | @Override |
| 42 | protected void doExecute() { |
| 43 | DeviceId deviceId = DeviceId.deviceId(deviceIdStr); |
| 44 | int l2LbPort = Integer.parseInt(keyStr); |
| 45 | |
| 46 | L2LbAdminService l2LbAdminService = get(L2LbAdminService.class); |
| 47 | l2LbAdminService.remove(deviceId, l2LbPort); |
| 48 | } |
| 49 | } |