[ONOS-7732] Automating switch workflow - workflow event map cli completer

Change-Id: I2fbabf4b42ab99fcf439e6b5864b5c1a53c1530f
This commit is contained in:
jaegonkim 2019-04-06 16:27:09 +09:00
parent 024f44c902
commit 50370b5664
2 changed files with 41 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.Completion;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.workflow.api.ContextEventMapStore;
@ -32,7 +33,11 @@ import java.util.Objects;
@Command(scope = "onos", name = "workflow-eventmap", description = "workflow event map cli")
public class WorkFlowEventMapCommand extends AbstractShellCommand {
@Argument(index = 0, name = "cmd", description = "command(print)", required = true)
static final String PRINT = "print";
@Argument(index = 0, name = "cmd",
description = "command(" + PRINT + ")", required = true)
@Completion(WorkFlowEventMapCompleter.class)
private String cmd = null;
@Override
@ -45,7 +50,7 @@ public class WorkFlowEventMapCommand extends AbstractShellCommand {
ContextEventMapStore store = get(ContextEventMapStore.class);
try {
switch (cmd) {
case "print":
case PRINT:
JsonNode tree = store.asJsonTree();
ObjectMapper mapper = new ObjectMapper();
try {

View File

@ -0,0 +1,34 @@
/*
* Copyright 2019-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.workflow.cli;
import com.google.common.collect.ImmutableList;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.onosproject.cli.AbstractChoicesCompleter;
import java.util.List;
import static org.onosproject.workflow.cli.WorkFlowEventMapCommand.PRINT;
/**
* Workflow event map command completer.
*/
@Service
public class WorkFlowEventMapCompleter extends AbstractChoicesCompleter {
@Override
protected List<String> choices() {
return ImmutableList.of(PRINT); }
}