use of org.onosproject.net.device.DeviceProvider in project onos by opennetworkinglab.
the class DeviceManager method changePortStateAtMaster.
private void changePortStateAtMaster(DeviceId deviceId, PortNumber portNumber, boolean enable) {
DeviceProvider provider = getProvider(deviceId);
if (provider != null) {
log.info("Port {} on device {} being administratively brought {}", portNumber, deviceId, (enable) ? "UP" : "DOWN");
provider.changePortState(deviceId, portNumber, enable);
} else {
log.warn("Provider not found for {}", deviceId);
}
}
use of org.onosproject.net.device.DeviceProvider in project onos by opennetworkinglab.
the class DeviceManager method applyRoleAndProbe.
// Applies the specified role to the device; ignores NONE
/**
* Apply role to device and send probe if MASTER.
*
* @param deviceId device identifier
* @param newRole new role to apply to the device
* @return true if the request was sent to provider
*/
private boolean applyRoleAndProbe(DeviceId deviceId, MastershipRole newRole) {
if (newRole.equals(MastershipRole.NONE)) {
// no-op
return true;
}
DeviceProvider provider = getProvider(deviceId);
if (provider == null) {
log.warn("Provider for {} was not found. Cannot apply role {}", deviceId, newRole);
return false;
}
// Start the timer
roleToAcknowledge.put(deviceId, currentTimeMillis());
provider.roleChanged(deviceId, newRole);
if (newRole.equals(MastershipRole.MASTER)) {
log.debug("sent TriggerProbe({})", deviceId);
// only trigger event when request was sent to provider
provider.triggerProbe(deviceId);
}
return true;
}
use of org.onosproject.net.device.DeviceProvider in project onos by opennetworkinglab.
the class DeviceManager method inGracePeriod.
// Returns true if the grace period is still on
private boolean inGracePeriod(DeviceId deviceId) {
LocalStatus ls = deviceLocalStatus.get(deviceId);
if (ls == null) {
// This should not be possible, unless the device is removed
log.warn("Not found a recent local status for {}", deviceId);
return true;
}
DeviceProvider provider = getProvider(deviceId);
return ls.connected && (Instant.now().toEpochMilli() - ls.dateTime.toEpochMilli()) < provider.gracePeriod();
}
Aggregations