blob: b7d413c528941d103817a1a914fd57ec8b7d2e7b [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
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import org.onosproject.cli.AbstractShellCommand;
Jian Lic7efc1d2018-08-23 16:37:34 +090021import org.onosproject.simplefabric.api.SimpleFabricService;
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090022
23/**
24 * CLI to interact with the SIMPLE_FABRIC application.
25 */
26@Command(scope = "onos", name = "simpleFabric",
27 description = "Manages the SimpleFabric application")
28public class SimpleFabricCommand extends AbstractShellCommand {
29
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090030 @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 Milkey074ba9b2018-02-06 10:23:41 -080037
38 SimpleFabricService simpleFabric = get(SimpleFabricService.class);
39
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +090040 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