Thomas Vachuska | c40d463 | 2015-04-09 16:55:03 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | c40d463 | 2015-04-09 16:55:03 -0700 | [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.onosproject.provider.nil.cli; |
| 17 | |
| 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onosproject.cfg.ComponentConfigService; |
| 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.onosproject.provider.nil.NullProviders; |
| 23 | |
| 24 | import static org.onosproject.cli.StartStopCompleter.START; |
| 25 | |
| 26 | /** |
| 27 | * Starts or stops topology simulation. |
| 28 | */ |
| 29 | @Command(scope = "onos", name = "null-simulation", |
| 30 | description = "Starts or stops topology simulation") |
| 31 | public class NullControlCommand extends AbstractShellCommand { |
| 32 | |
| 33 | @Argument(index = 0, name = "cmd", description = "Control command: start/stop", |
| 34 | required = true, multiValued = false) |
| 35 | String cmd = null; |
| 36 | |
| 37 | @Argument(index = 1, name = "topoShape", |
Andreas Pantelopoulos | 620d3d7 | 2016-11-08 22:18:59 +0100 | [diff] [blame] | 38 | description = "Topology shape: e.g. configured, linear, reroute, centipede, tree, spineleaf, " + |
| 39 | ", mesh, fattree", |
Thomas Vachuska | c40d463 | 2015-04-09 16:55:03 -0700 | [diff] [blame] | 40 | required = false, multiValued = false) |
| 41 | String topoShape = null; |
| 42 | |
| 43 | @Override |
| 44 | protected void execute() { |
| 45 | ComponentConfigService service = get(ComponentConfigService.class); |
| 46 | if (topoShape != null) { |
| 47 | service.setProperty(NullProviders.class.getName(), "topoShape", topoShape); |
| 48 | } |
| 49 | service.setProperty(NullProviders.class.getName(), "enabled", |
| 50 | cmd.equals(START) ? "true" : "false"); |
| 51 | } |
| 52 | |
| 53 | } |