Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public interface OutOfBandManagementService {

long getId();
boolean isOutOfBandManagementEnabled(Host host);
boolean isOutOfBandManagementEnabledForHost(Long hostId);
void submitBackgroundPowerSyncTask(Host host);
boolean transitionPowerStateToDisabled(List<Long> hostIds);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public final class KVMHAProvider extends HAAbstractHostProvider implements HAPro

@Override
public boolean isEligible(final Host host) {
if (outOfBandManagementService.isOutOfBandManagementEnabled(host)){
if (outOfBandManagementService.isOutOfBandManagementEnabled(host)) {
return !isInMaintenanceMode(host) && !isDisabled(host) &&
hostActivityChecker.getNeighbors(host).length > 0 &&
(Hypervisor.HypervisorType.KVM.equals(host.getHypervisorType()) ||
Expand All @@ -57,45 +57,54 @@ public boolean isEligible(final Host host) {
}

@Override
public boolean isHealthy(final Host r) throws HACheckerException {
return hostActivityChecker.isHealthy(r);
public boolean isHealthy(final Host host) throws HACheckerException {
return hostActivityChecker.isHealthy(host);
}

@Override
public boolean hasActivity(final Host r, final DateTime suspectTime) throws HACheckerException {
return hostActivityChecker.isActive(r, suspectTime);
public boolean hasActivity(final Host host, final DateTime suspectTime) throws HACheckerException {
return hostActivityChecker.isActive(host, suspectTime);
}

@Override
public boolean recover(Host r) throws HARecoveryException {
public boolean recover(Host host) throws HARecoveryException {
try {
if (outOfBandManagementService.isOutOfBandManagementEnabled(r)){
final OutOfBandManagementResponse resp = outOfBandManagementService.executePowerOperation(r, PowerOperation.RESET, null);
if (outOfBandManagementService.isOutOfBandManagementEnabled(host)) {
final OutOfBandManagementResponse resp = outOfBandManagementService.executePowerOperation(host, PowerOperation.RESET, null);
return resp.getSuccess();
} else {
logger.warn("OOBM recover operation failed for the host {}", r);
logger.warn("OOBM recover operation failed for the host {}", host);
return false;
}
} catch (Exception e){
logger.warn("OOBM service is not configured or enabled for this host {} error is {}", r, e.getMessage());
throw new HARecoveryException(String.format(" OOBM service is not configured or enabled for this host %s", r), e);
} catch (Exception e) {
String msg = "Failed to recover host " + host;
if (host != null && !outOfBandManagementService.isOutOfBandManagementEnabledForHost(host.getId())) {
msg = "OOBM service is not configured or enabled for this host " + host;
}

logger.warn("{}, error is {}", msg, e.getMessage());
throw new HARecoveryException(msg, e);
}
}

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

public boolean fence(Host host) throws HAFenceException {
try {
if (outOfBandManagementService.isOutOfBandManagementEnabled(r)){
final OutOfBandManagementResponse resp = outOfBandManagementService.executePowerOperation(r, PowerOperation.OFF, null);
if (outOfBandManagementService.isOutOfBandManagementEnabled(host)){
final OutOfBandManagementResponse resp = outOfBandManagementService.executePowerOperation(host, PowerOperation.OFF, null);
return resp.getSuccess();
} else {
logger.warn("OOBM fence operation failed for this host {}", r);
logger.warn("OOBM fence operation failed for this host {}", host);
return false;
}
} catch (Exception e){
logger.warn("OOBM service is not configured or enabled for this host {} error is {}", r, e.getMessage());
throw new HAFenceException(String.format("OBM service is not configured or enabled for this host %s", r.getName()), e);
} catch (Exception e) {
String msg = "Failed to fence host " + host;
if (host != null && !outOfBandManagementService.isOutOfBandManagementEnabledForHost(host.getId())) {
msg = "OOBM service is not configured or enabled for this host " + host;
}

logger.warn("{}, error is {}", msg, e.getMessage());
throw new HAFenceException(msg, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ private boolean isOutOfBandManagementEnabledForZone(Long zoneId) {
}
final DataCenterDetailVO zoneDetails = dataCenterDetailsDao.findDetail(zoneId, OOBM_ENABLED_DETAIL);
if (zoneDetails != null && StringUtils.isNotEmpty(zoneDetails.getValue()) && !Boolean.valueOf(zoneDetails.getValue())) {
logger.debug("Out-of-band management disabled for zone {}", zoneId);
return false;
}
return true;
Expand All @@ -247,12 +248,13 @@ private boolean isOutOfBandManagementEnabledForCluster(Long clusterId) {
}
final ClusterDetailsVO clusterDetails = clusterDetailsDao.findDetail(clusterId, OOBM_ENABLED_DETAIL);
if (clusterDetails != null && StringUtils.isNotEmpty(clusterDetails.getValue()) && !Boolean.valueOf(clusterDetails.getValue())) {
logger.debug("Out-of-band management disabled for cluster {}", clusterId);
return false;
}
return true;
}

private boolean isOutOfBandManagementEnabledForHost(Long hostId) {
public boolean isOutOfBandManagementEnabledForHost(Long hostId) {
if (hostId == null) {
return false;
}
Expand All @@ -266,6 +268,7 @@ private boolean isOutOfBandManagementEnabledForHost(Long hostId) {

final OutOfBandManagement outOfBandManagementConfig = outOfBandManagementDao.findByHost(hostId);
if (outOfBandManagementConfig == null || !outOfBandManagementConfig.isEnabled()) {
logger.debug("Out-of-band management disabled for host {}", hostId);
return false;
}
return true;
Expand Down
Loading