blob: b51525991405d75285606d840c44a4d0ae639761 [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
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import org.onosproject.cli.AbstractShellCommand;
21
22/**
23 * CLI to interact with the SIMPLE_FABRIC application.
24 */
25@Command(scope = "onos", name = "simpleFabric",
26 description = "Manages the SimpleFabric application")
27public class SimpleFabricCommand extends AbstractShellCommand {
28
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090029 @Argument(index = 0, name = "command",
30 description = "Command: show|intents|reactive-intents|refresh|flush",
31 required = true, multiValued = false)
32 String command = null;
33
34 @Override
35 protected void execute() {
Ray Milkey074ba9b2018-02-06 10:23:41 -080036
37 SimpleFabricService simpleFabric = get(SimpleFabricService.class);
38
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090039 if (command == null) {
40 print("command not found", command);
41 return;
42 }
43 switch (command) {
44 case "show":
45 simpleFabric.dumpToStream("show", System.out);
46 break;
47 case "intents":
48 simpleFabric.dumpToStream("intents", System.out);
49 break;
50 case "reactive-intents":
51 simpleFabric.dumpToStream("reactive-intents", System.out);
52 break;
53 case "refresh":
54 simpleFabric.triggerRefresh();
55 System.out.println("simple fabric refresh triggered");
56 break;
57 case "flush":
58 simpleFabric.triggerFlush();
59 System.out.println("simple fabric flush triggered");
60 break;
61 default:
62 System.out.println("unknown command: " + command);
63 break;
64 }
65 }
66
67}
68