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());
}
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");
}
}
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());
}
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);
}
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);
}
Aggregations