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