mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-15 18:12:35 +01:00
add check befor fencing
Resolve the issur : Should not shutting down a server which is already shut. Thanks for DaanHoogland which provide code.
This commit is contained in:
parent
a208db54ea
commit
8feecbc23b
@ -35,6 +35,7 @@ import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement.PowerOperat
|
||||
import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.joda.time.DateTime;
|
||||
import com.cloud.host.Status;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.security.InvalidParameterException;
|
||||
@ -86,17 +87,23 @@ public final class KVMHAProvider extends HAAbstractHostProvider implements HAPro
|
||||
|
||||
@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 (Status.Down.equals(r.getStatus())) {
|
||||
logger.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 {
|
||||
LOG.warn("OOBM fence operation failed for this host " + r.getName());
|
||||
logger.warn("OOBM fence operation failed for this host " + r.getName());
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e){
|
||||
LOG.warn("OOBM service is not configured or enabled for this host " + r.getName() + " error is " + e.getMessage());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user