Search in sources :

Example 71 with Switch

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;
}
Also used : Switch(org.openkilda.model.Switch)

Example 72 with Switch

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());
}
Also used : Switch(org.openkilda.model.Switch) IpSocketAddress(org.openkilda.model.IpSocketAddress)

Example 73 with Switch

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());
}
Also used : Switch(org.openkilda.model.Switch) IslReference(org.openkilda.wfm.share.model.IslReference) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 74 with Switch

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);
}
Also used : Switch(org.openkilda.model.Switch)

Example 75 with Switch

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());
}
Also used : Isl(org.openkilda.model.Isl) Switch(org.openkilda.model.Switch) SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) HistoryFacts(org.openkilda.wfm.topology.network.model.facts.HistoryFacts) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Test(org.junit.Test)

Aggregations

Switch (org.openkilda.model.Switch)230 Test (org.junit.Test)126 Flow (org.openkilda.model.Flow)68 SwitchId (org.openkilda.model.SwitchId)67 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)46 FlowPath (org.openkilda.model.FlowPath)34 PathId (org.openkilda.model.PathId)32 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)32 PathComputer (org.openkilda.pce.PathComputer)28 GetPathsResult (org.openkilda.pce.GetPathsResult)23 List (java.util.List)22 SwitchProperties (org.openkilda.model.SwitchProperties)21 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)20 SpeakerData (org.openkilda.rulemanager.SpeakerData)19 String.format (java.lang.String.format)17 Set (java.util.Set)17 Isl (org.openkilda.model.Isl)15 HashSet (java.util.HashSet)14 ArrayList (java.util.ArrayList)13 Collections (java.util.Collections)13