use of org.ovirt.engine.core.common.vdscommands.HSMGetStorageDomainsListVDSCommandParameters in project ovirt-engine by oVirt.
the class GetExistingStorageDomainListQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
ArrayList<StorageDomain> returnValue = new ArrayList<>();
VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.HSMGetStorageDomainsList, new HSMGetStorageDomainsListVDSCommandParameters(getParameters().getId(), Guid.Empty, null, getParameters().getStorageDomainType(), getParameters().getPath()));
if (vdsReturnValue.getSucceeded()) {
ArrayList<Guid> guidsFromIrs = (ArrayList<Guid>) vdsReturnValue.getReturnValue();
HashSet<Guid> guidsFromDb = new HashSet<>();
if (guidsFromIrs.size() > 0) {
List<StorageDomain> domainsInDb = storageDomainDao.getAll();
for (StorageDomain domain : domainsInDb) {
guidsFromDb.add(domain.getId());
}
for (Guid domainId : guidsFromIrs) {
if (!guidsFromDb.contains(domainId)) {
Pair<StorageDomainStatic, Guid> domainFromIrs = (Pair<StorageDomainStatic, Guid>) runVdsCommand(VDSCommandType.HSMGetStorageDomainInfo, new HSMGetStorageDomainInfoVDSCommandParameters(getParameters().getId(), domainId)).getReturnValue();
StorageDomain domain = new StorageDomain();
domain.setStorageStaticData(domainFromIrs.getFirst());
domain.setStoragePoolId(domainFromIrs.getSecond());
if (getParameters().getStorageFormatType() == null || getParameters().getStorageFormatType() == domain.getStorageFormat()) {
if (getParameters().getStorageType() != null && domain.getStorageType().getValue() != getParameters().getStorageType().getValue()) {
log.warn("The storage type of domain {} has been changed from {} to {}", domain.getStorageName(), domain.getStorageType().toString(), getParameters().getStorageType().toString());
domain.setStorageType(getParameters().getStorageType());
}
returnValue.add(domain);
}
}
}
}
getQueryReturnValue().setReturnValue(returnValue);
}
}
Aggregations