Search in sources :

Example 1 with Phase

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);
}
Also used : PhasedRecoveryService(org.onosproject.segmentrouting.phasedrecovery.api.PhasedRecoveryService) Phase(org.onosproject.segmentrouting.phasedrecovery.api.Phase) DeviceId(org.onosproject.net.DeviceId)

Example 2 with Phase

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;
    }
}
Also used : Phase(org.onosproject.segmentrouting.phasedrecovery.api.Phase)

Aggregations

Phase (org.onosproject.segmentrouting.phasedrecovery.api.Phase)2 DeviceId (org.onosproject.net.DeviceId)1 PhasedRecoveryService (org.onosproject.segmentrouting.phasedrecovery.api.PhasedRecoveryService)1