use of org.onosproject.segmentrouting.phasedrecovery.api.Phase in project trellis-control by opennetworkinglab.
the class PhasedRecoverySetCommand method doExecute.
@Override
protected void doExecute() {
DeviceId deviceId = DeviceId.deviceId(deviceIdStr);
Phase newPhase = Phase.valueOf(phaseStr);
PhasedRecoveryService prService = get(PhasedRecoveryService.class);
prService.setPhase(deviceId, newPhase);
}
use of org.onosproject.segmentrouting.phasedrecovery.api.Phase in project trellis-control by opennetworkinglab.
the class PhasedRecoveryManager method init.
@Override
public boolean init(DeviceId deviceId) {
if (this.srService == null) {
log.info("SegmentRoutingService is not ready");
return false;
}
if (!srService.shouldProgram(deviceId)) {
log.info("Skip init not leading the phase recovery of {}", deviceId);
return false;
}
Phase phase = Optional.ofNullable(phasedRecoveryStore.putIfAbsent(deviceId, Phase.PENDING)).map(Versioned::value).orElse(null);
if (phase != null) {
log.info("{} has been initialized already. Skipping.", deviceId);
return false;
} else {
if (phasedRecovery) {
// Even in case of EDGE as next phase, it is better to drive the transition
// to the next phase through the port checker. If the device is reported by
// a non master instance the first time, ports wont be available until the next
// port reconciliation.
Phase nextPhase = this.srService.getPairDeviceId(deviceId).isPresent() ? Phase.PAIR : Phase.EDGE;
// Wait for the PORT_STAT before entering next phase.
// Note: Unlikely, when the device init fails due to PORT_STATS timeout,
// it requires operator to manually move the device to the next phase by CLI command.
executor.schedule(new PortChecker(deviceId, PORT_CHECKER_RETRIES, nextPhase), PORT_CHECKER_INTERVAL, TimeUnit.SECONDS);
} else {
// We assume that all ports will be reported as enabled on devices that don't require phased recovery
setPhase(deviceId, Phase.EDGE);
}
return true;
}
}
Aggregations