Thomas Vachuska | f22fd66 | 2021-03-02 22:43:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015-present Open Networking Foundation |
| 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.api.action.Argument; |
| 19 | import org.apache.karaf.shell.api.action.Command; |
| 20 | import org.apache.karaf.shell.api.action.Completion; |
| 21 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
| 22 | import org.onosproject.cfg.ComponentConfigService; |
| 23 | import org.onosproject.cli.AbstractShellCommand; |
| 24 | import org.onosproject.cli.StartStopCompleter; |
| 25 | import org.onosproject.provider.nil.NullProviders; |
| 26 | |
| 27 | import static org.onosproject.cli.StartStopCompleter.START; |
| 28 | |
| 29 | /** |
| 30 | * Starts or stops topology simulation. |
| 31 | */ |
| 32 | @Service |
| 33 | @Command(scope = "onos", name = "null-port-stats", |
| 34 | description = "Starts or stops port statistics simulation") |
| 35 | public class NullPortStatsControlCommand extends AbstractShellCommand { |
| 36 | |
| 37 | @Argument(index = 0, name = "cmd", description = "Control command: start/stop", |
| 38 | required = true) |
| 39 | @Completion(StartStopCompleter.class) |
| 40 | String cmd = null; |
| 41 | |
| 42 | @Override |
| 43 | protected void doExecute() { |
| 44 | ComponentConfigService service = get(ComponentConfigService.class); |
| 45 | NullProviders npService = get(NullProviders.class); |
| 46 | npService.enablePortStats(cmd.equals(START)); |
| 47 | } |
| 48 | |
| 49 | } |