Tunahan Sezen | 03e5527 | 2020-04-18 09:18:53 +0000 | [diff] [blame] | 1 | /* |
Joey Armstrong | 53fcac2 | 2023-01-11 13:25:01 -0500 | [diff] [blame^] | 2 | * Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Tunahan Sezen | 03e5527 | 2020-04-18 09:18:53 +0000 | [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 | package org.opencord.maclearner.app.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.opencord.maclearner.api.MacLearnerService; |
| 22 | import org.onosproject.cli.AbstractShellCommand; |
| 23 | import org.onosproject.net.DeviceId; |
| 24 | import org.onosproject.net.PortNumber; |
| 25 | |
| 26 | /** |
| 27 | * Removes a port of device from Ignore Map. |
| 28 | */ |
| 29 | @Service |
| 30 | @Command(scope = "onos", name = "mac-learner-remove-ignore-port", |
| 31 | description = "Removes a port of device from Ignore Map") |
| 32 | public class MacLearnerRemoveIgnorePort extends AbstractShellCommand { |
| 33 | |
| 34 | @Argument(index = 0, name = "deviceId", |
| 35 | description = "OpenFlow Device Id", |
| 36 | required = true) |
| 37 | String devId = null; |
| 38 | |
| 39 | @Argument(index = 1, name = "portNo", |
| 40 | description = "Integer value of Port Number", |
| 41 | required = true) |
| 42 | Integer portNo; |
| 43 | |
| 44 | @Override |
| 45 | protected void doExecute() { |
| 46 | try { |
| 47 | MacLearnerService macLearnerService = AbstractShellCommand.get(MacLearnerService.class); |
| 48 | macLearnerService.removeFromIgnoredPorts(DeviceId.deviceId(devId), |
| 49 | PortNumber.portNumber(portNo)); |
| 50 | |
| 51 | } catch (IllegalArgumentException e) { |
| 52 | String msg = String.format("Exception occurred while executing %s command", |
| 53 | this.getClass().getSimpleName()); |
| 54 | print(msg); |
| 55 | log.error(msg, e); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | } |