Search in sources :

Example 1 with PortFsmEvent

use of org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmEvent 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 PortFsmEvent

use of org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmEvent 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 PortFsmEvent

use of org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmEvent 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)

Aggregations

PortFsm (org.openkilda.wfm.topology.network.controller.port.PortFsm)3 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 PortFsmContext (org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmContext)1