use of org.openkilda.model.Switch in project open-kilda by telstra.
the class IslFsm method createSwitch.
private Switch createSwitch(SwitchId datapath) {
Switch sw = Switch.builder().switchId(datapath).status(SwitchStatus.INACTIVE).description(String.format("auto created as part of ISL %s discovery", reference)).build();
switchRepository.add(sw);
return sw;
}
use of org.openkilda.model.Switch 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.Switch in project open-kilda by telstra.
the class NetworkIslServiceTest method initialUp.
@Test
@Ignore("incomplete")
public void initialUp() {
persistenceManager = InMemoryGraphPersistenceManager.newInstance();
persistenceManager.install();
emulateEmptyPersistentDb();
SwitchRepository switchRepository = persistenceManager.getRepositoryFactory().createSwitchRepository();
Switch swA = Switch.builder().switchId(endpointAlpha1.getDatapath()).description("alpha").build();
switchRepository.add(swA);
switchPropertiesRepository.add(SwitchProperties.builder().multiTable(false).supportedTransitEncapsulation(SwitchProperties.DEFAULT_FLOW_ENCAPSULATION_TYPES).switchObj(swA).build());
Switch swB = Switch.builder().switchId(endpointBeta2.getDatapath()).description("alpha").build();
switchRepository.add(swB);
switchPropertiesRepository.add(SwitchProperties.builder().multiTable(false).supportedTransitEncapsulation(SwitchProperties.DEFAULT_FLOW_ENCAPSULATION_TYPES).switchObj(swB).build());
IslReference ref = new IslReference(endpointAlpha1, endpointBeta2);
IslDataHolder islData = new IslDataHolder(1000, 1000, 1000);
service = new NetworkIslService(carrier, persistenceManager, options);
service.islUp(ref.getSource(), ref, islData);
System.out.println(mockingDetails(carrier).printInvocations());
System.out.println(mockingDetails(islRepository).printInvocations());
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class NetworkIslServiceTest method makeIsl.
private Isl.IslBuilder makeIsl(Endpoint source, Endpoint dest, boolean multiTable) {
Switch sourceSwitch = lookupSwitchCreateMockIfAbsent(source.getDatapath(), multiTable);
Switch destSwitch = lookupSwitchCreateMockIfAbsent(dest.getDatapath(), multiTable);
return Isl.builder().srcSwitch(sourceSwitch).srcPort(source.getPortNumber()).destSwitch(destSwitch).destPort(dest.getPortNumber()).status(IslStatus.ACTIVE).actualStatus(IslStatus.ACTIVE).latency(10).speed(100).availableBandwidth(100).maxBandwidth(100).defaultMaxBandwidth(100);
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class NetworkSwitchServiceTest method switchFromHistoryToOfflineToOnlineRemovedPort.
@Test
public void switchFromHistoryToOfflineToOnlineRemovedPort() {
// History
HistoryFacts history = new HistoryFacts(alphaDatapath, SwitchStatus.ACTIVE);
Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build();
Switch betaSwitch = Switch.builder().switchId(betaDatapath).build();
Isl islAtoB = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
Isl islAtoB2 = Isl.builder().srcSwitch(alphaSwitch).srcPort(2).destSwitch(betaSwitch).destPort(2).build();
Isl islAtoB3 = Isl.builder().srcSwitch(alphaSwitch).srcPort(3).destSwitch(betaSwitch).destPort(3).build();
history.addLink(islAtoB);
history.addLink(islAtoB2);
history.addLink(islAtoB3);
NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options);
service.switchAddWithHistory(history);
// Online
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);
resetMocks();
service.switchEvent(switchAddEvent);
verifySwitchSync(service);
verify(carrier).removePortHandler(Endpoint.of(alphaDatapath, 3));
// System.out.println(mockingDetails(carrier).printInvocations());
// System.out.println(mockingDetails(switchRepository).printInvocations());
}
Aggregations