use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.
the class MoveDiskModel method onInitDisks.
@Override
protected void onInitDisks() {
final ArrayList<DiskModel> disks = new ArrayList<>();
List<QueryType> queries = new ArrayList<>();
List<QueryParametersBase> params = new ArrayList<>();
for (DiskImage disk : getDiskImages()) {
disks.add(DiskModel.diskToModel(disk));
queries.add(QueryType.GetVmsByDiskGuid);
params.add(new IdQueryParameters(disk.getId()));
}
Frontend.getInstance().runMultipleQueries(queries, params, result -> {
for (int i = 0; i < result.getReturnValues().size(); i++) {
Map<Boolean, List<VM>> resultValue = result.getReturnValues().get(i).getReturnValue();
disks.get(i).setPluggedToRunningVm(!isAllVmsDown(resultValue));
}
setDisks(disks);
updateMoveWarning(disks);
initStorageDomains();
});
}
use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.
the class ImportVmFromExportDomainModel method initDisksStorageDomainsList.
protected void initDisksStorageDomainsList() {
for (Object item : getItems()) {
ImportVmData importVmData = (ImportVmData) item;
VM vm = importVmData.getVm();
if (!Guid.Empty.equals(vm.getVmtGuid())) {
if (!templateDiskMap.containsKey(vm.getVmtGuid())) {
templateDiskMap.put(vm.getVmtGuid(), new ArrayList<Disk>());
}
templateDiskMap.get(vm.getVmtGuid()).addAll(extractRootDisks(vm));
}
for (Disk disk : vm.getDiskMap().values()) {
DiskImage diskImage = (DiskImage) disk;
addDiskImportData(diskImage.getId(), filteredStorageDomains, diskImage.getVolumeType(), importVmData.getCollapseSnapshots());
}
}
if (!templateDiskMap.isEmpty()) {
ArrayList<QueryType> queryTypeList = new ArrayList<>();
final ArrayList<QueryParametersBase> queryParamsList = new ArrayList<>();
for (Guid templateId : templateDiskMap.keySet()) {
queryTypeList.add(QueryType.GetVmTemplatesDisks);
queryParamsList.add(new IdQueryParameters(templateId));
}
Frontend.getInstance().runMultipleQueries(queryTypeList, queryParamsList, result -> {
List<QueryReturnValue> returnValueList = result.getReturnValues();
Map<Guid, List<StorageDomain>> templateDisksStorageDomains = new HashMap<>();
for (QueryReturnValue returnValue : returnValueList) {
for (DiskImage diskImage : (ArrayList<DiskImage>) returnValue.getReturnValue()) {
templateDisksStorageDomains.put(diskImage.getImageId(), getStorageDomainsByIds(diskImage.getStorageIds()));
}
}
for (Entry<Guid, List<Disk>> guidListEntry : templateDiskMap.entrySet()) {
for (Disk disk : guidListEntry.getValue()) {
DiskImage diskImage = (DiskImage) disk;
if (diskImage.getParentId() != null && !Guid.Empty.equals(diskImage.getParentId())) {
List<StorageDomain> storageDomains = templateDisksStorageDomains.get(diskImage.getParentId());
if (storageDomains == null) {
missingTemplateDiskMap.put(guidListEntry.getKey(), guidListEntry.getValue());
}
}
}
}
if (!missingTemplateDiskMap.keySet().isEmpty()) {
getTemplatesFromExportDomain();
} else {
postInitDisks();
}
});
} else {
postInitDisks();
}
}
use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.
the class ImportVmFromExportDomainModel method initQuotaForStorageDomains.
private void initQuotaForStorageDomains() {
ArrayList<QueryType> queryTypeList = new ArrayList<>();
ArrayList<QueryParametersBase> queryParamsList = new ArrayList<>();
for (StorageDomain storage : filteredStorageDomains) {
queryTypeList.add(QueryType.GetAllRelevantQuotasForStorage);
queryParamsList.add(new IdQueryParameters(storage.getId()));
}
storageQuotaMap = new HashMap<>();
Frontend.getInstance().runMultipleQueries(queryTypeList, queryParamsList, result -> {
List<QueryReturnValue> returnValueList = result.getReturnValues();
boolean noQuota = true;
for (int i = 0; i < filteredStorageDomains.size(); i++) {
ArrayList<Quota> quotaList = returnValueList.get(i).getReturnValue();
if (noQuota && !quotaList.isEmpty()) {
noQuota = false;
}
storageQuotaMap.put(filteredStorageDomains.get(i).getId(), quotaList);
}
if (noQuota && QuotaEnforcementTypeEnum.HARD_ENFORCEMENT.equals(storagePool.getQuotaEnforcementType())) {
showCloseMessage(ConstantsManager.getInstance().getConstants().missingQuotaStorageEnforceMode());
}
initDisksStorageDomainsList();
});
}
use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.
the class ImportVmsModel method initDataCenterCpuArchitectureMap.
private void initDataCenterCpuArchitectureMap() {
final AsyncQuery<QueryReturnValue> callback = new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {
@Override
public void onSuccess(QueryReturnValue returnValue) {
List<Cluster> allClusters = returnValue.getReturnValue();
clusterArchitecturesInDataCenters = new HashMap<>();
for (Cluster cluster : allClusters) {
if (cluster.supportsVirtService() && cluster.getArchitecture() != null) {
addArchitecture(cluster.getStoragePoolId(), cluster.getArchitecture());
}
}
}
private void addArchitecture(Guid dataCenterId, ArchitectureType architecture) {
Set<ArchitectureType> architectures = clusterArchitecturesInDataCenters.get(dataCenterId);
if (architectures == null) {
architectures = new HashSet<>();
clusterArchitecturesInDataCenters.put(dataCenterId, architectures);
}
architectures.add(architecture);
}
});
Frontend.getInstance().runQuery(QueryType.GetAllClusters, new QueryParametersBase(), callback);
}
Aggregations