Search in sources :

Example 26 with StorageDomain

use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.

the class GetUnregisteredBlockStorageDomainsQuery method getStorageDomainById.

/**
 * Retrieve a storage domain using a specified storage domain ID.
 *
 * @param storageDomainId the domain's ID
 * @return the storage domain
 */
@SuppressWarnings("unchecked")
protected StorageDomain getStorageDomainById(Guid storageDomainId) {
    VDSReturnValue returnValue;
    try {
        returnValue = executeHSMGetStorageDomainInfo(new HSMGetStorageDomainInfoVDSCommandParameters(getParameters().getVdsId(), storageDomainId));
    } catch (RuntimeException e) {
        log.error("Could not get info for storage domain ID: '{}': {}", storageDomainId, e.getMessage());
        log.debug("Exception", e);
        return null;
    }
    Pair<StorageDomainStatic, SANState> result = (Pair<StorageDomainStatic, SANState>) returnValue.getReturnValue();
    StorageDomainStatic storageDomainStatic = result.getFirst();
    storageDomainStatic.setStorageType(getParameters().getStorageType());
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setStorageStaticData(storageDomainStatic);
    return storageDomain;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HSMGetStorageDomainInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.HSMGetStorageDomainInfoVDSCommandParameters) SANState(org.ovirt.engine.core.common.businessentities.SANState) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 27 with StorageDomain

use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.

the class GetStorageDomainListByIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<StorageDomain> result = storageDomainDao.getAllForStorageDomain(getParameters().getId());
    ArrayList<StorageDomain> temp = new ArrayList<>(result);
    for (StorageDomain domain : temp) {
        if (domain.getStorageDomainSharedStatus() == StorageDomainSharedStatus.Unattached) {
            result.remove(domain);
        }
    }
    getQueryReturnValue().setReturnValue(result);
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ArrayList(java.util.ArrayList)

Example 28 with StorageDomain

use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.

the class GetStorageDomainsByVmTemplateIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    vmTemplate = vmTemplateDao.get(getParameters().getId(), getUserID(), getParameters().isFiltered());
    ArrayList<StorageDomain> result = new ArrayList<>();
    if (vmTemplate != null && vmTemplate.getStoragePoolId() != null) {
        List<Disk> templateDisks = getTemplateDisks();
        if (templateDisks.size() > 0) {
            Set<Guid> domains = new HashSet<>();
            for (Disk templateDisk : templateDisks) {
                domains.addAll(((DiskImage) templateDisk).getStorageIds());
            }
            for (Guid domainId : domains) {
                StorageDomain domain = getStorageDomain(domainId);
                if (domain != null) {
                    result.add(domain);
                }
            }
        }
    }
    getQueryReturnValue().setReturnValue(result);
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) HashSet(java.util.HashSet)

Example 29 with StorageDomain

use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.

the class AutoRecoveryManagerTest method setup.

@Before
public void setup() {
    final VDS vds = new VDS();
    vdss.add(vds);
    when(vdsDaoMock.listFailedAutorecoverables()).thenReturn(vdss);
    StorageDomain domain = new StorageDomain();
    domain.setStoragePoolId(Guid.newGuid());
    storageDomains.add(domain);
    when(storageDomainDaoMock.listFailedAutorecoverables()).thenReturn(storageDomains);
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VDS(org.ovirt.engine.core.common.businessentities.VDS) Before(org.junit.Before)

Example 30 with StorageDomain

use of org.ovirt.engine.core.common.businessentities.StorageDomain in project ovirt-engine by oVirt.

the class SyncStorageDomainsLunsCommandTest method validateStorageTypeOfStorageDomainsToSyncFails.

@Test
public void validateStorageTypeOfStorageDomainsToSyncFails() {
    StorageDomain blockDomain = new StorageDomain();
    blockDomain.setStorageType(StorageType.ISCSI);
    StorageDomain fileDomain = new StorageDomain();
    fileDomain.setStorageType(StorageType.NFS);
    doReturn(Stream.of(blockDomain, fileDomain)).when(command).getStorageDomainsToSync();
    assertFalse(command.validateStorageTypeOfStorageDomainsToSync());
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) Test(org.junit.Test)

Aggregations

StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)345 ArrayList (java.util.ArrayList)108 Guid (org.ovirt.engine.core.compat.Guid)103 Test (org.junit.Test)91 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)75 List (java.util.List)58 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)58 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)49 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)47 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)46 QueryType (org.ovirt.engine.core.common.queries.QueryType)43 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)42 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)41 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)41 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)40 VDS (org.ovirt.engine.core.common.businessentities.VDS)39 Frontend (org.ovirt.engine.ui.frontend.Frontend)39 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)36 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)36 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)35