Search in sources :

Example 51 with StorageDomain

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

the class DiskProfileMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.profiles.DiskProfile.class, to = DiskProfile.class)
public static DiskProfile map(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile entity, DiskProfile template) {
    DiskProfile model = template != null ? template : new DiskProfile();
    if (entity.getId() != null) {
        model.setId(entity.getId().toString());
    }
    if (entity.getName() != null) {
        model.setName(entity.getName());
    }
    if (entity.getDescription() != null) {
        model.setDescription(entity.getDescription());
    }
    if (entity.getStorageDomainId() != null) {
        model.setStorageDomain(new StorageDomain());
        model.getStorageDomain().setId(entity.getStorageDomainId().toString());
    }
    if (entity.getQosId() != null) {
        model.setQos(new Qos());
        model.getQos().setId(entity.getQosId().toString());
    }
    return model;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) Qos(org.ovirt.engine.api.model.Qos) DiskProfile(org.ovirt.engine.api.model.DiskProfile)

Example 52 with StorageDomain

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

the class StorageDomainMapperTest method testMemory.

@Test
public void testMemory() {
    org.ovirt.engine.core.common.businessentities.StorageDomain entity = new org.ovirt.engine.core.common.businessentities.StorageDomain();
    entity.setAvailableDiskSize(3);
    entity.setUsedDiskSize(4);
    entity.setCommittedDiskSize(5);
    StorageDomain model = StorageDomainMapper.map(entity, null);
    assertEquals(Long.valueOf(3221225472L), model.getAvailable());
    assertEquals(Long.valueOf(4294967296L), model.getUsed());
    assertEquals(Long.valueOf(5368709120L), model.getCommitted());
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) Test(org.junit.Test)

Example 53 with StorageDomain

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

the class BackendStorageDomainsResource method mapCollection.

private StorageDomains mapCollection(List<org.ovirt.engine.core.common.businessentities.StorageDomain> entities) {
    StorageDomains collection = new StorageDomains();
    for (org.ovirt.engine.core.common.businessentities.StorageDomain entity : entities) {
        StorageDomain storageDomain = map(entity);
        // status is only relevant in the context of a data-center, so it can either be 'Unattached' or null.
        if (StorageDomainSharedStatus.Unattached.equals(entity.getStorageDomainSharedStatus())) {
            storageDomain.setStatus(StorageDomainStatus.UNATTACHED);
        } else {
            storageDomain.setStatus(null);
        }
        collection.getStorageDomains().add(addLinks(storageDomain, getLinksToExclude(storageDomain)));
    }
    return collection;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) StorageDomains(org.ovirt.engine.api.model.StorageDomains)

Example 54 with StorageDomain

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

the class BackendStorageDomainsResource method addExistingSAN.

private Response addExistingSAN(StorageDomain model, StorageType storageType, Guid hostId) {
    getEntity(VDS.class, QueryType.GetVdsByVdsId, new IdQueryParameters(hostId), "Host: id=" + hostId);
    List<LUNs> existingLuns = getDeviceList(hostId, storageType);
    List<StorageServerConnections> existingStorageServerConnections = getLunsWithInitializedStorageType(existingLuns, storageType);
    List<org.ovirt.engine.core.common.businessentities.StorageDomain> existingStorageDomains = getExistingBlockStorageDomain(hostId, storageType, existingStorageServerConnections);
    StorageDomainStatic storageDomainToImport = getMatchingStorageDomain(asGuid(model.getId()), existingStorageDomains);
    if (storageDomainToImport == null) {
        throw new WebFaultException(new WebApplicationException(), "Storage Domain id " + model.getId() + " Does not exists", Status.NOT_FOUND);
    }
    StorageDomainMapper.map(model, storageDomainToImport);
    StorageDomainManagementParameter parameters = new StorageDomainManagementParameter(storageDomainToImport);
    parameters.setVdsId(hostId);
    return performCreate(ActionType.AddExistingBlockStorageDomain, parameters, ID_RESOLVER);
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) WebApplicationException(javax.ws.rs.WebApplicationException) StorageDomainManagementParameter(org.ovirt.engine.core.common.action.StorageDomainManagementParameter) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) StorageDomain(org.ovirt.engine.api.model.StorageDomain) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters)

Example 55 with StorageDomain

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

the class BackendStorageDomainDiskSnapshotResource method get.

@Override
public DiskSnapshot get() {
    DiskSnapshot diskSnapshot = performGet(QueryType.GetDiskSnapshotByImageId, new IdQueryParameters(guid));
    // this code generates back-link to the corresponding SD
    diskSnapshot.setStorageDomain(new StorageDomain());
    diskSnapshot.getStorageDomain().setId(this.storageDomainId);
    return diskSnapshot;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DiskSnapshot(org.ovirt.engine.api.model.DiskSnapshot)

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