Skip to content
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,24 @@ public boolean recover(Host r) throws HARecoveryException {

@Override
public boolean fence(Host r) throws HAFenceException {

try {
if (outOfBandManagementService.isOutOfBandManagementEnabled(r)){
final OutOfBandManagementResponse resp = outOfBandManagementService.executePowerOperation(r, PowerOperation.OFF, null);
return resp.getSuccess();
// host exists and is managed OOB
if (r != null && outOfBandManagementService.isOutOfBandManagementEnabled(r)) {
// check host status
if (Host.Status.DOWN.equals(r.getStatus())) {
LOG.info("Host " + r.getName() + " is already down. Returning success.");
return true;
} else {
final OutOfBandManagementResponse resp = outOfBandManagementService.executePowerOperation(r, PowerOperation.OFF, null);
return resp.getSuccess();
}
} else {
logger.warn("OOBM fence operation failed for this host " + r.getName());
LOG.warn("OOBM fence operation failed for this host " + r.getName());
return false;
}
} catch (Exception e){
logger.warn("OOBM service is not configured or enabled for this host " + r.getName() + " error is " + e.getMessage());
throw new HAFenceException("OBM service is not configured or enabled for this host " + r.getName() , e);
} catch (Exception e) {
LOG.warn("OOBM service is not configured or enabled for this host " + r.getName() + " error is " + e.getMessage());
throw new HAFenceException("OBM service is not configured or enabled for this host " + r.getName(), e);
}
}

Expand Down
Loading