Hyunsun Moon | 53381e8 | 2017-03-28 19:58:28 +0900 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2017-present 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.onosproject.ofagent.cli; |
| 17 | |
| 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onosproject.cli.AbstractShellCommand; |
| 21 | import org.onosproject.incubator.net.virtual.NetworkId; |
| 22 | import org.onosproject.ofagent.api.OFAgent; |
| 23 | import org.onosproject.ofagent.api.OFAgentAdminService; |
| 24 | |
| 25 | /** |
| 26 | * Removes the existing OFAgent. |
| 27 | */ |
| 28 | @Command(scope = "onos", name = "ofagent-remove", description = "Removes the ofagent") |
| 29 | public class OFAgentRemoveCommand extends AbstractShellCommand { |
| 30 | |
| 31 | @Argument(index = 0, name = "network", description = "Virtual network ID", |
| 32 | required = true, multiValued = false) |
| 33 | private long networkId = NetworkId.NONE.id(); |
| 34 | |
| 35 | @Override |
| 36 | protected void execute() { |
| 37 | OFAgentAdminService adminService = get(OFAgentAdminService.class); |
| 38 | OFAgent removed = adminService.removeAgent(NetworkId.networkId(networkId)); |
| 39 | if (removed != null) { |
| 40 | print("Successfully removed OFAgent for network %s", networkId); |
| 41 | } else { |
| 42 | print("Failed to remove OFAgent for network %s", networkId); |
| 43 | } |
| 44 | } |
| 45 | } |