Java Code Examples for org.apache.karaf.shell.support.completers.StringsCompleter
The following examples show how to use
org.apache.karaf.shell.support.completers.StringsCompleter. These examples are extracted from open source projects.
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 Project: onos-p4-tutorial Source File: Srv6SidCompleter.java License: Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { DeviceService deviceService = AbstractShellCommand.get(DeviceService.class); NetworkConfigService netCfgService = AbstractShellCommand.get(NetworkConfigService.class); // Delegate string completer StringsCompleter delegate = new StringsCompleter(); SortedSet<String> strings = delegate.getStrings(); stream(deviceService.getDevices()) .map(d -> netCfgService.getConfig(d.id(), Srv6DeviceConfig.class)) .filter(Objects::nonNull) .map(Srv6DeviceConfig::mySid) .filter(Objects::nonNull) .forEach(sid -> strings.add(sid.toString())); // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 2
Source Project: onos-p4-tutorial Source File: Srv6SidCompleter.java License: Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { DeviceService deviceService = AbstractShellCommand.get(DeviceService.class); NetworkConfigService netCfgService = AbstractShellCommand.get(NetworkConfigService.class); // Delegate string completer StringsCompleter delegate = new StringsCompleter(); SortedSet<String> strings = delegate.getStrings(); stream(deviceService.getDevices()) .map(d -> netCfgService.getConfig(d.id(), Srv6DeviceConfig.class)) .filter(Objects::nonNull) .map(Srv6DeviceConfig::mySid) .filter(Objects::nonNull) .forEach(sid -> strings.add(sid.toString())); // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 3
Source Project: Karaf-Cassandra Source File: KeySpaceCompleter.java License: Apache License 2.0 | 6 votes |
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 4
Source Project: roboconf-platform Source File: ScopedInstanceCompleter.java License: Apache License 2.0 | 6 votes |
@Override public int complete( Session session, CommandLine commandLine, List<String> candidates ) { // Scoped instance path should be the third argument, preceded by an application name. String applicationName = null; int position = commandLine.getCursorArgumentIndex(); if( position > 0 ) applicationName = commandLine.getArguments()[ position - 1 ]; // Find the instances... StringsCompleter delegate = new StringsCompleter( false ); ManagedApplication ma; if( ! Utils.isEmptyOrWhitespaces( applicationName ) && ( ma = this.manager.applicationMngr().findManagedApplicationByName( applicationName )) != null ) { for( Instance inst : InstanceHelpers.findAllScopedInstances( ma.getApplication())) delegate.getStrings().add( InstanceHelpers.computeInstancePath( inst )); } return delegate.complete( session, commandLine, candidates ); }
Example 5
Source Project: cxf Source File: BusCompleter.java License: Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> list) { StringsCompleter delegate = new StringsCompleter(); try { List<Bus> busses = getBusses(); for (Bus bus : busses) { delegate.getStrings().add(bus.getId()); } } catch (Exception e) { // Ignore } return delegate.complete(session, commandLine, list); }
Example 6
Source Project: cxf Source File: EndpointCompleterSupport.java License: Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> list) { StringsCompleter delegate = new StringsCompleter(); try { List<Bus> busses = getBusses(); for (Bus b : busses) { ServerRegistry reg = b.getExtension(ServerRegistry.class); List<Server> servers = reg.getServers(); for (Server serv : servers) { if (acceptsFeature(serv)) { String qname = serv.getEndpoint().getEndpointInfo().getName().getLocalPart(); delegate.getStrings().add(qname); } } } } catch (Exception e) { // Ignore } return delegate.complete(session, commandLine, list); }
Example 7
Source Project: onos Source File: ComponentPropertyNameCompleter.java License: Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { // Delegate string completer StringsCompleter delegate = new StringsCompleter(); // Component name is the previous argument. String componentName = commandLine.getArguments()[commandLine.getCursorArgumentIndex() - 1]; ComponentConfigService service = get(ComponentConfigService.class); SortedSet<String> strings = delegate.getStrings(); Set<ConfigProperty> properties = service.getProperties(componentName); if (properties != null) { properties.forEach(property -> strings.add(property.name())); } // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 8
Source Project: onos Source File: ReviewApplicationNameCompleter.java License: Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { // Delegate string completer StringsCompleter delegate = new StringsCompleter(); ApplicationService service = get(ApplicationService.class); Iterator<Application> it = service.getApplications().iterator(); SortedSet<String> strings = delegate.getStrings(); while (it.hasNext()) { Application app = it.next(); ApplicationState state = service.getState(app.id()); // if (previousApps.contains(app.id().name())) { // continue; // } if (state == INSTALLED) { strings.add(app.id().name()); } } // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 9
Source Project: onos Source File: ApplicationIdWithIntentNameCompleter.java License: Apache License 2.0 | 6 votes |
@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 -> strings.add(intent.appId().name())); // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 10
Source Project: onos Source File: NodeIdCompleter.java License: Apache License 2.0 | 6 votes |
@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 ClusterService service = AbstractShellCommand.get(ClusterService.class); Iterator<ControllerNode> it = service.getNodes().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 11
Source Project: onos Source File: HostIdCompleter.java License: Apache License 2.0 | 6 votes |
@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 12
Source Project: onos Source File: ConnectPointCompleter.java License: Apache License 2.0 | 6 votes |
@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); // Generate the device ID/port number identifiers for (Device device : service.getDevices()) { SortedSet<String> strings = delegate.getStrings(); for (Port port : service.getPorts(device.id())) { if (!port.number().isLogical()) { strings.add(device.id().toString() + "/" + port.number()); } } } // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 13
Source Project: onos Source File: ClusterIdCompleter.java License: Apache License 2.0 | 6 votes |
@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 TopologyService service = AbstractShellCommand.get(TopologyService.class); Topology topology = service.currentTopology(); SortedSet<String> strings = delegate.getStrings(); for (TopologyCluster cluster : service.getClusters(topology)) { strings.add(Integer.toString(cluster.id().index())); } // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 14
Source Project: onos Source File: OpticalConnectPointCompleter.java License: Apache License 2.0 | 6 votes |
@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); // Generate the device ID/port number identifiers for (Device device : service.getDevices()) { SortedSet<String> strings = delegate.getStrings(); for (Port port : service.getPorts(device.id())) { if (!port.number().isLogical() && (port.type().equals(Port.Type.OCH) || port.type().equals(Port.Type.OMS) || port.type().equals(Port.Type.OTU))) { strings.add(device.id().toString() + "/" + port.number()); } } } // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 15
Source Project: onos Source File: DeviceIdCompleter.java License: Apache License 2.0 | 6 votes |
@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()) { 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 16
Source Project: onos Source File: IntentKeyCompleter.java License: Apache License 2.0 | 6 votes |
@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 17
Source Project: onos Source File: LinkDstCompleter.java License: Apache License 2.0 | 6 votes |
@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 LinkService service = AbstractShellCommand.get(LinkService.class); // Link source the previous argument. String srcArg = commandLine.getArguments()[commandLine.getCursorArgumentIndex() - 1]; // Generate the device ID/port number identifiers SortedSet<String> strings = delegate.getStrings(); try { ConnectPoint src = ConnectPoint.deviceConnectPoint(srcArg); service.getEgressLinks(src) .forEach(link -> strings.add(link.dst().elementId().toString() + "/" + link.dst().port())); } catch (NumberFormatException e) { System.err.println("Invalid connect-point"); } // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 18
Source Project: onos Source File: NetconfOperationCompleter.java License: Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { // Delegate string completer StringsCompleter delegate = new StringsCompleter(); SortedSet<String> strings = delegate.getStrings(); // The available operations are defined in NETCONF protocol (https://tools.ietf.org/html/rfc6241#section-7). strings.add("get"); strings.add("get-config"); strings.add("edit-config"); strings.add("copy-config"); strings.add("delete-config"); strings.add("lock"); strings.add("unlock"); strings.add("close-session"); strings.add("kill-session"); return delegate.complete(session, commandLine, candidates); }
Example 19
Source Project: onos Source File: DomainIdCompleter.java License: Apache License 2.0 | 6 votes |
@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 DomainService service = AbstractShellCommand.get(DomainService.class); Iterator<DomainId> it = service.getDomainIds().iterator(); SortedSet<String> strings = delegate.getStrings(); while (it.hasNext()) { strings.add(it.next().id()); } // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 20
Source Project: onos Source File: LinkSrcCompleter.java License: Apache License 2.0 | 6 votes |
@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 LinkService service = AbstractShellCommand.get(LinkService.class); // Generate the device ID/port number identifiers SortedSet<String> strings = delegate.getStrings(); service.getLinks() .forEach(link -> strings.add(link.src().elementId().toString() + "/" + link.src().port())); // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 21
Source Project: onos Source File: ApplicationNameImrCompleter.java License: Apache License 2.0 | 6 votes |
@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 -> strings.add(intent.appId().name())); // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 22
Source Project: onos Source File: IntentKeyImrCompleter.java License: Apache License 2.0 | 6 votes |
@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 23
Source Project: onos Source File: ApplicationIdImrCompleter.java License: Apache License 2.0 | 6 votes |
@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 -> strings.add(Short.toString(intent.appId().id()))); // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example 24
Source Project: onos Source File: VmIpCompleter.java License: Apache License 2.0 | 6 votes |
@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()) { for (IpAddress ip : it.next().ipAddresses()) { strings.add(ip.toString() + CIDR); } } return delegate.complete(session, commandLine, candidates); }
Example 25
Source Project: onos Source File: VtapIdCompleter.java License: Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { OpenstackVtap.Type type = getVtapTypeFromString(VTAP_TYPE); // Delegate string completer StringsCompleter delegate = new StringsCompleter(); SortedSet<String> strings = delegate.getStrings(); OpenstackVtapService service = AbstractShellCommand.get(OpenstackVtapService.class); service.getVtaps(type).forEach(t -> { strings.add(t.id().toString()); }); return delegate.complete(session, commandLine, candidates); }
Example 26
Source Project: onos Source File: CfmDeviceIdCompleter.java License: Apache License 2.0 | 6 votes |
@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 27
Source Project: onos Source File: InstanceIpAddressCompleter.java License: Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); InstancePortService instancePortService = AbstractShellCommand.get(InstancePortService.class); Set<IpAddress> set = instancePortService.instancePorts().stream() .map(InstancePort::ipAddress) .collect(Collectors.toSet()); set.add(IpAddress.valueOf(EXTERNAL_IP)); SortedSet<String> strings = delegate.getStrings(); Iterator<IpAddress> it = set.iterator(); while (it.hasNext()) { strings.add(it.next().toString()); } return delegate.complete(session, commandLine, candidates); }
Example 28
Source Project: onos Source File: MacAddressCompleter.java License: Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); OpenstackNetworkService osNetService = get(OpenstackNetworkService.class); Set<MacAddress> set = osNetService.externalPeerRouters().stream() .map(ExternalPeerRouter::macAddress) .collect(Collectors.toSet()); SortedSet<String> strings = delegate.getStrings(); Iterator<MacAddress> it = set.iterator(); while (it.hasNext()) { strings.add(it.next().toString()); } return delegate.complete(session, commandLine, candidates); }
Example 29
Source Project: onos Source File: IpAddressCompleter.java License: Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); OpenstackNetworkService osNetService = get(OpenstackNetworkService.class); Set<IpAddress> set = osNetService.externalPeerRouters().stream() .map(ExternalPeerRouter::ipAddress) .collect(Collectors.toSet()); SortedSet<String> strings = delegate.getStrings(); Iterator<IpAddress> it = set.iterator(); while (it.hasNext()) { strings.add(it.next().toString()); } return delegate.complete(session, commandLine, candidates); }
Example 30
Source Project: onos Source File: DirectPortListCompleter.java License: Apache License 2.0 | 6 votes |
@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); }