Lee Yongjae | 6dc7e4f | 2017-12-06 16:17:51 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-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.simplefabric; |
| 17 | |
Ray Milkey | 86ad7bb | 2018-09-27 12:32:28 -0700 | [diff] [blame^] | 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; |
Lee Yongjae | 6dc7e4f | 2017-12-06 16:17:51 +0900 | [diff] [blame] | 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | |
| 23 | /** |
| 24 | * CLI to interact with the SIMPLE_FABRIC application. |
| 25 | */ |
Ray Milkey | 86ad7bb | 2018-09-27 12:32:28 -0700 | [diff] [blame^] | 26 | @Service |
Lee Yongjae | 6dc7e4f | 2017-12-06 16:17:51 +0900 | [diff] [blame] | 27 | @Command(scope = "onos", name = "simpleFabric", |
| 28 | description = "Manages the SimpleFabric application") |
| 29 | public class SimpleFabricCommand extends AbstractShellCommand { |
| 30 | |
Lee Yongjae | 6dc7e4f | 2017-12-06 16:17:51 +0900 | [diff] [blame] | 31 | @Argument(index = 0, name = "command", |
| 32 | description = "Command: show|intents|reactive-intents|refresh|flush", |
| 33 | required = true, multiValued = false) |
| 34 | String command = null; |
| 35 | |
| 36 | @Override |
Ray Milkey | 86ad7bb | 2018-09-27 12:32:28 -0700 | [diff] [blame^] | 37 | protected void doExecute() { |
Ray Milkey | 074ba9b | 2018-02-06 10:23:41 -0800 | [diff] [blame] | 38 | |
| 39 | SimpleFabricService simpleFabric = get(SimpleFabricService.class); |
| 40 | |
Lee Yongjae | 6dc7e4f | 2017-12-06 16:17:51 +0900 | [diff] [blame] | 41 | if (command == null) { |
| 42 | print("command not found", command); |
| 43 | return; |
| 44 | } |
| 45 | switch (command) { |
| 46 | case "show": |
| 47 | simpleFabric.dumpToStream("show", System.out); |
| 48 | break; |
| 49 | case "intents": |
| 50 | simpleFabric.dumpToStream("intents", System.out); |
| 51 | break; |
| 52 | case "reactive-intents": |
| 53 | simpleFabric.dumpToStream("reactive-intents", System.out); |
| 54 | break; |
| 55 | case "refresh": |
| 56 | simpleFabric.triggerRefresh(); |
| 57 | System.out.println("simple fabric refresh triggered"); |
| 58 | break; |
| 59 | case "flush": |
| 60 | simpleFabric.triggerFlush(); |
| 61 | System.out.println("simple fabric flush triggered"); |
| 62 | break; |
| 63 | default: |
| 64 | System.out.println("unknown command: " + command); |
| 65 | break; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | } |
| 70 | |