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;
}
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());
}
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;
}
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);
}
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;
}
Aggregations