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);
}
}
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);
}
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()));
}
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;
}
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);
}
Aggregations