Search in sources :

Example 1 with OFSwitchService

use of org.onosproject.ofagent.api.OFSwitchService in project onos by opennetworkinglab.

the class OFSwitchListCommand method doExecute.

@Override
protected void doExecute() {
    OFSwitchService service = get(OFSwitchService.class);
    Set<OFSwitch> ofSwitches;
    if (networkId != NetworkId.NONE.id()) {
        ofSwitches = service.ofSwitches(NetworkId.networkId(networkId));
    } else {
        ofSwitches = service.ofSwitches();
    }
    print(FORMAT, "DPID", "Connected controllers");
    ofSwitches.forEach(ofSwitch -> {
        Set<String> channels = ofSwitch.controllerChannels().stream().map(channel -> channel.remoteAddress().toString()).collect(Collectors.toSet());
        print(FORMAT, ofSwitch.dpid(), channels);
    });
}
Also used : AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) Service(org.apache.karaf.shell.api.action.lifecycle.Service) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) OFSwitchService(org.onosproject.ofagent.api.OFSwitchService) Set(java.util.Set) Argument(org.apache.karaf.shell.api.action.Argument) OFSwitch(org.onosproject.ofagent.api.OFSwitch) Collectors(java.util.stream.Collectors) Command(org.apache.karaf.shell.api.action.Command) OFSwitchService(org.onosproject.ofagent.api.OFSwitchService) OFSwitch(org.onosproject.ofagent.api.OFSwitch)

Aggregations

Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Argument (org.apache.karaf.shell.api.action.Argument)1 Command (org.apache.karaf.shell.api.action.Command)1 Service (org.apache.karaf.shell.api.action.lifecycle.Service)1 AbstractShellCommand (org.onosproject.cli.AbstractShellCommand)1 NetworkId (org.onosproject.incubator.net.virtual.NetworkId)1 OFSwitch (org.onosproject.ofagent.api.OFSwitch)1 OFSwitchService (org.onosproject.ofagent.api.OFSwitchService)1