Search in sources :

Example 11 with SpeakerSwitchPortView

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

the class SwitchFsm method updatePorts.

private void updatePorts(SwitchFsmContext context, SpeakerSwitchView speakerData, boolean isForced) {
    // set features for correct port (re)identification
    updateFeatures(speakerData.getFeatures());
    Set<Integer> removedPorts = new HashSet<>(portByNumber.keySet());
    for (SpeakerSwitchPortView speakerPort : speakerData.getPorts()) {
        AbstractPort actualPort = makePortRecord(speakerPort);
        AbstractPort storedPort = portByNumber.get(speakerPort.getNumber());
        boolean isNewOrRecreated = true;
        if (storedPort == null) {
            storedPort = portAdd(actualPort, context);
        } else if (!storedPort.isSameKind(actualPort)) {
            // port kind have been changed, we must recreate port handler
            portDel(storedPort, context);
            storedPort = portAdd(actualPort, context);
        } else {
            removedPorts.remove(speakerPort.getNumber());
            isNewOrRecreated = false;
        }
        if (isForced || isNewOrRecreated) {
            updateOnlineStatus(storedPort, context, OnlineStatus.ONLINE);
            updatePortLinkMode(storedPort, actualPort.getLinkStatus(), context);
        } else if (storedPort.getLinkStatus() != actualPort.getLinkStatus()) {
            updatePortLinkMode(storedPort, actualPort.getLinkStatus(), context);
        }
    }
    for (Integer portNumber : removedPorts) {
        portDel(portByNumber.get(portNumber), context);
    }
}
Also used : SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) HashSet(java.util.HashSet)

Example 12 with SpeakerSwitchPortView

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

the class NetworkIntegrationTest method switchAdd.

@Test
@Ignore
public void switchAdd() {
    Set<SwitchFeature> features = new HashSet<>();
    features.add(SwitchFeature.BFD);
    Integer bfdLocalPortOffset = options.getBfdLogicalPortOffset();
    List<SpeakerSwitchPortView> ports = ImmutableList.of(new SpeakerSwitchPortView(1, SpeakerSwitchPortView.State.UP), new SpeakerSwitchPortView(1 + bfdLocalPortOffset, SpeakerSwitchPortView.State.UP), new SpeakerSwitchPortView(2, SpeakerSwitchPortView.State.DOWN), new SpeakerSwitchPortView(2 + bfdLocalPortOffset, SpeakerSwitchPortView.State.DOWN));
    SpeakerSwitchView speakerSwitchView = new SpeakerSwitchView(alphaDatapath, new IpSocketAddress(alphaInetAddress.getHostString(), alphaInetAddress.getPort()), new IpSocketAddress(speakerInetAddress.getHostString(), speakerInetAddress.getPort()), alphaInetAddress.getHostString(), "OF_13", switchDescription, features, ports);
    NetworkSwitchService switchService = integrationCarrier.getSwitchService();
    SwitchInfoData switchAddEvent = new SwitchInfoData(alphaDatapath, SwitchChangeType.ADDED, alphaInetAddress.toString(), alphaDescription, speakerInetAddress.toString(), false, speakerSwitchView);
    switchService.switchEvent(switchAddEvent);
    SwitchInfoData switchActivateEvent = new SwitchInfoData(alphaDatapath, SwitchChangeType.ACTIVATED, alphaInetAddress.toString(), alphaDescription, speakerInetAddress.toString(), false, speakerSwitchView);
    switchService.switchEvent(switchActivateEvent);
}
Also used : SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) SwitchFeature(org.openkilda.model.SwitchFeature) IpSocketAddress(org.openkilda.model.IpSocketAddress) HashSet(java.util.HashSet) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with SpeakerSwitchPortView

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

the class NetworkSwitchServiceTest method switchWithNoBfdSupport.

@Test
public void switchWithNoBfdSupport() {
    List<SpeakerSwitchPortView> ports = getSpeakerSwitchPortViews();
    SpeakerSwitchView speakerSwitchView = getSpeakerSwitchView().toBuilder().ports(ports).features(Collections.emptySet()).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());
    verify(carrier).setupPortHandler(Endpoint.of(alphaDatapath, ports.get(0).getNumber()), null);
    verify(carrier).setupPortHandler(Endpoint.of(alphaDatapath, ports.get(1).getNumber()), null);
    verify(carrier).setupPortHandler(Endpoint.of(alphaDatapath, ports.get(2).getNumber()), null);
    verify(carrier).setupPortHandler(Endpoint.of(alphaDatapath, ports.get(3).getNumber()), null);
    verify(carrier).setOnlineMode(Endpoint.of(alphaDatapath, ports.get(0).getNumber()), OnlineStatus.ONLINE);
    verify(carrier).setOnlineMode(Endpoint.of(alphaDatapath, ports.get(1).getNumber()), OnlineStatus.ONLINE);
    verify(carrier).setOnlineMode(Endpoint.of(alphaDatapath, ports.get(2).getNumber()), OnlineStatus.ONLINE);
    verify(carrier).setOnlineMode(Endpoint.of(alphaDatapath, ports.get(3).getNumber()), OnlineStatus.ONLINE);
    verify(carrier).setPortLinkMode(Endpoint.of(alphaDatapath, ports.get(2).getNumber()), LinkStatus.of(ports.get(2).getState()));
    verify(carrier).setPortLinkMode(Endpoint.of(alphaDatapath, ports.get(3).getNumber()), LinkStatus.of(ports.get(3).getState()));
    verify(carrier).setPortLinkMode(Endpoint.of(alphaDatapath, ports.get(0).getNumber()), LinkStatus.of(ports.get(0).getState()));
    verify(carrier).setPortLinkMode(Endpoint.of(alphaDatapath, ports.get(1).getNumber()), LinkStatus.of(ports.get(0).getState()));
}
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 14 with SpeakerSwitchPortView

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

the class NetworkSwitchServiceTest method swapBfdPortsState.

private List<SpeakerSwitchPortView> swapBfdPortsState(List<SpeakerSwitchPortView> ports) {
    List<SpeakerSwitchPortView> result = new ArrayList<>();
    for (SpeakerSwitchPortView entry : ports) {
        SpeakerSwitchPortView replace = entry;
        if (BFD_LOGICAL_PORT_OFFSET < entry.getNumber()) {
            replace = makePortEntryWithOppositeState(entry);
        }
        result.add(replace);
    }
    return result;
}
Also used : SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) ArrayList(java.util.ArrayList)

Example 15 with SpeakerSwitchPortView

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

the class NetworkSwitchServiceTest method newSwitchWithNullMetersInSynchronizationResponse.

@Test
public void newSwitchWithNullMetersInSynchronizationResponse() {
    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);
    // for a randomly generated key in SwitchFsm
    ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
    verify(carrier).sendSwitchSynchronizeRequest(captor.capture(), eq(alphaDatapath));
    RulesSyncEntry rulesSyncEntry = new RulesSyncEntry(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
    GroupSyncEntry groupSyncEntry = new GroupSyncEntry(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
    SwitchSyncResponse response = new SwitchSyncResponse(alphaDatapath, rulesSyncEntry, null, groupSyncEntry, LogicalPortsSyncEntry.builder().build());
    service.switchManagerResponse(response, captor.getValue());
    verifyNewSwitchAfterSwitchSync(ports);
    verify(carrier).sendSwitchStateChanged(alphaDatapath, SwitchStatus.ACTIVE);
    verifyNoMoreInteractions(carrier);
}
Also used : RulesSyncEntry(org.openkilda.messaging.info.switches.RulesSyncEntry) SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) SwitchSyncResponse(org.openkilda.messaging.info.switches.SwitchSyncResponse) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) GroupSyncEntry(org.openkilda.messaging.info.switches.GroupSyncEntry) Test(org.junit.Test)

Aggregations

SpeakerSwitchPortView (org.openkilda.messaging.model.SpeakerSwitchPortView)20 SpeakerSwitchView (org.openkilda.messaging.model.SpeakerSwitchView)17 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)16 Test (org.junit.Test)15 InetSocketAddress (java.net.InetSocketAddress)3 ArrayList (java.util.ArrayList)3 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)3 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)3 GroupSyncEntry (org.openkilda.messaging.info.switches.GroupSyncEntry)3 RulesSyncEntry (org.openkilda.messaging.info.switches.RulesSyncEntry)3 SwitchSyncResponse (org.openkilda.messaging.info.switches.SwitchSyncResponse)3 SpeakerSwitchDescription (org.openkilda.messaging.model.SpeakerSwitchDescription)3 IpSocketAddress (org.openkilda.model.IpSocketAddress)3 HashSet (java.util.HashSet)2 OFConnection (net.floodlightcontroller.core.internal.OFConnection)2 Message (org.openkilda.messaging.Message)2 SwitchSyncErrorData (org.openkilda.messaging.error.rule.SwitchSyncErrorData)2 InfoMessage (org.openkilda.messaging.info.InfoMessage)2 NetworkDumpSwitchData (org.openkilda.messaging.info.discovery.NetworkDumpSwitchData)2 PortInfoData (org.openkilda.messaging.info.event.PortInfoData)2