Search in sources :

Example 71 with StorageDomainStatic

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

the class VmInfoBuildUtils method getGlusterVolInfo.

/**
 * Finds Storage Domain by disk and extracts gluster host and volume info.
 * @param disk Disk located on Gluster's SD
 * @return volume info array. First element is a brick's hostname, second element - volume name.
 */
public String[] getGlusterVolInfo(Disk disk) {
    StorageDomainStatic dom = this.storageDomainStaticDao.get(((DiskImage) disk).getStorageIds().get(0));
    StorageServerConnections con = this.storageServerConnectionDao.getAllForDomain(dom.getId()).get(0);
    // host:/volume
    String path = con.getConnection();
    String[] volInfo = path.split(":");
    if (volInfo.length != 2) {
        log.error("Invalid volInfo value: {}", path);
        return null;
    }
    volInfo[1] = volInfo[1].replaceFirst("^/", "");
    return volInfo;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 72 with StorageDomainStatic

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

the class GetStorageDomainsWithAttachedStoragePoolGuidQuery method filterAttachedStorageDomains.

protected List<StorageDomainStatic> filterAttachedStorageDomains() {
    List<StorageDomain> connectedStorageDomainsToVds = new ArrayList<>();
    for (StorageDomain storageDomain : getParameters().getStorageDomainList()) {
        if (!connectStorageDomain(storageDomain)) {
            logErrorMessage(storageDomain);
        } else {
            connectedStorageDomainsToVds.add(storageDomain);
        }
    }
    // Some domains may have Hosted Engine VM running while importing them.
    // We want to avoid disconnecting before the import in that case, otherwise they'll crash
    List<Guid> heStorageDomainIds = storageDomainDao.getHostedEngineStorageDomainIds();
    List<StorageDomainStatic> storageDomainsWithAttachedStoragePoolId = getAttachedStorageDomains(connectedStorageDomainsToVds);
    for (StorageDomain storageDomain : connectedStorageDomainsToVds) {
        if (heStorageDomainIds.contains(storageDomain.getId())) {
            log.info("Skipping disconnect Storage Domain {} from VDS '{}' because Hosted Engine VM is running on it.", storageDomain.getName(), getVdsId());
            continue;
        }
        if (!disconnectStorageDomain(storageDomain)) {
            log.warn("Could not disconnect Storage Domain {} from VDS '{}'. ", storageDomain.getName(), getVdsId());
        }
    }
    return storageDomainsWithAttachedStoragePoolId;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 73 with StorageDomainStatic

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

the class GetStorageDomainsWithAttachedStoragePoolGuidQuery method getAttachedStorageDomains.

protected List<StorageDomainStatic> getAttachedStorageDomains(List<StorageDomain> storageDomains) {
    VDSReturnValue vdsReturnValue = null;
    List<StorageDomainStatic> storageDomainsWithAttachedStoragePoolId = new ArrayList<>();
    // another Storage Pool
    for (StorageDomain storageDomain : storageDomains) {
        try {
            vdsReturnValue = runVdsCommand(VDSCommandType.HSMGetStorageDomainInfo, new HSMGetStorageDomainInfoVDSCommandParameters(getVdsId(), storageDomain.getId()));
        } catch (RuntimeException e) {
            logErrorMessage(storageDomain);
            continue;
        }
        if (!vdsReturnValue.getSucceeded()) {
            logErrorMessage(storageDomain);
            continue;
        }
        Pair<StorageDomainStatic, Guid> domainFromIrs = (Pair<StorageDomainStatic, Guid>) vdsReturnValue.getReturnValue();
        if (domainFromIrs.getSecond() != null) {
            storageDomainsWithAttachedStoragePoolId.add(domainFromIrs.getFirst());
        }
    }
    return storageDomainsWithAttachedStoragePoolId;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) 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) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 74 with StorageDomainStatic

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

the class AddExistingFileStorageDomainCommand method concreteCheckExistingStorageDomain.

protected boolean concreteCheckExistingStorageDomain(Pair<StorageDomainStatic, Guid> domain) {
    boolean returnValue = false;
    StorageDomainStatic domainFromIrs = domain.getFirst();
    if (StringUtils.isEmpty(getStorageDomain().getStorageStaticData().getStorage()) && StringUtils.isEmpty(domainFromIrs.getStorage()) && domainFromIrs.getConnection() != null && getStorageDomain().getStorageStaticData().getConnection() != null) {
        returnValue = StringUtils.equals(domainFromIrs.getConnection().getConnection(), getStorageDomain().getStorageStaticData().getConnection().getConnection());
    } else if (!StringUtils.isEmpty(getStorageDomain().getStorageStaticData().getStorage()) && !StringUtils.isEmpty(domainFromIrs.getStorage())) {
        returnValue = StringUtils.equals(domainFromIrs.getStorage(), getStorageDomain().getStorageStaticData().getStorage());
    }
    if (!returnValue) {
        addValidationMessage(EngineMessage.ERROR_CANNOT_ADD_EXISTING_STORAGE_DOMAIN_CONNECTION_DATA_ILLEGAL);
    }
    return returnValue;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic)

Example 75 with StorageDomainStatic

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

the class AddStorageDomainCommand method addStorageDomainInDb.

protected void addStorageDomainInDb() {
    TransactionSupport.executeInNewTransaction(() -> {
        StorageDomainStatic storageStaticData = getStorageDomain().getStorageStaticData();
        storageDomainStaticDao.save(storageStaticData);
        getCompensationContext().snapshotNewEntity(storageStaticData);
        StorageDomainDynamic newStorageDynamic = new StorageDomainDynamic(null, getStorageDomain().getId(), null);
        getReturnValue().setActionReturnValue(getStorageDomain().getId());
        storageDomainDynamicDao.save(newStorageDynamic);
        getCompensationContext().snapshotNewEntity(newStorageDynamic);
        getCompensationContext().stateChanged();
        return null;
    });
    if (getStorageDomain().getStorageDomainType().isDataDomain()) {
        createDefaultDiskProfile();
    }
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomainDynamic(org.ovirt.engine.core.common.businessentities.StorageDomainDynamic)

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