alshabib | bf70b08 | 2016-02-03 10:25:49 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | d6a135a | 2017-08-03 22:46:05 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
alshabib | bf70b08 | 2016-02-03 10:25:49 -0800 | [diff] [blame] | 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 | |
alshabib | 36a4d73 | 2016-06-01 16:03:59 -0700 | [diff] [blame] | 17 | package org.opencord.olt.cli; |
alshabib | bf70b08 | 2016-02-03 10:25:49 -0800 | [diff] [blame] | 18 | |
Carmelo Cascone | ca93116 | 2019-07-15 18:22:24 -0700 | [diff] [blame] | 19 | import org.apache.karaf.shell.api.action.Argument; |
| 20 | import org.apache.karaf.shell.api.action.Command; |
| 21 | import org.apache.karaf.shell.api.action.Completion; |
| 22 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
alshabib | bf70b08 | 2016-02-03 10:25:49 -0800 | [diff] [blame] | 23 | import org.onosproject.cli.AbstractShellCommand; |
Carmelo Cascone | ca93116 | 2019-07-15 18:22:24 -0700 | [diff] [blame] | 24 | import org.onosproject.cli.net.DeviceIdCompleter; |
alshabib | bf70b08 | 2016-02-03 10:25:49 -0800 | [diff] [blame] | 25 | import org.onosproject.net.ConnectPoint; |
| 26 | import org.onosproject.net.DeviceId; |
| 27 | import org.onosproject.net.PortNumber; |
alshabib | 36a4d73 | 2016-06-01 16:03:59 -0700 | [diff] [blame] | 28 | import org.opencord.olt.AccessDeviceService; |
alshabib | bf70b08 | 2016-02-03 10:25:49 -0800 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * Adds a subscriber to an access device. |
| 32 | */ |
Carmelo Cascone | ca93116 | 2019-07-15 18:22:24 -0700 | [diff] [blame] | 33 | @Service |
Saurav Das | 82b8e6d | 2018-10-04 15:25:12 -0700 | [diff] [blame] | 34 | @Command(scope = "onos", name = "volt-remove-subscriber-access", |
Saurav Das | eae48de | 2019-06-19 13:26:15 -0700 | [diff] [blame] | 35 | description = "Removes a subscriber to an access device") |
alshabib | bf70b08 | 2016-02-03 10:25:49 -0800 | [diff] [blame] | 36 | public class SubscriberRemoveCommand extends AbstractShellCommand { |
| 37 | |
| 38 | @Argument(index = 0, name = "deviceId", description = "Access device ID", |
| 39 | required = true, multiValued = false) |
Carmelo Cascone | ca93116 | 2019-07-15 18:22:24 -0700 | [diff] [blame] | 40 | @Completion(DeviceIdCompleter.class) |
alshabib | bf70b08 | 2016-02-03 10:25:49 -0800 | [diff] [blame] | 41 | private String strDeviceId = null; |
| 42 | |
| 43 | @Argument(index = 1, name = "port", description = "Subscriber port number", |
| 44 | required = true, multiValued = false) |
| 45 | private String strPort = null; |
| 46 | |
| 47 | @Override |
Carmelo Cascone | ca93116 | 2019-07-15 18:22:24 -0700 | [diff] [blame] | 48 | protected void doExecute() { |
alshabib | bf70b08 | 2016-02-03 10:25:49 -0800 | [diff] [blame] | 49 | AccessDeviceService service = AbstractShellCommand.get(AccessDeviceService.class); |
| 50 | |
| 51 | DeviceId deviceId = DeviceId.deviceId(strDeviceId); |
| 52 | PortNumber port = PortNumber.portNumber(strPort); |
| 53 | ConnectPoint connectPoint = new ConnectPoint(deviceId, port); |
| 54 | |
| 55 | service.removeSubscriber(connectPoint); |
| 56 | |
| 57 | } |
| 58 | } |