Search in sources :

Example 1 with InvalidConnectionDataException

use of org.openkilda.floodlight.error.InvalidConnectionDataException 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);
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) InvalidConnectionDataException(org.openkilda.floodlight.error.InvalidConnectionDataException) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException)

Example 2 with InvalidConnectionDataException

use of org.openkilda.floodlight.error.InvalidConnectionDataException 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();
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) OFControllerRole(org.projectfloodlight.openflow.protocol.OFControllerRole) Message(org.openkilda.messaging.Message) OfPortDescConverter(org.openkilda.floodlight.converter.OfPortDescConverter) SocketAddress(java.net.SocketAddress) LogicalOFMessageCategory(net.floodlightcontroller.core.LogicalOFMessageCategory) SwitchChangeType(org.openkilda.messaging.info.event.SwitchChangeType) OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) LoggerFactory(org.slf4j.LoggerFactory) FloodlightDashboardLogger(org.openkilda.floodlight.utils.FloodlightDashboardLogger) SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) IService(org.openkilda.floodlight.service.IService) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) InetAddress(java.net.InetAddress) SpeakerSwitchDescription(org.openkilda.messaging.model.SpeakerSwitchDescription) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) NetworkDumpSwitchData(org.openkilda.messaging.info.discovery.NetworkDumpSwitchData) IpSocketAddress(org.openkilda.model.IpSocketAddress) Logger(org.slf4j.Logger) Collection(java.util.Collection) PortChangeType(net.floodlightcontroller.core.PortChangeType) InfoData(org.openkilda.messaging.info.InfoData) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) IofSwitchConverter(org.openkilda.floodlight.converter.IofSwitchConverter) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) InetSocketAddress(java.net.InetSocketAddress) CorrelationContext(org.openkilda.floodlight.utils.CorrelationContext) Slf4j(lombok.extern.slf4j.Slf4j) KafkaUtilityService(org.openkilda.floodlight.service.kafka.KafkaUtilityService) NewCorrelationContextRequired(org.openkilda.floodlight.utils.NewCorrelationContextRequired) KafkaChannel(org.openkilda.floodlight.KafkaChannel) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) SwitchId(org.openkilda.model.SwitchId) IOFSwitchListener(net.floodlightcontroller.core.IOFSwitchListener) DatapathId(org.projectfloodlight.openflow.types.DatapathId) InvalidConnectionDataException(org.openkilda.floodlight.error.InvalidConnectionDataException) SwitchDescription(net.floodlightcontroller.core.SwitchDescription) SpeakerSwitchPortView(org.openkilda.messaging.model.SpeakerSwitchPortView) SpeakerSwitchView(org.openkilda.messaging.model.SpeakerSwitchView) SwitchId(org.openkilda.model.SwitchId) SpeakerSwitchDescription(org.openkilda.messaging.model.SpeakerSwitchDescription) SwitchDescription(net.floodlightcontroller.core.SwitchDescription)

Aggregations

IOFSwitch (net.floodlightcontroller.core.IOFSwitch)2 InvalidConnectionDataException (org.openkilda.floodlight.error.InvalidConnectionDataException)2 SwitchNotFoundException (org.openkilda.floodlight.error.SwitchNotFoundException)2 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)2 SpeakerSwitchView (org.openkilda.messaging.model.SpeakerSwitchView)2 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 Collection (java.util.Collection)1 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 Slf4j (lombok.extern.slf4j.Slf4j)1 IOFSwitchListener (net.floodlightcontroller.core.IOFSwitchListener)1 LogicalOFMessageCategory (net.floodlightcontroller.core.LogicalOFMessageCategory)1 PortChangeType (net.floodlightcontroller.core.PortChangeType)1 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)1 IOFSwitchService (net.floodlightcontroller.core.internal.IOFSwitchService)1 FloodlightModuleContext (net.floodlightcontroller.core.module.FloodlightModuleContext)1 KafkaChannel (org.openkilda.floodlight.KafkaChannel)1 IofSwitchConverter (org.openkilda.floodlight.converter.IofSwitchConverter)1