blob: d15ac87b7c9a6383c0e96e1bb13bc1ade5b85893 [file] [log] [blame]
Charles Chan33f4a912018-04-19 23:35:30 -07001/*
2 * Copyright 2018-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.cli.net;
17
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import org.onlab.osgi.ServiceNotFoundException;
21import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.net.flowobjective.FlowObjectiveService;
23
24/**
25 * Clear flow objective that are waiting for the completion of previous objective with the same key.
26 */
27@Command(scope = "onos", name = "obj-clear-queues",
28 description = "Force empty flow objective queues and invalidate flow objective caches")
29public class FlowObjectiveQueueClearCommand extends AbstractShellCommand {
30
31 private static final String CONFIRM_PHRASE = "please";
32 @Argument(name = "confirm", description = "Confirmation phrase")
33 private String please = null;
34
35 @Override
36 protected void execute() {
37 if (please == null || !please.equals(CONFIRM_PHRASE)) {
38 print("WARNING: System may enter an unpredictable state if the flow obj queues are force emptied." +
39 "Enter confirmation phrase to continue.");
40 return;
41 }
42
43 try {
44 FlowObjectiveService service = get(FlowObjectiveService.class);
45 service.clearQueue();
46 } catch (ServiceNotFoundException e) {
47 print("FlowObjectiveService unavailable");
48 }
49 }
50
51}