Search in sources :

Example 41 with DatapathId

use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.

the class RecordHandler method doInstallIslDefaultRule.

private void doInstallIslDefaultRule(CommandMessage message) {
    InstallIslDefaultRulesCommand toSetup = (InstallIslDefaultRulesCommand) message.getData();
    InstallIslDefaultRulesResult result = new InstallIslDefaultRulesResult(toSetup.getSrcSwitch(), toSetup.getSrcPort(), toSetup.getDstSwitch(), toSetup.getDstPort(), true);
    DatapathId dpid = DatapathId.of(toSetup.getSrcSwitch().toLong());
    try {
        if (toSetup.isMultitableMode()) {
            context.getSwitchManager().installMultitableEndpointIslRules(dpid, toSetup.getSrcPort());
        }
        if (toSetup.isServer42IslRtt()) {
            context.getSwitchManager().installServer42IslRttInputFlow(dpid, toSetup.getServer42Port(), toSetup.getSrcPort());
        }
    } catch (SwitchOperationException e) {
        logger.error("Failed to install isl rules for switch: '{}'", toSetup.getSrcSwitch(), e);
        result.setSuccess(false);
    }
    getKafkaProducer().sendMessageAndTrack(context.getKafkaSwitchManagerTopic(), record.key(), new InfoMessage(result, System.currentTimeMillis(), message.getCorrelationId(), context.getRegion()));
}
Also used : SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) InfoMessage(org.openkilda.messaging.info.InfoMessage) InstallIslDefaultRulesCommand(org.openkilda.messaging.payload.switches.InstallIslDefaultRulesCommand) DatapathId(org.projectfloodlight.openflow.types.DatapathId) InstallIslDefaultRulesResult(org.openkilda.messaging.info.discovery.InstallIslDefaultRulesResult)

Example 42 with DatapathId

use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.

the class PingData method of.

/**
 * Build {@link PingData} from {@link Ping} instance.
 */
public static PingData of(Ping ping) {
    NetworkEndpoint ingress = ping.getSource();
    DatapathId source = DatapathId.of(ingress.getDatapath().toLong());
    DatapathId dest = DatapathId.of(ping.getDest().getDatapath().toLong());
    return new PingData(ingress.getPortNumber(), source, dest, ping.getPingId());
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) DatapathId(org.projectfloodlight.openflow.types.DatapathId)

Example 43 with DatapathId

use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.

the class PingData method of.

/**
 * Build {@link PingData} from {@link DecodedJWT} token.
 */
public static PingData of(DecodedJWT token) throws CorruptedNetworkDataException {
    PingData data;
    try {
        DatapathId ingress = DatapathId.of(token.getClaim(makeIngressDatapathRef()).asLong());
        int ingressPortNumber = token.getClaim(makeIngressPortRef()).asInt();
        DatapathId egress = DatapathId.of(token.getClaim(makeEgressDatapathRef()).asLong());
        UUID packetId = UUID.fromString(token.getClaim(makePingIdRef()).asString());
        data = new PingData(ingressPortNumber, ingress, egress, packetId);
        data.setSenderLatency(token.getClaim(makeIngressLatencyRef()).asLong());
        data.setSendTime(token.getClaim(makeTimestampRef()).asLong());
    } catch (NullPointerException e) {
        throw new CorruptedNetworkDataException(String.format("Corrupted flow verification package (%s)", token));
    }
    return data;
}
Also used : DatapathId(org.projectfloodlight.openflow.types.DatapathId) UUID(java.util.UUID) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) CorruptedNetworkDataException(org.openkilda.floodlight.error.CorruptedNetworkDataException)

Example 44 with DatapathId

use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.

the class NetworkDiscoveryEmitter method emit.

void emit(DiscoveryHolder discovery) {
    DiscoverIslCommandData request = discovery.getDiscoveryRequest();
    DatapathId dpId = DatapathId.of(request.getSwitchId().getId());
    pathVerificationService.sendDiscoveryMessage(dpId, OFPort.of(request.getPortNumber()), request.getPacketId());
    DiscoPacketSendingConfirmation confirmation = new DiscoPacketSendingConfirmation(new NetworkEndpoint(request.getSwitchId(), request.getPortNumber()), request.getPacketId());
    kafkaProducerService.sendMessageAndTrackWithZk(confirmationTopic, request.getSwitchId().toString(), new InfoMessage(confirmation, System.currentTimeMillis(), discovery.getCorrelationId(), region));
}
Also used : DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) DiscoPacketSendingConfirmation(org.openkilda.messaging.info.discovery.DiscoPacketSendingConfirmation) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InfoMessage(org.openkilda.messaging.info.InfoMessage) DatapathId(org.projectfloodlight.openflow.types.DatapathId)

Example 45 with DatapathId

use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.

the class OfPortDescConverterTest method testPortChangeTypeMapping.

@Test
public void testPortChangeTypeMapping() {
    OFPortDesc portDesc = OFFactoryVer13.INSTANCE.buildPortDesc().setPortNo(OFPort.of(1)).setName("test").build();
    Map<org.openkilda.messaging.info.event.PortChangeType, net.floodlightcontroller.core.PortChangeType> expected = new HashMap<>();
    expected.put(org.openkilda.messaging.info.event.PortChangeType.ADD, net.floodlightcontroller.core.PortChangeType.ADD);
    expected.put(org.openkilda.messaging.info.event.PortChangeType.OTHER_UPDATE, net.floodlightcontroller.core.PortChangeType.OTHER_UPDATE);
    expected.put(org.openkilda.messaging.info.event.PortChangeType.DELETE, net.floodlightcontroller.core.PortChangeType.DELETE);
    expected.put(org.openkilda.messaging.info.event.PortChangeType.UP, net.floodlightcontroller.core.PortChangeType.UP);
    expected.put(org.openkilda.messaging.info.event.PortChangeType.DOWN, net.floodlightcontroller.core.PortChangeType.DOWN);
    DatapathId dpId = DatapathId.of(1);
    for (Map.Entry<org.openkilda.messaging.info.event.PortChangeType, net.floodlightcontroller.core.PortChangeType> entry : expected.entrySet()) {
        PortInfoData encoded = OfPortDescConverter.INSTANCE.toPortInfoData(dpId, portDesc, entry.getValue());
        Assert.assertSame(entry.getKey(), encoded.getState());
    }
}
Also used : OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) HashMap(java.util.HashMap) DatapathId(org.projectfloodlight.openflow.types.DatapathId) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

DatapathId (org.projectfloodlight.openflow.types.DatapathId)55 InfoMessage (org.openkilda.messaging.info.InfoMessage)19 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)17 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)16 SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)16 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)16 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)15 IKafkaProducerService (org.openkilda.floodlight.service.kafka.IKafkaProducerService)14 SwitchId (org.openkilda.model.SwitchId)14 OFMessage (org.projectfloodlight.openflow.protocol.OFMessage)13 SwitchNotFoundException (org.openkilda.floodlight.error.SwitchNotFoundException)12 OFPortDesc (org.projectfloodlight.openflow.protocol.OFPortDesc)10 ArrayList (java.util.ArrayList)9 InetSocketAddress (java.net.InetSocketAddress)8 HashSet (java.util.HashSet)8 Map (java.util.Map)8 InvalidMeterIdException (org.openkilda.floodlight.error.InvalidMeterIdException)8 OfInstallException (org.openkilda.floodlight.error.OfInstallException)8 Objects (java.util.Objects)7 Collectors (java.util.stream.Collectors)7