Skip to content

Commit f8e8320

Browse files
Out-of-band management (OOBM) improvements
1 parent 2dbc86a commit f8e8320

File tree

3 files changed

+34
-21
lines changed

3 files changed

+34
-21
lines changed

api/src/main/java/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public interface OutOfBandManagementService {
3838

3939
long getId();
4040
boolean isOutOfBandManagementEnabled(Host host);
41+
boolean isOutOfBandManagementEnabledForHost(Long hostId);
4142
void submitBackgroundPowerSyncTask(Host host);
4243
boolean transitionPowerStateToDisabled(List<Long> hostIds);
4344

plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/kvm/ha/KVMHAProvider.java

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public final class KVMHAProvider extends HAAbstractHostProvider implements HAPro
4747

4848
@Override
4949
public boolean isEligible(final Host host) {
50-
if (outOfBandManagementService.isOutOfBandManagementEnabled(host)){
50+
if (outOfBandManagementService.isOutOfBandManagementEnabled(host)) {
5151
return !isInMaintenanceMode(host) && !isDisabled(host) &&
5252
hostActivityChecker.getNeighbors(host).length > 0 &&
5353
(Hypervisor.HypervisorType.KVM.equals(host.getHypervisorType()) ||
@@ -57,45 +57,54 @@ public boolean isEligible(final Host host) {
5757
}
5858

5959
@Override
60-
public boolean isHealthy(final Host r) throws HACheckerException {
61-
return hostActivityChecker.isHealthy(r);
60+
public boolean isHealthy(final Host host) throws HACheckerException {
61+
return hostActivityChecker.isHealthy(host);
6262
}
6363

6464
@Override
65-
public boolean hasActivity(final Host r, final DateTime suspectTime) throws HACheckerException {
66-
return hostActivityChecker.isActive(r, suspectTime);
65+
public boolean hasActivity(final Host host, final DateTime suspectTime) throws HACheckerException {
66+
return hostActivityChecker.isActive(host, suspectTime);
6767
}
6868

6969
@Override
70-
public boolean recover(Host r) throws HARecoveryException {
70+
public boolean recover(Host host) throws HARecoveryException {
7171
try {
72-
if (outOfBandManagementService.isOutOfBandManagementEnabled(r)){
73-
final OutOfBandManagementResponse resp = outOfBandManagementService.executePowerOperation(r, PowerOperation.RESET, null);
72+
if (outOfBandManagementService.isOutOfBandManagementEnabled(host)) {
73+
final OutOfBandManagementResponse resp = outOfBandManagementService.executePowerOperation(host, PowerOperation.RESET, null);
7474
return resp.getSuccess();
7575
} else {
76-
logger.warn("OOBM recover operation failed for the host {}", r);
76+
logger.warn("OOBM recover operation failed for the host {}", host);
7777
return false;
7878
}
79-
} catch (Exception e){
80-
logger.warn("OOBM service is not configured or enabled for this host {} error is {}", r, e.getMessage());
81-
throw new HARecoveryException(String.format(" OOBM service is not configured or enabled for this host %s", r), e);
79+
} catch (Exception e) {
80+
String msg = "Failed to recover host " + host;
81+
if (host != null && !outOfBandManagementService.isOutOfBandManagementEnabledForHost(host.getId())) {
82+
msg = "OOBM service is not configured or enabled for this host " + host;
83+
}
84+
85+
logger.warn("{}, error is {}", msg, e.getMessage());
86+
throw new HARecoveryException(msg, e);
8287
}
8388
}
8489

8590
@Override
86-
public boolean fence(Host r) throws HAFenceException {
87-
91+
public boolean fence(Host host) throws HAFenceException {
8892
try {
89-
if (outOfBandManagementService.isOutOfBandManagementEnabled(r)){
90-
final OutOfBandManagementResponse resp = outOfBandManagementService.executePowerOperation(r, PowerOperation.OFF, null);
93+
if (outOfBandManagementService.isOutOfBandManagementEnabled(host)){
94+
final OutOfBandManagementResponse resp = outOfBandManagementService.executePowerOperation(host, PowerOperation.OFF, null);
9195
return resp.getSuccess();
9296
} else {
93-
logger.warn("OOBM fence operation failed for this host {}", r);
97+
logger.warn("OOBM fence operation failed for this host {}", host);
9498
return false;
9599
}
96-
} catch (Exception e){
97-
logger.warn("OOBM service is not configured or enabled for this host {} error is {}", r, e.getMessage());
98-
throw new HAFenceException(String.format("OBM service is not configured or enabled for this host %s", r.getName()), e);
100+
} catch (Exception e) {
101+
String msg = "Failed to fence host " + host;
102+
if (host != null && !outOfBandManagementService.isOutOfBandManagementEnabledForHost(host.getId())) {
103+
msg = "OOBM service is not configured or enabled for this host " + host;
104+
}
105+
106+
logger.warn("{}, error is {}", msg, e.getMessage());
107+
throw new HAFenceException(msg, e);
99108
}
100109
}
101110

server/src/main/java/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementServiceImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ private boolean isOutOfBandManagementEnabledForZone(Long zoneId) {
236236
}
237237
final DataCenterDetailVO zoneDetails = dataCenterDetailsDao.findDetail(zoneId, OOBM_ENABLED_DETAIL);
238238
if (zoneDetails != null && StringUtils.isNotEmpty(zoneDetails.getValue()) && !Boolean.valueOf(zoneDetails.getValue())) {
239+
logger.debug("Out-of-band management disabled for zone {}", zoneId);
239240
return false;
240241
}
241242
return true;
@@ -247,12 +248,13 @@ private boolean isOutOfBandManagementEnabledForCluster(Long clusterId) {
247248
}
248249
final ClusterDetailsVO clusterDetails = clusterDetailsDao.findDetail(clusterId, OOBM_ENABLED_DETAIL);
249250
if (clusterDetails != null && StringUtils.isNotEmpty(clusterDetails.getValue()) && !Boolean.valueOf(clusterDetails.getValue())) {
251+
logger.debug("Out-of-band management disabled for cluster {}", clusterId);
250252
return false;
251253
}
252254
return true;
253255
}
254256

255-
private boolean isOutOfBandManagementEnabledForHost(Long hostId) {
257+
public boolean isOutOfBandManagementEnabledForHost(Long hostId) {
256258
if (hostId == null) {
257259
return false;
258260
}
@@ -266,6 +268,7 @@ private boolean isOutOfBandManagementEnabledForHost(Long hostId) {
266268

267269
final OutOfBandManagement outOfBandManagementConfig = outOfBandManagementDao.findByHost(hostId);
268270
if (outOfBandManagementConfig == null || !outOfBandManagementConfig.isEnabled()) {
271+
logger.debug("Out-of-band management disabled for host {}", hostId);
269272
return false;
270273
}
271274
return true;

0 commit comments

Comments
 (0)