blob: 780d9048332db390cb38ae82bd927cb63255c54b [file] [log] [blame]
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +09001/*
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 */
16package org.onosproject.simplefabric;
17
Ray Milkey86ad7bb2018-09-27 12:32:28 -070018import org.apache.karaf.shell.api.action.Argument;
19import org.apache.karaf.shell.api.action.Command;
20import org.apache.karaf.shell.api.action.lifecycle.Service;
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090021import org.onosproject.cli.AbstractShellCommand;
22
23/**
24 * CLI to interact with the SIMPLE_FABRIC application.
25 */
Ray Milkey86ad7bb2018-09-27 12:32:28 -070026@Service
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090027@Command(scope = "onos", name = "simpleFabric",
28 description = "Manages the SimpleFabric application")
29public class SimpleFabricCommand extends AbstractShellCommand {
30
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090031 @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 Milkey86ad7bb2018-09-27 12:32:28 -070037 protected void doExecute() {
Ray Milkey074ba9b2018-02-06 10:23:41 -080038
39 SimpleFabricService simpleFabric = get(SimpleFabricService.class);
40
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090041 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