use of org.openkilda.model.IpSocketAddress in project open-kilda by telstra.
the class SwitchTest method serializeLoop.
@Test
public void serializeLoop() throws Exception {
Switch origin = Switch.builder().switchId(new SwitchId(1)).controller("test_controller").description("test_description").hostname("test_hostname").pop("test_pop").status(SwitchStatus.ACTIVE).underMaintenance(true).socketAddress(new IpSocketAddress("192.168.10.20", 1)).features(Collections.singleton(SwitchFeature.GROUP_PACKET_OUT_CONTROLLER)).build();
serializer.serialize(origin);
Switch reconstructed = (Switch) serializer.deserialize();
Assert.assertEquals(origin, reconstructed);
}
use of org.openkilda.model.IpSocketAddress in project open-kilda by telstra.
the class TimeModifyPropertyOnFramesTest method shouldUpdateTimeModifyOnImplementedPropertyChange.
@Test
public void shouldUpdateTimeModifyOnImplementedPropertyChange() {
Instant timeModifyBefore = transactionManager.doInTransaction(() -> createTestSwitch(1).getTimeModify());
waitUntilNowIsAfter(timeModifyBefore);
transactionManager.doInTransaction(() -> switchRepository.findById(new SwitchId(1)).get().setSocketAddress(new IpSocketAddress("192.168.10.20", 12345)));
Instant timeModifyAfter = switchRepository.findById(new SwitchId(1)).get().getTimeModify();
assertNotEquals(timeModifyBefore, timeModifyAfter);
}
use of org.openkilda.model.IpSocketAddress in project open-kilda by telstra.
the class BfdWorker method lookupSwitchAddress.
private Optional<String> lookupSwitchAddress(SwitchId switchId) {
Optional<Switch> sw = switchRepository.findById(switchId);
if (!sw.isPresent()) {
return Optional.empty();
}
IpSocketAddress address = sw.get().getSocketAddress();
return Optional.of(address.getAddress());
}
use of org.openkilda.model.IpSocketAddress in project open-kilda by telstra.
the class SwitchFsm method persistSwitchData.
private void persistSwitchData(SpeakerSwitchView speakerSwitchView, SwitchAvailabilityData availabilityData) {
Switch sw = lookupSwitchCreateIfMissing();
IpSocketAddress socketAddress = speakerSwitchView.getSwitchSocketAddress();
sw.setSocketAddress(socketAddress);
sw.setHostname(speakerSwitchView.getHostname());
SpeakerSwitchDescription description = speakerSwitchView.getDescription();
sw.setDescription(String.format("%s %s %s", description.getManufacturer(), speakerSwitchView.getOfVersion(), description.getSoftware()));
sw.setOfVersion(speakerSwitchView.getOfVersion());
sw.setOfDescriptionManufacturer(description.getManufacturer());
sw.setOfDescriptionHardware(description.getHardware());
sw.setOfDescriptionSoftware(description.getSoftware());
sw.setOfDescriptionSerialNumber(description.getSerialNumber());
sw.setOfDescriptionDatapath(description.getDatapath());
sw.setStatus(SwitchStatus.INACTIVE);
sw.setFeatures(speakerSwitchView.getFeatures());
persistSwitchProperties(sw);
persistSwitchConnections(sw, availabilityData);
}
use of org.openkilda.model.IpSocketAddress in project open-kilda by telstra.
the class SwitchValidateFsm method emitRequests.
public void emitRequests(SwitchValidateState from, SwitchValidateState to, SwitchValidateEvent event, SwitchValidateContext context) {
try {
SwitchId switchId = getSwitchId();
log.info("The switch validate process for {} has been started (key={})", switchId, key);
// FIXME(surabujin): not reliable check - corresponding error from speaker is much more better
Optional<Switch> sw = switchRepository.findById(switchId);
if (!sw.isPresent()) {
throw new SwitchNotFoundException(switchId);
}
requestSwitchOfFlows();
requestSwitchOfGroups();
if (sw.get().getFeatures().contains(LAG)) {
// at this moment Kilda validated only LAG logical ports
Optional<String> ipAddress = sw.map(Switch::getSocketAddress).map(IpSocketAddress::getAddress);
if (ipAddress.isPresent()) {
requestLogicalPorts(ipAddress.get());
} else {
log.warn("Unable to get IP address of switch {} to get LAGs", switchId);
}
}
if (request.isProcessMeters()) {
requestSwitchMeters();
}
} catch (Exception ex) {
log.error("Failure in emitRequests", ex);
throw ex;
}
}
Aggregations