Search in sources :

Example 1 with HSMGetStorageDomainsListVDSCommandParameters

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);
    }
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) ArrayList(java.util.ArrayList) HSMGetStorageDomainInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.HSMGetStorageDomainInfoVDSCommandParameters) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) HSMGetStorageDomainsListVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.HSMGetStorageDomainsListVDSCommandParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HashSet(java.util.HashSet) Pair(org.ovirt.engine.core.common.utils.Pair)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)1 Pair (org.ovirt.engine.core.common.utils.Pair)1 HSMGetStorageDomainInfoVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.HSMGetStorageDomainInfoVDSCommandParameters)1 HSMGetStorageDomainsListVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.HSMGetStorageDomainsListVDSCommandParameters)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 Guid (org.ovirt.engine.core.compat.Guid)1