Search in sources :

Example 1 with IpSocketAddress

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

Example 2 with IpSocketAddress

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);
}
Also used : Instant(java.time.Instant) SwitchId(org.openkilda.model.SwitchId) IpSocketAddress(org.openkilda.model.IpSocketAddress) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 3 with IpSocketAddress

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

Example 4 with IpSocketAddress

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

Example 5 with IpSocketAddress

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;
    }
}
Also used : Switch(org.openkilda.model.Switch) SwitchId(org.openkilda.model.SwitchId) SwitchNotFoundException(org.openkilda.wfm.topology.switchmanager.error.SwitchNotFoundException) IpSocketAddress(org.openkilda.model.IpSocketAddress) SwitchManagerException(org.openkilda.wfm.topology.switchmanager.error.SwitchManagerException) SwitchNotFoundException(org.openkilda.wfm.topology.switchmanager.error.SwitchNotFoundException)

Aggregations

IpSocketAddress (org.openkilda.model.IpSocketAddress)12 Switch (org.openkilda.model.Switch)6 Test (org.junit.Test)5 SwitchId (org.openkilda.model.SwitchId)5 SpeakerSwitchView (org.openkilda.messaging.model.SpeakerSwitchView)3 Values (org.apache.storm.tuple.Values)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 GetPacketInOutStatsRequest (org.openkilda.messaging.command.grpc.GetPacketInOutStatsRequest)2 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)2 SpeakerSwitchDescription (org.openkilda.messaging.model.SpeakerSwitchDescription)2 SpeakerSwitchPortView (org.openkilda.messaging.model.SpeakerSwitchPortView)2 InetSocketAddress (java.net.InetSocketAddress)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)1 OFConnection (net.floodlightcontroller.core.internal.OFConnection)1 OFSwitch (net.floodlightcontroller.core.internal.OFSwitch)1 Tuple (org.apache.storm.tuple.Tuple)1