Search in sources :

Example 81 with StorageDomainStatic

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

the class UpdateStoragePoolCommand method updateMemberDomainsFormat.

private void updateMemberDomainsFormat(StorageFormatType targetFormat) {
    Guid spId = getStoragePool().getId();
    List<StorageDomainStatic> domains = storageDomainStaticDao.getAllForStoragePool(spId);
    for (StorageDomainStatic domain : domains) {
        StorageDomainType sdType = domain.getStorageDomainType();
        if (sdType == StorageDomainType.Data || sdType == StorageDomainType.Master) {
            log.info("Setting storage domain '{}' (type '{}') to format '{}'", domain.getId(), sdType, targetFormat);
            domain.setStorageFormat(targetFormat);
            storageDomainStaticDao.update(domain);
        }
    }
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Guid(org.ovirt.engine.core.compat.Guid)

Example 82 with StorageDomainStatic

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

the class AddStoragePoolWithStoragesCommand method isStorageDomainAttachedToStoragePool.

private boolean isStorageDomainAttachedToStoragePool(StorageDomain storageDomain) {
    try {
        VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.HSMGetStorageDomainInfo, new HSMGetStorageDomainInfoVDSCommandParameters(getVdsId(), storageDomain.getId()));
        if (!vdsReturnValue.getSucceeded()) {
            logErrorMessage(storageDomain);
        }
        Pair<StorageDomainStatic, Guid> domainFromIrs = (Pair<StorageDomainStatic, Guid>) vdsReturnValue.getReturnValue();
        if (domainFromIrs.getSecond() != null) {
            return true;
        }
    } catch (RuntimeException e) {
        logErrorMessage(storageDomain);
    }
    return false;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) HSMGetStorageDomainInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.HSMGetStorageDomainInfoVDSCommandParameters) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 83 with StorageDomainStatic

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

the class StorageDomainStaticDaoTest method testGetByNameWithInvalidName.

/**
 * Ensures that null is returned when the name is invalid.
 */
@Test
public void testGetByNameWithInvalidName() {
    StorageDomainStatic result = dao.getByName("farkle");
    assertNull(result);
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) Test(org.junit.Test)

Example 84 with StorageDomainStatic

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

the class GetGeoRepSessionsForStorageDomainQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    StorageDomainStatic domain = storageDomainDao.get(getParameters().getId());
    StorageServerConnections connection = storageServerConnectionDao.get(domain.getStorage());
    getQueryReturnValue().setReturnValue(new ArrayList<GlusterGeoRepSession>());
    if (connection.getStorageType() != StorageType.GLUSTERFS) {
        // return empty
        getQueryReturnValue().setSucceeded(false);
        return;
    }
    Guid glusterVolumeId = connection.getGlusterVolumeId();
    if (glusterVolumeId == null) {
        // retrieve the gluster volume associated with path
        String path = connection.getConnection();
        String[] pathElements = path.split(StorageConstants.GLUSTER_VOL_SEPARATOR);
        String volumeName = pathElements[1];
        String hostName = pathElements[0];
        List<VDS> vdsList = vdsDao.getAll();
        VDS vds = vdsList.stream().filter(v -> v.getName().equals(hostName) || interfaceDao.getAllInterfacesForVds(v.getId()).stream().anyMatch(iface -> iface.getIpv4Address().equals(hostName))).findFirst().orElse(null);
        if (vds == null) {
            // return empty
            getQueryReturnValue().setSucceeded(false);
            return;
        }
        GlusterVolumeEntity vol = glusterVolumeDao.getByName(vds.getClusterId(), volumeName);
        if (vol == null) {
            getQueryReturnValue().setSucceeded(false);
            return;
        }
        glusterVolumeId = vol.getId();
    }
    getQueryReturnValue().setReturnValue(glusterGeoRepDao.getGeoRepSessions(glusterVolumeId));
    getQueryReturnValue().setSucceeded(true);
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) Guid(org.ovirt.engine.core.compat.Guid)

Example 85 with StorageDomainStatic

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

the class ImportVmTemplateCommandTest method mockStorageDomainStatic.

private void mockStorageDomainStatic(StorageType storageType) {
    final StorageDomainStatic domain = new StorageDomainStatic();
    domain.setStorageType(storageType);
    when(storageDomainStaticDao.get(any())).thenReturn(domain);
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic)

Aggregations

StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)92 Guid (org.ovirt.engine.core.compat.Guid)39 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)35 ArrayList (java.util.ArrayList)33 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)31 Test (org.junit.Test)23 Pair (org.ovirt.engine.core.common.utils.Pair)19 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)18 StorageDomainType (org.ovirt.engine.core.common.businessentities.StorageDomainType)15 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)15 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)14 List (java.util.List)13 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)13 StorageDomainManagementParameter (org.ovirt.engine.core.common.action.StorageDomainManagementParameter)13 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)13 VDS (org.ovirt.engine.core.common.businessentities.VDS)12 HashSet (java.util.HashSet)11 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)11 ActionType (org.ovirt.engine.core.common.action.ActionType)11 AttachStorageDomainToPoolParameters (org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters)10