Thomas Vachuska | 90b453f | 2015-01-30 18:57:14 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2015 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.cli.app; |
| 17 | |
| 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onosproject.app.ApplicationAdminService; |
| 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.onosproject.core.ApplicationId; |
| 23 | |
| 24 | /** |
| 25 | * Deactivates an installed application. |
| 26 | */ |
| 27 | @Command(scope = "onos", name = "app-deactivate", |
| 28 | description = "Deactivates an installed application") |
| 29 | public class ApplicationDeactivateCommand extends AbstractShellCommand { |
| 30 | |
| 31 | @Argument(index = 0, name = "name", description = "Application name", |
| 32 | required = true, multiValued = false) |
| 33 | String name = null; |
| 34 | |
| 35 | @Override |
| 36 | protected void execute() { |
| 37 | ApplicationAdminService service = get(ApplicationAdminService.class); |
| 38 | ApplicationId appId = service.getId(name); |
| 39 | if (appId != null) { |
| 40 | service.deactivate(appId); |
| 41 | } else { |
| 42 | print("No such application: %s", name); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | } |