use of org.ovirt.engine.core.common.vdscommands.SpmStopVDSCommandParameters in project ovirt-engine by oVirt.
the class IrsProxy method failover.
public boolean failover() {
Guid vdsId = currentVdsId;
nullifyInternalProxies();
boolean performFailover = false;
if (vdsId != null) {
try {
VDSReturnValue statusResult = resourceManager.runVdsCommand(VDSCommandType.SpmStatus, new SpmStatusVDSCommandParameters(vdsId, storagePoolId));
if (statusResult != null && statusResult.getSucceeded() && (((SpmStatusResult) statusResult.getReturnValue()).getSpmStatus() == SpmStatus.SPM || ((SpmStatusResult) statusResult.getReturnValue()).getSpmStatus() == SpmStatus.Contend)) {
performFailover = resourceManager.runVdsCommand(VDSCommandType.SpmStop, new SpmStopVDSCommandParameters(vdsId, storagePoolId)).getSucceeded();
} else {
performFailover = true;
}
} catch (Exception ex) {
// try to failover to another host if failed to get spm
// status or stop spm
// (in case currentVdsId has wrong id for some reason)
log.error("Could not get spm status on host '{}' for spmStop: {}", vdsId, ex.getMessage());
log.debug("Exception", ex);
performFailover = true;
}
}
if (performFailover) {
log.info("Irs placed on server '{}' failed. Proceed Failover", vdsId);
triedVdssList.add(vdsId);
return true;
} else {
log.error("IRS failover failed - can't allocate vds server");
return false;
}
}
use of org.ovirt.engine.core.common.vdscommands.SpmStopVDSCommandParameters in project ovirt-engine by oVirt.
the class IrsProxy method handleSpmStatusResult.
private SpmStatusResult handleSpmStatusResult(Guid curVdsId, List<VDS> vdsByPool, final StoragePool storagePool, RefObject<VDS> selectedVds, SpmStatusResult spmStatus) {
if (spmStatus.getSpmStatus() == SpmStatus.Free) {
int vdsSpmIdToFence = -1;
boolean startSpm = true;
if (spmStatus.getSpmId() != -1 && !wasVdsManuallyFenced(spmStatus.getSpmId())) {
int spmId = spmStatus.getSpmId();
Guid spmVdsId = Guid.Empty;
VDS spmVds = null;
if (selectedVds.argvalue.getVdsSpmId() == spmId) {
spmVdsId = selectedVds.argvalue.getId();
} else {
for (VDS tempVds : vdsByPool) {
if (tempVds.getVdsSpmId() == spmId) {
log.info("Found spm host '{}', host name: '{}', according to spmId: '{}'.", tempVds.getId(), tempVds.getName(), spmId);
spmVds = tempVds;
break;
}
}
// non operational we want to find it as well
if (spmVds == null) {
List<VDS> nonOperationalVds = vdsDao.getAllForStoragePoolAndStatus(storagePoolId, VDSStatus.NonOperational);
for (VDS tempVds : nonOperationalVds) {
if (tempVds.getVdsSpmId() == spmId) {
spmVds = tempVds;
break;
}
}
}
if (spmVds != null) {
spmVdsId = spmVds.getId();
} else if (!curVdsId.equals(Guid.Empty)) {
VDS currentVds = vdsDao.get(curVdsId);
if (currentVds != null && currentVds.getStatus() == VDSStatus.Up && currentVds.getVdsSpmId() != null && currentVds.getVdsSpmId().equals(spmId)) {
spmVdsId = curVdsId;
spmVds = currentVds;
}
}
}
try {
if (!spmVdsId.equals(Guid.Empty)) {
SpmStatusResult destSpmStatus = (SpmStatusResult) resourceManager.runVdsCommand(VDSCommandType.SpmStatus, new SpmStatusVDSCommandParameters(spmVdsId, storagePoolId)).getReturnValue();
log.info("SpmStatus on vds '{}': '{}'", spmVdsId, destSpmStatus == null ? "NULL" : destSpmStatus.getSpmStatus());
// intentionally unreachable code
if (destSpmStatus != null && destSpmStatus.getSpmStatus() == SpmStatus.SPM) {
if (!spmVdsId.equals(selectedVds.argvalue.getId()) && spmVds != null && spmVds.getStatus() == VDSStatus.Up) {
selectedVds.argvalue = spmVds;
startSpm = false;
log.info("Using old spm server: '{}', no start needed", spmVds.getName());
return destSpmStatus;
} else // VDS is non-operational and SPM
{
log.warn("Host reports to be SPM '{}', but is not up.", spmVdsId);
vdsSpmIdToFence = spmStatus.getSpmId();
}
} else // it is not SPM and continue.
if (destSpmStatus == null || (destSpmStatus.getSpmStatus() != SpmStatus.Free && destSpmStatus.getSpmStatus() != SpmStatus.Unknown_Pool)) {
vdsSpmIdToFence = spmStatus.getSpmId();
}
} else {
log.error("SPM Init: could not find reported vds or not up - pool: '{}' vds_spm_id: '{}'", storagePool.getName(), spmStatus.getSpmId());
vdsSpmIdToFence = spmStatus.getSpmId();
}
} catch (Exception ex) {
vdsSpmIdToFence = spmStatus.getSpmId();
}
}
if (startSpm) {
VdsSpmIdMap map = vdsSpmIdMapDao.get(storagePoolId, vdsSpmIdToFence);
if (map != null) {
VDS vdsToFenceObject = vdsDao.get(map.getId());
if (vdsToFenceObject != null) {
log.info("SPM selection - vds seems as spm '{}'", vdsToFenceObject.getName());
if (vdsToFenceObject.getStatus() == VDSStatus.NonResponsive) {
log.warn("spm vds is non responsive, stopping spm selection.");
selectedVds.argvalue = null;
return spmStatus;
} else {
// try to stop spm
VDSReturnValue spmStopReturnValue = resourceManager.runVdsCommand(VDSCommandType.SpmStop, new SpmStopVDSCommandParameters(vdsToFenceObject.getId(), storagePoolId));
// continue with spm selection
if (spmStopReturnValue != null && spmStopReturnValue.getSucceeded()) {
log.info("spm stop succeeded, continuing with spm selection");
} else // if spm stop failed for any reason we stop spm
// selection
{
log.warn("spm stop on spm failed, stopping spm selection!");
selectedVds.argvalue = null;
return spmStatus;
}
}
}
}
spmStatus = startSpm(storagePool, selectedVds.argvalue, spmStatus.getSpmId(), spmStatus.getSpmLVER(), vdsSpmIdToFence);
}
}
return spmStatus;
}
use of org.ovirt.engine.core.common.vdscommands.SpmStopVDSCommandParameters in project ovirt-engine by oVirt.
the class ResetIrsVDSCommand method executeVDSCommand.
@Override
protected void executeVDSCommand() {
P parameters = getParameters();
Guid vdsId = parameters.getVdsId();
if (getParameters().isVdsAlreadyRebooted() || resourceManager.runVdsCommand(VDSCommandType.SpmStop, new SpmStopVDSCommandParameters(vdsId, parameters.getStoragePoolId())).getSucceeded() || parameters.getIgnoreStopFailed()) {
if (getParameters().getPreferredSPMId() != null) {
getCurrentIrsProxy().setPreferredHostId(getParameters().getPreferredSPMId());
}
if (getParameters().isVdsAlreadyRebooted()) {
getCurrentIrsProxy().setFencedIrs(vdsId);
}
getCurrentIrsProxy().resetIrs();
StoragePool pool = DbFacade.getInstance().getStoragePoolDao().get(parameters.getStoragePoolId());
if (pool != null && (pool.getStatus() == StoragePoolStatus.NotOperational)) {
resourceManager.getEventListener().storagePoolStatusChange(parameters.getStoragePoolId(), StoragePoolStatus.NonResponsive, AuditLogType.SYSTEM_CHANGE_STORAGE_POOL_STATUS_RESET_IRS, EngineError.ENGINE);
}
} else {
getVDSReturnValue().setSucceeded(false);
}
}
Aggregations