mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-05-05 04:06:49 +02:00
[ONOS-7732] Automating switch workflow: workflow store cli command completeter
Change-Id: Ieb2a4d60f4d567f4a7117b734691178c79ef1d26
This commit is contained in:
parent
5504bd2524
commit
a929a2ebc7
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 org.apache.karaf.shell.api.action.lifecycle.Service;
|
||||
import org.onosproject.cli.AbstractChoicesCompleter;
|
||||
import org.onosproject.workflow.api.WorkflowStore;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.onlab.osgi.DefaultServiceDirectory.getService;
|
||||
|
||||
/**
|
||||
* Workflow ID completer.
|
||||
*/
|
||||
@Service
|
||||
public class WorkFlowIdCompleter extends AbstractChoicesCompleter {
|
||||
@Override
|
||||
protected List<String> choices() {
|
||||
WorkflowStore workflowStore = getService(WorkflowStore.class);
|
||||
return workflowStore.getAll().stream()
|
||||
.map(workflow -> workflow.id().toString())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,7 @@ package org.onosproject.workflow.cli;
|
||||
|
||||
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.Workflow;
|
||||
@ -29,10 +30,16 @@ import java.net.URI;
|
||||
@Command(scope = "onos", name = "workflowstore", description = "workflow store cli")
|
||||
public class WorkFlowStoreCommand extends AbstractShellCommand {
|
||||
|
||||
@Argument(index = 0, name = "cmd", description = "command(rm)", required = false)
|
||||
static final String RM = "rm";
|
||||
|
||||
@Argument(index = 0, name = "cmd",
|
||||
description = "command(" + RM + ")", required = false)
|
||||
@Completion(WorkFlowStoreCompleter.class)
|
||||
private String cmd = null;
|
||||
|
||||
@Argument(index = 1, name = "id", description = "workflow id(URI)", required = false)
|
||||
@Argument(index = 1, name = "id",
|
||||
description = "workflow id(URI)", required = false)
|
||||
@Completion(WorkFlowIdCompleter.class)
|
||||
private String id = null;
|
||||
|
||||
@Override
|
||||
@ -49,7 +56,7 @@ public class WorkFlowStoreCommand extends AbstractShellCommand {
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case "rm":
|
||||
case RM:
|
||||
rmWorkflow(id);
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.WorkFlowStoreCommand.RM;
|
||||
|
||||
/**
|
||||
* Workflow Store command completer.
|
||||
*/
|
||||
@Service
|
||||
public class WorkFlowStoreCompleter extends AbstractChoicesCompleter {
|
||||
@Override
|
||||
protected List<String> choices() {
|
||||
return ImmutableList.of(RM);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user