Search in sources :

Example 1 with PortFsm

use of org.openkilda.wfm.topology.network.controller.port.PortFsm in project open-kilda by telstra.

the class NetworkPortService method updateLinkStatus.

/**
 * .
 */
public void updateLinkStatus(Endpoint endpoint, LinkStatus status) {
    log.debug("Port service receive link status update for {} new status is {}", endpoint, status);
    PortFsm portFsm = locateController(endpoint);
    PortFsmEvent event;
    switch(status) {
        case UP:
            event = PortFsmEvent.PORT_UP;
            break;
        case DOWN:
            event = PortFsmEvent.PORT_DOWN;
            break;
        default:
            throw new IllegalArgumentException(format("Unsupported %s value %s", LinkStatus.class.getName(), status));
    }
    controllerExecutor.fire(portFsm, event, PortFsmContext.builder(carrier).build());
}
Also used : PortFsm(org.openkilda.wfm.topology.network.controller.port.PortFsm) PortFsmEvent(org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmEvent)

Example 2 with PortFsm

use of org.openkilda.wfm.topology.network.controller.port.PortFsm in project open-kilda by telstra.

the class NetworkPortService method updatePortProperties.

/**
 * Update port properties.
 */
public void updatePortProperties(Endpoint endpoint, boolean discoveryEnabled) {
    try {
        transactionManager.doInTransaction(() -> {
            PortProperties portProperties = savePortProperties(endpoint, discoveryEnabled);
            PortFsm portFsm = locateController(endpoint);
            PortFsmContext context = PortFsmContext.builder(carrier).build();
            PortFsmEvent event = discoveryEnabled ? PortFsmEvent.ENABLE_DISCOVERY : PortFsmEvent.DISABLE_DISCOVERY;
            controllerExecutor.fire(portFsm, event, context);
            carrier.notifyPortPropertiesChanged(portProperties);
        });
    } catch (PersistenceException e) {
        String message = format("Could not update port properties for '%s': %s", endpoint, e.getMessage());
        throw new MessageException(NOT_FOUND, message, "Persistence exception");
    } catch (IllegalStateException e) {
        // Rollback if port is not found. It's allowed to change port properties for already existing ports only.
        String message = format("Port not found: '%s'", e.getMessage());
        throw new MessageException(NOT_FOUND, message, "Port not found exception");
    }
}
Also used : MessageException(org.openkilda.messaging.error.MessageException) PortFsm(org.openkilda.wfm.topology.network.controller.port.PortFsm) PersistenceException(org.openkilda.persistence.exceptions.PersistenceException) PortFsmEvent(org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmEvent) PortProperties(org.openkilda.model.PortProperties) PortFsmContext(org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmContext)

Example 3 with PortFsm

use of org.openkilda.wfm.topology.network.controller.port.PortFsm in project open-kilda by telstra.

the class NetworkPortService method updateOnlineMode.

/**
 * .
 */
public void updateOnlineMode(Endpoint endpoint, OnlineStatus onlineStatus) {
    PortFsm portFsm = locateController(endpoint);
    PortFsmEvent event;
    switch(onlineStatus) {
        case ONLINE:
            event = PortFsmEvent.ONLINE;
            break;
        case OFFLINE:
            event = PortFsmEvent.OFFLINE;
            break;
        case REGION_OFFLINE:
            event = PortFsmEvent.REGION_OFFLINE;
            break;
        default:
            throw new IllegalArgumentException(format("Unsupported %s value %s", OnlineStatus.class.getName(), onlineStatus));
    }
    log.debug("Port service receive online status change for {}, new status is {}", endpoint, event);
    controllerExecutor.fire(portFsm, event, PortFsmContext.builder(carrier).build());
}
Also used : PortFsm(org.openkilda.wfm.topology.network.controller.port.PortFsm) PortFsmEvent(org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmEvent)

Example 4 with PortFsm

use of org.openkilda.wfm.topology.network.controller.port.PortFsm in project open-kilda by telstra.

the class NetworkPortService method remove.

/**
 * .
 */
public void remove(Endpoint endpoint) {
    log.info("Port service receive remove request for {}", endpoint);
    PortFsm portFsm = controller.remove(endpoint);
    if (portFsm == null) {
        throw new IllegalStateException(format("Port FSM not found (%s).", endpoint));
    }
    PortFsmContext context = PortFsmContext.builder(carrier).build();
    controllerExecutor.fire(portFsm, PortFsmEvent.PORT_DEL, context);
}
Also used : PortFsm(org.openkilda.wfm.topology.network.controller.port.PortFsm) PortFsmContext(org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmContext)

Example 5 with PortFsm

use of org.openkilda.wfm.topology.network.controller.port.PortFsm in project open-kilda by telstra.

the class NetworkPortService method discovery.

/**
 * Feed port FSM with discovery event from discovery poll subsystem.
 */
public void discovery(Endpoint endpoint, IslInfoData speakerDiscoveryEvent) {
    log.debug("Port service receive discovery for {}: {}", endpoint, speakerDiscoveryEvent);
    PortFsm portFsm = locateController(endpoint);
    PortFsmContext context = PortFsmContext.builder(carrier).speakerDiscoveryEvent(speakerDiscoveryEvent).build();
    controllerExecutor.fire(portFsm, PortFsmEvent.DISCOVERY, context);
}
Also used : PortFsm(org.openkilda.wfm.topology.network.controller.port.PortFsm) PortFsmContext(org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmContext)

Aggregations

PortFsm (org.openkilda.wfm.topology.network.controller.port.PortFsm)8 PortFsmContext (org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmContext)5 PortFsmEvent (org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmEvent)3 MessageException (org.openkilda.messaging.error.MessageException)1 PortProperties (org.openkilda.model.PortProperties)1 PersistenceException (org.openkilda.persistence.exceptions.PersistenceException)1