Search in sources :

Example 1 with OFSwitch

use of org.onosproject.ofagent.api.OFSwitch 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)

Example 2 with OFSwitch

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

the class OFSwitchManager method addOFSwitch.

private void addOFSwitch(NetworkId networkId, DeviceId deviceId) {
    OFSwitch ofSwitch = DefaultOFSwitch.of(dpidWithDeviceId(deviceId), DEFAULT_CAPABILITIES, networkId, deviceId, virtualNetService.getServiceDirectory());
    ofSwitchMap.put(deviceId, ofSwitch);
    log.info("Added virtual OF switch for {}", deviceId);
    OFAgent ofAgent = ofAgentService.agent(networkId);
    if (ofAgent == null) {
        log.error("OFAgent for network {} does not exist", networkId);
        return;
    }
    if (ofAgent.state() == STARTED) {
        connectController(ofSwitch, ofAgent.controllers());
    }
}
Also used : OFSwitch(org.onosproject.ofagent.api.OFSwitch) OFAgent(org.onosproject.ofagent.api.OFAgent)

Example 3 with OFSwitch

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

the class OFSwitchManager method deleteOFSwitch.

private void deleteOFSwitch(DeviceId deviceId) {
    OFSwitch ofSwitch = ofSwitchMap.get(deviceId);
    ofSwitch.controllerChannels().forEach(ChannelOutboundInvoker::disconnect);
    ofSwitchMap.remove(deviceId);
    log.info("Removed virtual OFSwitch for {}", deviceId);
}
Also used : ChannelOutboundInvoker(io.netty.channel.ChannelOutboundInvoker) OFSwitch(org.onosproject.ofagent.api.OFSwitch)

Example 4 with OFSwitch

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

the class DefaultOFSwitch method processLldp.

@Override
public void processLldp(Channel channel, OFMessage msg) {
    log.trace("processLldp msg{}", msg);
    // For each output port, look up neighbour port.
    // If neighbour port exists, have the neighbour switch send lldp response.
    // Modeled after how OpenVirtex handles lldp from external controller.
    OFPacketOut ofPacketOut = (OFPacketOut) msg;
    List<OFAction> actions = ofPacketOut.getActions();
    for (final OFAction action : actions) {
        OFActionType actionType = action.getType();
        if (actionType.equals(OFActionType.OUTPUT)) {
            OFActionOutput ofActionOutput = (OFActionOutput) action;
            OFPort ofPort = ofActionOutput.getPort();
            ConnectPoint neighbourCp = ofSwitchService.neighbour(networkId, deviceId, PortNumber.portNumber(ofPort.getPortNumber()));
            if (neighbourCp == null) {
                log.trace("No neighbour found for {} {}", deviceId, ofPort);
                continue;
            }
            OFSwitch neighbourSwitch = ofSwitchService.ofSwitch(networkId, neighbourCp.deviceId());
            neighbourSwitch.sendLldpResponse(ofPacketOut, neighbourCp.port());
        }
    }
}
Also used : OFActionOutput(org.projectfloodlight.openflow.protocol.action.OFActionOutput) OFPort(org.projectfloodlight.openflow.types.OFPort) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) OFActionType(org.projectfloodlight.openflow.protocol.OFActionType) OFSwitch(org.onosproject.ofagent.api.OFSwitch) ConnectPoint(org.onosproject.net.ConnectPoint) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut)

Example 5 with OFSwitch

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

the class OFSwitchManager method processOFAgentStarted.

private void processOFAgentStarted(OFAgent ofAgent) {
    devices(ofAgent.networkId()).forEach(deviceId -> {
        OFSwitch ofSwitch = ofSwitchMap.get(deviceId);
        if (ofSwitch != null) {
            connectController(ofSwitch, ofAgent.controllers());
        }
    });
    DeviceService deviceService = virtualNetService.get(ofAgent.networkId(), DeviceService.class);
    deviceService.addListener(deviceListener);
    PacketService packetService = virtualNetService.get(ofAgent.networkId(), PacketService.class);
    packetService.addProcessor(packetProcessor, PacketProcessor.director(0));
    FlowRuleService flowRuleService = virtualNetService.get(ofAgent.networkId(), FlowRuleService.class);
    flowRuleService.addListener(flowRuleListener);
}
Also used : PacketService(org.onosproject.net.packet.PacketService) DeviceService(org.onosproject.net.device.DeviceService) OFSwitch(org.onosproject.ofagent.api.OFSwitch) FlowRuleService(org.onosproject.net.flow.FlowRuleService)

Aggregations

OFSwitch (org.onosproject.ofagent.api.OFSwitch)6 DeviceService (org.onosproject.net.device.DeviceService)2 FlowRuleService (org.onosproject.net.flow.FlowRuleService)2 PacketService (org.onosproject.net.packet.PacketService)2 ChannelOutboundInvoker (io.netty.channel.ChannelOutboundInvoker)1 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 ConnectPoint (org.onosproject.net.ConnectPoint)1 OFAgent (org.onosproject.ofagent.api.OFAgent)1 OFSwitchService (org.onosproject.ofagent.api.OFSwitchService)1 OFActionType (org.projectfloodlight.openflow.protocol.OFActionType)1 OFPacketOut (org.projectfloodlight.openflow.protocol.OFPacketOut)1 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)1 OFActionOutput (org.projectfloodlight.openflow.protocol.action.OFActionOutput)1 OFPort (org.projectfloodlight.openflow.types.OFPort)1