use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.
the class VdsNotRespondingTreatmentCommand method isConnectivityBrokenThresholdReached.
private boolean isConnectivityBrokenThresholdReached(VDS vds) {
Cluster cluster = clusterDao.get(vds.getClusterId());
int percents = 0;
boolean result = false;
if (cluster.getFencingPolicy().isSkipFencingIfConnectivityBroken()) {
List<VDS> hosts = vdsDao.getAllForCluster(cluster.getId());
double hostsNumber = hosts.size();
double hostsWithBrokenConnectivityNumber = hosts.stream().filter(h -> h.getStatus() == VDSStatus.Connecting || h.getStatus() == VDSStatus.NonResponsive).count();
percents = (int) ((hostsWithBrokenConnectivityNumber / hostsNumber) * 100);
result = percents >= cluster.getFencingPolicy().getHostsWithBrokenConnectivityThreshold();
}
if (result) {
logAlert(vds, percents);
}
return result;
}
use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.
the class RemoveStorageDomainCommand method validate.
@Override
protected boolean validate() {
if (!super.validate()) {
return false;
}
StorageDomain dom = getStorageDomain();
if (dom == null) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_EXIST);
}
VDS vds = getVds();
boolean localFs = isLocalFs(dom);
if (vds == null) {
if (localFs) {
if (!initializeVds()) {
return false;
}
} else {
return failValidation(EngineMessage.CANNOT_REMOVE_STORAGE_DOMAIN_INVALID_HOST_ID);
}
} else if (vds.getStatus() != VDSStatus.Up) {
return failValidation(EngineMessage.CANNOT_REMOVE_STORAGE_DOMAIN_HOST_NOT_UP, String.format("$%1$s %2$s", "hostName", vds.getName()));
}
StorageDomainToPoolRelationValidator domainPoolValidator = createDomainToPoolValidator(dom);
if (!checkStorageDomain()) {
return false;
}
if (!localFs && !validate(domainPoolValidator.isStorageDomainNotInAnyPool())) {
return false;
}
if (localFs && isDomainAttached(dom) && !canDetachDomain(getParameters().getDestroyingPool())) {
return false;
}
if (getParameters().getDoFormat() && !localFs && isStorageDomainAttached(dom)) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_FORMAT_STORAGE_DOMAIN_WITH_ATTACHED_DATA_DOMAIN);
}
if (dom.getStorageType().isOpenStackDomain()) {
return failValidation(EngineMessage.ERROR_CANNOT_MANAGE_STORAGE_DOMAIN);
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.
the class AddStoragePoolWithStoragesCommand method executeCommand.
@Override
protected void executeCommand() {
if (updateStorageDomainsInDb()) {
// setting storage pool status to maintenance
StoragePool storagePool = getStoragePool();
getCompensationContext().snapshotEntity(storagePool);
TransactionSupport.executeInNewTransaction(() -> {
getStoragePool().setStatus(StoragePoolStatus.Maintenance);
getStoragePool().setStoragePoolFormatType(masterStorageDomain.getStorageFormat());
storagePoolDao.update(getStoragePool());
getCompensationContext().stateChanged();
StoragePoolStatusHandler.poolStatusChanged(getStoragePool().getId(), getStoragePool().getStatus());
return null;
});
// Following code performs only read operations, therefore no need for new transaction
boolean result = false;
// Once we create a storage pool with multiple hosts, the engine should connect all
// the hosts in the storage pool,
// since the engine picks a random host to fetch all the unregistered disks.
boolean isStoragePoolCreated = false;
retVal = null;
for (VDS vds : getAllRunningVdssInPool()) {
setVds(vds);
for (Guid storageDomainId : getParameters().getStorages()) {
// now the domain should have the mapping
// with the pool in db
StorageDomain storageDomain = storageDomainDao.getForStoragePool(storageDomainId, getStoragePool().getId());
storageHelperDirector.getItem(storageDomain.getStorageType()).connectStorageToDomainByVdsId(storageDomain, getVds().getId());
}
if (!isStoragePoolCreated) {
// but didn't throw exception
if (!cleanDirtyMetaDataIfNeeded()) {
result = false;
} else {
retVal = addStoragePoolInIrs();
if (!retVal.getSucceeded() && retVal.getVdsError().getCode() == EngineError.StorageDomainAccessError) {
log.warn("Error creating storage pool on vds '{}' - continuing", vds.getName());
continue;
}
result = retVal.getSucceeded();
}
isStoragePoolCreated = true;
}
}
setSucceeded(result);
if (!result) {
if (retVal != null && retVal.getVdsError().getCode() != null) {
throw new EngineException(retVal.getVdsError().getCode(), retVal.getVdsError().getMessage());
} else {
// command
throw new EngineException(EngineError.ENGINE_ERROR_CREATING_STORAGE_POOL);
}
}
registerOvfStoreDisks();
}
// Create pool phase completed, no rollback is needed here, so compensation information needs to be cleared!
TransactionSupport.executeInNewTransaction(() -> {
getCompensationContext().cleanupCompensationDataAfterSuccessfulCommand();
return null;
});
freeLock();
// if create succeeded activate
if (getSucceeded()) {
activateStorageDomains();
}
}
use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.
the class RefreshLunsSizeCommand method getDeviceListAllVds.
/**
* This method calls GetDeviceList with the specified luns on all hosts.
* In VDSM , this call will resize the devices if needed.
* It returns a map of LUN ID to a list of Pair(VDS,LUNs)
* This map will help to check if all hosts are seeing the same size of the LUNs.
*/
private Map<String, List<Pair<VDS, LUNs>>> getDeviceListAllVds(Set<String> lunsToResize) {
Map<String, List<Pair<VDS, LUNs>>> lunToVds = new HashMap<>();
for (VDS vds : getAllRunningVdssInPool()) {
GetDeviceListVDSCommandParameters parameters = new GetDeviceListVDSCommandParameters(vds.getId(), getStorageDomain().getStorageType(), false, lunsToResize);
List<LUNs> luns = (List<LUNs>) runVdsCommand(VDSCommandType.GetDeviceList, parameters).getReturnValue();
for (LUNs lun : luns) {
lunToVds.computeIfAbsent(lun.getLUNId(), k -> new ArrayList<>()).add(new Pair<>(vds, lun));
}
}
return lunToVds;
}
use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.
the class ReconstructMasterDomainCommand method connectAndRefreshAllUpHosts.
private void connectAndRefreshAllUpHosts(final boolean commandSucceeded) {
if (isLastMaster || !commandSucceeded) {
log.warn("skipping connect and refresh for all hosts, last master '{}', command status '{}'", isLastMaster, commandSucceeded);
return;
}
List<Callable<Void>> tasks = new ArrayList<>();
for (final VDS vds : getAllRunningVdssInPool()) {
tasks.add(() -> {
try {
if (!connectVdsToNewMaster(vds)) {
log.warn("failed to connect vds '{}' to the new master '{}'", vds.getId(), getNewMasterStorageDomainId());
return null;
}
List<StoragePoolIsoMap> storagePoolIsoMap = storagePoolIsoMapDao.getAllForStoragePool(getStoragePool().getId());
try {
runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds, getStoragePool(), getNewMasterStorageDomainId(), storagePoolIsoMap, true));
} catch (EngineException ex) {
if (EngineError.StoragePoolUnknown == ex.getVdsError().getCode()) {
VDSReturnValue returnVal = runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds, getStoragePool(), getNewMasterStorageDomainId(), storagePoolIsoMap));
if (!returnVal.getSucceeded()) {
log.error("Post reconstruct actions (connectPool) did not complete on host '{}' in the pool. error {}", vds.getId(), returnVal.getVdsError().getMessage());
}
} else {
log.error("Post reconstruct actions (refreshPool)" + " did not complete on host '{}' in the pool. error {}", vds.getId(), ex.getMessage());
}
}
} catch (Exception e) {
log.error("Post reconstruct actions (connectPool,refreshPool,disconnect storage)" + " did not complete on host '{}' in the pool: {}", vds.getId(), e.getMessage());
log.debug("Exception", e);
}
return null;
});
}
ThreadPoolUtil.invokeAll(tasks);
}
Aggregations