Search in sources :

Example 61 with StorageDomain

use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.

the class AbstractBackendStorageDomainDiskResource method get.

public Disk get() {
    Disk disk;
    boolean unregistered = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, UNREGISTERED, true, false);
    if (unregistered) {
        QueryReturnValue result = runQuery(QueryType.GetDiskByDiskId, new IdQueryParameters(guid));
        if (!result.getSucceeded() || result.getReturnValue() == null) {
            Guid dataCenterId = BackendDataCenterHelper.lookupByStorageDomainId(this, storageDomainId);
            disk = performGet(QueryType.GetUnregisteredDisk, new GetUnregisteredDiskQueryParameters(guid, storageDomainId, dataCenterId));
        } else {
            // since the unregistered parameter was passed.
            return notFound();
        }
    } else {
        disk = getDelegate().get();
    }
    if (disk.isSetStorageDomains() && !disk.getStorageDomains().getStorageDomains().isEmpty()) {
        for (StorageDomain sd : disk.getStorageDomains().getStorageDomains()) {
            if (sd.isSetId() && sd.getId().equals(storageDomainId.toString())) {
                return disk;
            }
        }
    }
    return notFound();
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StorageDomain(org.ovirt.engine.api.model.StorageDomain) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) GetUnregisteredDiskQueryParameters(org.ovirt.engine.core.common.queries.GetUnregisteredDiskQueryParameters) Disk(org.ovirt.engine.api.model.Disk)

Example 62 with StorageDomain

use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.

the class AbstractBackendStorageDomainDisksResource method addParents.

@Override
protected Disk addParents(Disk disk) {
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setId(storageDomainId.toString());
    StorageDomains storageDomains = new StorageDomains();
    storageDomains.getStorageDomains().add(storageDomain);
    disk.setStorageDomain(storageDomain);
    disk.setStorageDomains(storageDomains);
    return disk;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) StorageDomains(org.ovirt.engine.api.model.StorageDomains)

Example 63 with StorageDomain

use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.

the class PermissionMapper method setObjectId.

/**
 * Completeness of "{entityType}.id" already validated
 */
private static void setObjectId(Permission model, org.ovirt.engine.core.common.businessentities.Permission entity) {
    String id = entity.getObjectId().toString();
    switch(entity.getObjectType()) {
        case System:
            break;
        case StoragePool:
            model.setDataCenter(new DataCenter());
            model.getDataCenter().setId(id);
            break;
        case Cluster:
            model.setCluster(new Cluster());
            model.getCluster().setId(id);
            break;
        case VDS:
            model.setHost(new Host());
            model.getHost().setId(id);
            break;
        case Storage:
            model.setStorageDomain(new StorageDomain());
            model.getStorageDomain().setId(id);
            break;
        case VM:
            model.setVm(new Vm());
            model.getVm().setId(id);
            break;
        case VmPool:
            model.setVmPool(new VmPool());
            model.getVmPool().setId(id);
            break;
        case VmTemplate:
            model.setTemplate(new Template());
            model.getTemplate().setId(id);
            break;
        case Disk:
            model.setDisk(new Disk());
            model.getDisk().setId(id);
            break;
        default:
            assert false;
    }
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) DataCenter(org.ovirt.engine.api.model.DataCenter) VmPool(org.ovirt.engine.api.model.VmPool) Vm(org.ovirt.engine.api.model.Vm) Cluster(org.ovirt.engine.api.model.Cluster) Host(org.ovirt.engine.api.model.Host) Disk(org.ovirt.engine.api.model.Disk) Template(org.ovirt.engine.api.model.Template)

Example 64 with StorageDomain

use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.

the class StorageDomainMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.StorageDomain.class, to = StorageDomain.class)
public static StorageDomain map(org.ovirt.engine.core.common.businessentities.StorageDomain entity, StorageDomain template) {
    StorageDomain model = template != null ? template : new StorageDomain();
    model.setId(entity.getId().toString());
    model.setName(entity.getStorageName());
    model.setDescription(entity.getDescription());
    model.setComment(entity.getComment());
    model.setType(map(entity.getStorageDomainType(), null));
    model.setWarningLowSpaceIndicator(entity.getWarningLowSpaceIndicator());
    model.setCriticalSpaceActionBlocker(entity.getCriticalSpaceActionBlocker());
    model.setMaster(entity.getStorageDomainType() == org.ovirt.engine.core.common.businessentities.StorageDomainType.Master);
    if (entity.getStatus() != null) {
        model.setStatus(mapStorageDomainStatus(entity.getStatus()));
    }
    if (entity.getExternalStatus() != null) {
        model.setExternalStatus(ExternalStatusMapper.map(entity.getExternalStatus()));
    }
    model.setStorage(new HostStorage());
    model.getStorage().setType(map(entity.getStorageType(), null));
    if (entity.getStorageType() == org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI || entity.getStorageType() == org.ovirt.engine.core.common.businessentities.storage.StorageType.FCP) {
        model.getStorage().setVolumeGroup(new VolumeGroup());
        model.getStorage().getVolumeGroup().setId(entity.getStorage());
    }
    if (entity.getAvailableDiskSize() != null) {
        model.setAvailable(SizeConverter.convert(entity.getAvailableDiskSize().longValue(), SizeConverter.SizeUnit.GiB, SizeConverter.SizeUnit.BYTES).longValue());
    }
    if (entity.getUsedDiskSize() != null) {
        model.setUsed(SizeConverter.convert(entity.getUsedDiskSize().longValue(), SizeConverter.SizeUnit.GiB, SizeConverter.SizeUnit.BYTES).longValue());
    }
    model.setCommitted(SizeConverter.convert(entity.getCommittedDiskSize(), SizeConverter.SizeUnit.GiB, SizeConverter.SizeUnit.BYTES).longValue());
    if (entity.getStorageFormat() != null) {
        model.setStorageFormat(StorageFormatMapper.map(entity.getStorageFormat(), null));
    }
    model.setWipeAfterDelete(entity.getWipeAfterDelete());
    model.setDiscardAfterDelete(entity.getDiscardAfterDelete());
    model.setSupportsDiscard(entity.getSupportsDiscard());
    // Not supported by sysfs since kernel version 4.12, and thus deprecated.
    model.setSupportsDiscardZeroesData(false);
    model.setBackup(entity.isBackup());
    return model;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) VolumeGroup(org.ovirt.engine.api.model.VolumeGroup) HostStorage(org.ovirt.engine.api.model.HostStorage)

Example 65 with StorageDomain

use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.

the class BackendStorageDomainVmResourceTest method testImportWithClusterName.

@Test
public void testImportWithClusterName() throws Exception {
    setUpEntityQueryExpectations(QueryType.GetClusterByName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { NAMES[1] }, getCluster(1));
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setId(GUIDS[2].toString());
    org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster();
    cluster.setName(NAMES[1]);
    setUpGetDataCenterByStorageDomainExpectations(STORAGE_DOMAIN_ID);
    doTestImport(storageDomain, cluster, false, false);
}
Also used : BackendStorageDomainVmsResourceTest.setUpStorageDomain(org.ovirt.engine.api.restapi.resource.BackendStorageDomainVmsResourceTest.setUpStorageDomain) StorageDomain(org.ovirt.engine.api.model.StorageDomain) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Test(org.junit.Test)

Aggregations

StorageDomain (org.ovirt.engine.api.model.StorageDomain)88 Test (org.junit.Test)41 WebApplicationException (javax.ws.rs.WebApplicationException)14 Action (org.ovirt.engine.api.model.Action)14 Response (javax.ws.rs.core.Response)13 Host (org.ovirt.engine.api.model.Host)13 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)13 Disk (org.ovirt.engine.api.model.Disk)9 StorageDomains (org.ovirt.engine.api.model.StorageDomains)9 BackendStorageDomainVmsResourceTest.setUpStorageDomain (org.ovirt.engine.api.restapi.resource.BackendStorageDomainVmsResourceTest.setUpStorageDomain)8 HostStorage (org.ovirt.engine.api.model.HostStorage)6 BackendStorageDomainTemplatesResourceTest.setUpStorageDomain (org.ovirt.engine.api.restapi.resource.BackendStorageDomainTemplatesResourceTest.setUpStorageDomain)6 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)6 DataCenter (org.ovirt.engine.api.model.DataCenter)5 Vm (org.ovirt.engine.api.model.Vm)5 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)5 Guid (org.ovirt.engine.core.compat.Guid)5 DiskProfile (org.ovirt.engine.api.model.DiskProfile)4 ExportRepoImageParameters (org.ovirt.engine.core.common.action.ExportRepoImageParameters)4 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)4