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