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