Search in sources :

Example 1 with PortFsmContext

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

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

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

Example 4 with PortFsmContext

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

the class NetworkPortService method fail.

/**
 * Feed port FSM with fail event from discovery poll subsystem.
 */
public void fail(Endpoint endpoint) {
    log.debug("Port service receive fail for {}", endpoint);
    PortFsm portFsm = locateController(endpoint);
    PortFsmContext context = PortFsmContext.builder(carrier).build();
    controllerExecutor.fire(portFsm, PortFsmEvent.FAIL, 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 PortFsmContext

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

the class NetworkPortService method roundTripStatusNotification.

/**
 * Handle round trip status notification.
 */
public void roundTripStatusNotification(RoundTripStatus status) {
    log.debug("Port service receive round trip status notification: {}", status);
    PortFsm portFsm = locateController(status.getEndpoint());
    PortFsmContext context = PortFsmContext.builder(carrier).roundTripStatus(status).build();
    controllerExecutor.fire(portFsm, PortFsmEvent.ROUND_TRIP_STATUS, 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)5 PortFsmContext (org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmContext)5 MessageException (org.openkilda.messaging.error.MessageException)1 PortProperties (org.openkilda.model.PortProperties)1 PersistenceException (org.openkilda.persistence.exceptions.PersistenceException)1 PortFsmEvent (org.openkilda.wfm.topology.network.controller.port.PortFsm.PortFsmEvent)1