blob: 3271e8d8e37b95ae356a12fa32174235abc9abe2 [file] [log] [blame]
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +09001/*
Jian Li8df54a92018-08-23 17:01:31 +09002 * Copyright 2018-present Open Networking Foundation
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +09003 *
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 Li8df54a92018-08-23 17:01:31 +090016package org.onosproject.simplefabric.cli;
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090017
Ray Milkey86ad7bb2018-09-27 12:32:28 -070018import org.apache.karaf.shell.api.action.Argument;
19import org.apache.karaf.shell.api.action.Command;
Ray Milkey5417cbe2018-10-10 14:15:42 -070020import org.apache.karaf.shell.api.action.Completion;
Ray Milkey86ad7bb2018-09-27 12:32:28 -070021import org.apache.karaf.shell.api.action.lifecycle.Service;
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090022import org.onosproject.cli.AbstractShellCommand;
Jian Lic7efc1d2018-08-23 16:37:34 +090023import org.onosproject.simplefabric.api.SimpleFabricService;
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090024
25/**
26 * CLI to interact with the SIMPLE_FABRIC application.
27 */
Ray Milkey86ad7bb2018-09-27 12:32:28 -070028@Service
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090029@Command(scope = "onos", name = "simpleFabric",
30 description = "Manages the SimpleFabric application")
31public class SimpleFabricCommand extends AbstractShellCommand {
32
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090033 @Argument(index = 0, name = "command",
34 description = "Command: show|intents|reactive-intents|refresh|flush",
35 required = true, multiValued = false)
Ray Milkey5417cbe2018-10-10 14:15:42 -070036 @Completion(SimpleFabricCommandCompleter.class)
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090037 String command = null;
38
39 @Override
Ray Milkey86ad7bb2018-09-27 12:32:28 -070040 protected void doExecute() {
Ray Milkey074ba9b2018-02-06 10:23:41 -080041
42 SimpleFabricService simpleFabric = get(SimpleFabricService.class);
43
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090044 if (command == null) {
45 print("command not found", command);
46 return;
47 }
48 switch (command) {
49 case "show":
50 simpleFabric.dumpToStream("show", System.out);
51 break;
52 case "intents":
53 simpleFabric.dumpToStream("intents", System.out);
54 break;
55 case "reactive-intents":
56 simpleFabric.dumpToStream("reactive-intents", System.out);
57 break;
58 case "refresh":
59 simpleFabric.triggerRefresh();
60 System.out.println("simple fabric refresh triggered");
61 break;
62 case "flush":
63 simpleFabric.triggerFlush();
64 System.out.println("simple fabric flush triggered");
65 break;
66 default:
67 System.out.println("unknown command: " + command);
68 break;
69 }
70 }
71
72}
73