Search in sources :

Example 11 with StorageDomainStatic

use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic 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 12 with StorageDomainStatic

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

the class UpdateStoragePoolCommandTest method hasLocalDomain.

@Test
public void hasLocalDomain() {
    StorageDomainStatic sdc = new StorageDomainStatic();
    sdc.setStorageType(StorageType.LOCALFS);
    StoragePool existingSp = createStoragePool();
    existingSp.setIsLocal(true);
    when(spDao.get(any())).thenReturn(existingSp);
    when(sdDao.getAllForStoragePool(any())).thenReturn(Collections.singletonList(sdc));
    ValidateTestUtils.runAndAssertValidateFailure(cmd, EngineMessage.ERROR_CANNOT_CHANGE_STORAGE_POOL_TYPE_WITH_LOCAL);
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 13 with StorageDomainStatic

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

the class UpdateStoragePoolCommandTest method hasSharedDomain.

@Test
public void hasSharedDomain() {
    StorageDomainStatic sdc = new StorageDomainStatic();
    sdc.setStorageType(StorageType.NFS);
    when(sdDao.getAllForStoragePool(any())).thenReturn(Collections.singletonList(sdc));
    ValidateTestUtils.runAndAssertValidateSuccess(cmd);
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 14 with StorageDomainStatic

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

the class BackendOpenStackVolumeProvidersResource method getStoragePoolIdByStorageDomainName.

private StoragePool getStoragePoolIdByStorageDomainName(String storageDomainName) {
    StorageDomainStatic storageDomain = getEntity(StorageDomainStatic.class, QueryType.GetStorageDomainByName, new NameQueryParameters(storageDomainName), "StorageDomain: name=" + storageDomainName);
    List<StoragePool> storagePools = getEntity(List.class, QueryType.GetStoragePoolsByStorageDomainId, new IdQueryParameters(storageDomain.getId()), "Datacenters");
    if (!storagePools.isEmpty()) {
        return storagePools.get(0);
    }
    // The storage domain is unattached
    return null;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) NameQueryParameters(org.ovirt.engine.core.common.queries.NameQueryParameters)

Example 15 with StorageDomainStatic

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

the class AddStorageDomainRM method prepare5.

private void prepare5() {
    PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow();
    ActionReturnValue returnValue = context.addStorageServerConnectionReturnValue;
    if (returnValue == null || !returnValue.getSucceeded()) {
        // Don't rollback.
        context.enlistment = null;
        enlistment.done();
    } else {
        StorageDomainStatic storage = new StorageDomainStatic();
        storage.setStorageType(StorageType.LOCALFS);
        storage.setStorageDomainType(StorageDomainType.Data);
        storage.setStorageName(configureModel.getFormattedStorageName().getEntity());
        storage.setStorage((String) returnValue.getActionReturnValue());
        StorageDomainManagementParameter parameters = new StorageDomainManagementParameter(storage);
        parameters.setVdsId(context.host.getId());
        parameters.setCorrelationId(getCorrelationId());
        Frontend.getInstance().runAction(ActionType.AddLocalStorageDomain, parameters, result -> {
            ActionReturnValue returnValue1 = result.getReturnValue();
            context.addLocalStorageDomainReturnValue = returnValue1;
            prepare6();
        });
    }
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StorageDomainManagementParameter(org.ovirt.engine.core.common.action.StorageDomainManagementParameter)

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