Java Code Examples for org.apache.karaf.shell.support.completers.StringsCompleter#complete()

The following examples show how to use org.apache.karaf.shell.support.completers.StringsCompleter#complete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CfmDeviceIdCompleter.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();

    // Fetch our service and feed it's offerings to the string completer
    DeviceService service = AbstractShellCommand.get(DeviceService.class);
    Iterator<Device> it = service.getDevices().iterator();
    SortedSet<String> strings = delegate.getStrings();
    while (it.hasNext()) {
        Device device = it.next();
        if (device.is(CfmMepProgrammable.class)) {
            strings.add(device.id().toString());
        }
    }

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
 
Example 2
Source File: HostIdCompleter.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();

    HostService service = AbstractShellCommand.get(HostService.class);
    Iterator<Host> it = service.getHosts().iterator();
    SortedSet<String> strings = delegate.getStrings();
    while (it.hasNext()) {
        strings.add(it.next().id().toString());
    }

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);

}
 
Example 3
Source File: IntentKeyCompleter.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();

    // Fetch our service and feed it's offerings to the string completer
    IntentService service = AbstractShellCommand.get(IntentService.class);
    Iterator<Intent> it = service.getIntents().iterator();
    SortedSet<String> strings = delegate.getStrings();
    while (it.hasNext()) {
        strings.add(it.next().key().toString());
    }

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
 
Example 4
Source File: DirectPortListCompleter.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter delegate = new StringsCompleter();
    OpenstackNetworkService osNetService = get(OpenstackNetworkService.class);
    Set<String> set = osNetService.ports().stream()
            .filter(port -> port.getvNicType().equals(DIRECT))
            .map(Port::getId)
            .collect(Collectors.toSet());

    SortedSet<String> strings = delegate.getStrings();
    Iterator<String> it = set.iterator();

    while (it.hasNext()) {
        strings.add(it.next());
    }
    return delegate.complete(session, commandLine, candidates);
}
 
Example 5
Source File: IntentKeyImrCompleter.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();

    // Fetch our service and feed it's offerings to the string completer
    IntentService service = AbstractShellCommand.get(IntentService.class);
    SortedSet<String> strings = delegate.getStrings();
    service.getIntents().forEach(intent -> {
        if (intent instanceof LinkCollectionIntent
                || intent instanceof PointToPointIntent) {
            strings.add(intent.key().toString());
        }
    });

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
 
Example 6
Source File: KeySpaceCompleter.java    From Karaf-Cassandra with Apache License 2.0 6 votes vote down vote up
public int complete(Session session, CommandLine commandLine,
		List<String> candidates) {
	StringsCompleter delegate = new StringsCompleter();

	com.datastax.driver.core.Session cassandraSession = (com.datastax.driver.core.Session) session
			.get(SessionParameter.CASSANDRA_SESSION);

	if (cassandraSession == null) {
		System.err
				.println("No active session found--run the connect command first");
		return 0;
		// return delegate.complete(session, commandLine, candidates);
	}

	CompleterCommons.completeKeySpace(delegate, cassandraSession);

	return delegate.complete(session, commandLine, candidates);
}
 
Example 7
Source File: EthTypeCompleter.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();
    SortedSet<String> strings = delegate.getStrings();

    for (EthType eth : EthType.values()) {
        strings.add(eth.toString());
    }

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
 
Example 8
Source File: K8sHostnameCompleter.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter delegate = new StringsCompleter();
    K8sNodeService nodeService = get(K8sNodeService.class);

    Set<String> hostnames = nodeService.nodes().stream()
            .map(K8sNode::hostname)
            .collect(Collectors.toSet());
    SortedSet<String> strings = delegate.getStrings();

    strings.addAll(hostnames);

    return delegate.complete(session, commandLine, candidates);
}
 
Example 9
Source File: TargetCompleter.java    From roboconf-platform with Apache License 2.0 5 votes vote down vote up
@Override
public int complete( Session session, CommandLine commandLine, List<String> candidates ) {

	StringsCompleter delegate = new StringsCompleter( false );
	delegate.getStrings().addAll( SupportedTarget.allString());

	return delegate.complete( session, commandLine, candidates );
}
 
Example 10
Source File: FreeIpCompleter.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();
    DhcpService dhcpService = AbstractShellCommand.get(DhcpService.class);
    Iterator<Ip4Address> it = dhcpService.getAvailableIPs().iterator();
    SortedSet<String> strings = delegate.getStrings();

    while (it.hasNext()) {
        strings.add(it.next().toString());
    }

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
 
Example 11
Source File: AlertUUIDCompleter.java    From karaf-decanter with Apache License 2.0 5 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates){
    StringsCompleter delegate = new StringsCompleter();
    try {
        for (Alert alert : store.list()) {
            delegate.getStrings().add(alert.get("alertUUID").toString());
        }
    } catch (Exception e) {
        // nothing to do
    }
    return delegate.complete(session, commandLine, candidates);
}
 
Example 12
Source File: AbstractChoicesCompleter.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    this.session = session;
    this.commandLine = commandLine;
    StringsCompleter delegate = new StringsCompleter();
    SortedSet<String> strings = delegate.getStrings();
    choices().forEach(strings::add);
    return delegate.complete(session, commandLine, candidates);
}
 
Example 13
Source File: RoleCompleter.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();
    SortedSet<String> strings = delegate.getStrings();
    strings.add(MastershipRole.MASTER.toString().toLowerCase());
    strings.add(MastershipRole.STANDBY.toString().toLowerCase());
    strings.add(MastershipRole.NONE.toString().toLowerCase());

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
 
Example 14
Source File: FlowRuleStatusCompleter.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();

    FlowEntryState[] states = FlowEntryState.values();
    SortedSet<String> strings = delegate.getStrings();
    for (int i = 0; i < states.length; i++) {
        strings.add(states[i].toString().toLowerCase());
    }
    strings.add(FlowsListCommand.ANY);

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
 
Example 15
Source File: PlaceholderCompleter.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Populate a string completer with what the user has typed so far
    StringsCompleter delegate = new StringsCompleter();
    SortedSet<String> strings = delegate.getStrings();
    if (commandLine.getCursorArgument() != null) {
        strings.add(commandLine.getCursorArgument());
    }
    return delegate.complete(session, commandLine, candidates);
}
 
Example 16
Source File: IpProtocolCompleter.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();
    SortedSet<String> strings = delegate.getStrings();

    for (IpProtocol ip : IpProtocol.values()) {
        strings.add(ip.toString());
    }

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
 
Example 17
Source File: ComponentNameCompleter.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();

    // Fetch our service and feed it's offerings to the string completer
    ComponentConfigService service = AbstractShellCommand.get(ComponentConfigService.class);
    SortedSet<String> strings = delegate.getStrings();
    service.getComponentNames().forEach(strings::add);

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
 
Example 18
Source File: DhcpRelayCounterCompleter.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();
    SortedSet<String> strings = delegate.getStrings();
    strings.add("counter");

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
 
Example 19
Source File: ActiveVmIpCompleter.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter delegate = new StringsCompleter();
    InstancePortService service = AbstractShellCommand.get(InstancePortService.class);
    Set<String> set = service.instancePorts().stream()
            .filter(p -> p.state() == InstancePort.State.ACTIVE)
            .map(p -> p.ipAddress().getIp4Address().toString())
            .collect(Collectors.toSet());

    SortedSet<String> strings = delegate.getStrings();
    strings.addAll(set);

    return delegate.complete(session, commandLine, candidates);
}
 
Example 20
Source File: AbstractCompleter.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter delegate = new StringsCompleter();

    return delegate.complete(session, commandLine, candidates);
}