Search in sources :

Example 11 with SpeakerSwitchView

use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.

the class NetworkSwitchServiceTest method switchShouldBecomeOfflineEvenIfOfflineEventHaveBeenLost.

@Test
public void switchShouldBecomeOfflineEvenIfOfflineEventHaveBeenLost() {
    NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options);
    SpeakerSwitchView alpha = getSpeakerSwitchView();
    service.switchAddWithHistory(new HistoryFacts(betaDatapath, SwitchStatus.ACTIVE));
    verifyZeroInteractions(carrier);
    service.switchBecomeManaged(alpha, "A-0");
    verify(carrier).sendSwitchSynchronizeRequest(any(), eq(alpha.getDatapath()));
    verifyNoMoreInteractions(carrier);
    service.switchBecomeManaged(alpha, "A-1");
    verify(carrier).sendSwitchStateChanged(betaDatapath, SwitchStatus.INACTIVE);
    verifyNoMoreInteractions(carrier);
}
Also used : SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) HistoryFacts(org.openkilda.wfm.topology.network.model.facts.HistoryFacts) Test(org.junit.Test)

Example 12 with SpeakerSwitchView

use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.

the class NetworkSwitchServiceTest method newSwitch.

@Test
public void newSwitch() {
    List<SpeakerSwitchPortView> ports = getSpeakerSwitchPortViews();
    SpeakerSwitchView speakerSwitchView = getSpeakerSwitchView().toBuilder().ports(ports).build();
    SwitchInfoData switchAddEvent = new SwitchInfoData(alphaDatapath, SwitchChangeType.ACTIVATED, alphaInetAddress.toString(), alphaDescription, speakerInetAddress.toString(), false, speakerSwitchView);
    NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options);
    service.switchEvent(switchAddEvent);
    verifySwitchSync(service);
    // System.out.println(mockingDetails(carrier).printInvocations());
    // System.out.println(mockingDetails(switchRepository).printInvocations());
    verifyNewSwitchAfterSwitchSync(ports);
}
Also used : SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Test(org.junit.Test)

Example 13 with SpeakerSwitchView

use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.

the class NetworkSwitchServiceTest method doSpeakerOnline.

private List<SpeakerSwitchPortView> doSpeakerOnline(NetworkSwitchService service, Set<SwitchFeature> features) {
    List<SpeakerSwitchPortView> ports = getSpeakerSwitchPortViews();
    SpeakerSwitchView speakerSwitchView = getSpeakerSwitchView().toBuilder().features(features).ports(ports).build();
    SwitchInfoData switchAddEvent = new SwitchInfoData(alphaDatapath, SwitchChangeType.ACTIVATED, alphaInetAddress.toString(), alphaDescription, speakerInetAddress.toString(), false, speakerSwitchView);
    service.switchEvent(switchAddEvent);
    verifySwitchSync(service);
    return ports;
}
Also used : SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData)

Example 14 with SpeakerSwitchView

use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.

the class SwitchTrackingService method buildSwitch.

private SpeakerSwitchView buildSwitch(IOFSwitch sw) throws InvalidConnectionDataException {
    SpeakerSwitchView.SpeakerSwitchViewBuilder builder = SpeakerSwitchView.builder().datapath(new SwitchId(sw.getId().getLong())).hostname(readHostname(sw.getInetAddress())).ofVersion(sw.getOFFactory().getVersion().toString()).features(featureDetector.detectSwitch(sw));
    SwitchDescription ofDescription = sw.getSwitchDescription();
    builder.description(SpeakerSwitchDescription.builder().manufacturer(ofDescription.getManufacturerDescription()).hardware(ofDescription.getHardwareDescription()).software(ofDescription.getSoftwareDescription()).serialNumber(ofDescription.getSerialNumber()).datapath(ofDescription.getDatapathDescription()).build());
    switchManager.getPhysicalPorts(sw).stream().map(port -> new SpeakerSwitchPortView(port.getPortNo().getPortNumber(), port.isEnabled() ? SpeakerSwitchPortView.State.UP : SpeakerSwitchPortView.State.DOWN)).forEach(builder::port);
    buildSwitchAddress(builder, sw);
    buildSwitchSpeakerAddress(builder, sw);
    return builder.build();
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) OFControllerRole(org.projectfloodlight.openflow.protocol.OFControllerRole) Message(org.openkilda.messaging.Message) OfPortDescConverter(org.openkilda.floodlight.converter.OfPortDescConverter) SocketAddress(java.net.SocketAddress) LogicalOFMessageCategory(net.floodlightcontroller.core.LogicalOFMessageCategory) SwitchChangeType(org.openkilda.messaging.info.event.SwitchChangeType) OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) LoggerFactory(org.slf4j.LoggerFactory) FloodlightDashboardLogger(org.openkilda.floodlight.utils.FloodlightDashboardLogger) SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) IService(org.openkilda.floodlight.service.IService) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) InetAddress(java.net.InetAddress) SpeakerSwitchDescription(org.openkilda.messaging.model.SpeakerSwitchDescription) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) NetworkDumpSwitchData(org.openkilda.messaging.info.discovery.NetworkDumpSwitchData) IpSocketAddress(org.openkilda.model.IpSocketAddress) Logger(org.slf4j.Logger) Collection(java.util.Collection) PortChangeType(net.floodlightcontroller.core.PortChangeType) InfoData(org.openkilda.messaging.info.InfoData) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) IofSwitchConverter(org.openkilda.floodlight.converter.IofSwitchConverter) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) InetSocketAddress(java.net.InetSocketAddress) CorrelationContext(org.openkilda.floodlight.utils.CorrelationContext) Slf4j(lombok.extern.slf4j.Slf4j) KafkaUtilityService(org.openkilda.floodlight.service.kafka.KafkaUtilityService) NewCorrelationContextRequired(org.openkilda.floodlight.utils.NewCorrelationContextRequired) KafkaChannel(org.openkilda.floodlight.KafkaChannel) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) SwitchId(org.openkilda.model.SwitchId) IOFSwitchListener(net.floodlightcontroller.core.IOFSwitchListener) DatapathId(org.projectfloodlight.openflow.types.DatapathId) InvalidConnectionDataException(org.openkilda.floodlight.error.InvalidConnectionDataException) SwitchDescription(net.floodlightcontroller.core.SwitchDescription) SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) SwitchId(org.openkilda.model.SwitchId) SpeakerSwitchDescription(org.openkilda.messaging.model.SpeakerSwitchDescription) SwitchDescription(net.floodlightcontroller.core.SwitchDescription)

Example 15 with SpeakerSwitchView

use of org.openkilda.messaging.model.SpeakerSwitchView in project open-kilda by telstra.

the class SwitchTrackingService method switchDiscoveryAction.

private void switchDiscoveryAction(DatapathId dpId, SwitchChangeType event) {
    logger.info("Send switch discovery ({} - {})", dpId, event);
    SwitchInfoData payload = null;
    if (SwitchChangeType.DEACTIVATED != event && SwitchChangeType.REMOVED != event) {
        try {
            IOFSwitch sw = switchManager.lookupSwitch(dpId);
            SpeakerSwitchView switchView = buildSwitch(sw);
            payload = buildSwitchMessage(sw, switchView, event);
        } catch (SwitchNotFoundException | InvalidConnectionDataException e) {
            logger.error("Switch {} is not in management state now({}), switch ISL discovery details will be degraded.", dpId, e.getMessage());
        }
    }
    if (payload == null) {
        payload = buildSwitchMessage(dpId, event);
    }
    emitDiscoveryEvent(dpId, payload);
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) InvalidConnectionDataException(org.openkilda.floodlight.error.InvalidConnectionDataException) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException)

Aggregations

SpeakerSwitchView (org.openkilda.messaging.model.SpeakerSwitchView)29 Test (org.junit.Test)25 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)23 SpeakerSwitchPortView (org.openkilda.messaging.model.SpeakerSwitchPortView)21 IpSocketAddress (org.openkilda.model.IpSocketAddress)8 NetworkDumpSwitchData (org.openkilda.messaging.info.discovery.NetworkDumpSwitchData)6 SpeakerSwitchDescription (org.openkilda.messaging.model.SpeakerSwitchDescription)6 SwitchId (org.openkilda.model.SwitchId)6 Duration (java.time.Duration)4 Instant (java.time.Instant)4 Collections (java.util.Collections)4 Comparator (java.util.Comparator)4 Objects (java.util.Objects)4 Collectors (java.util.stream.Collectors)4 Assert (org.junit.Assert)4 RunWith (org.junit.runner.RunWith)4 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)4 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)4 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)4 Mock (org.mockito.Mock)4