use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.
the class DiskMapper method mapDiskToDiskImageProperties.
private static void mapDiskToDiskImageProperties(Disk disk, DiskImage diskImage) {
if (disk.isSetImageId()) {
diskImage.setImageId(GuidUtils.asGuid(disk.getImageId()));
}
if (disk.isSetProvisionedSize()) {
diskImage.setSize(disk.getProvisionedSize());
}
if (disk.isSetFormat()) {
diskImage.setVolumeFormat(map(disk.getFormat(), null));
}
if (disk.isSetQcowVersion()) {
diskImage.setQcowCompat(mapQcowVersion(disk.getQcowVersion()));
}
if (disk.isSetStatus()) {
diskImage.setImageStatus(mapDiskStatus(disk.getStatus()));
}
if (disk.isSetSnapshot() && disk.getSnapshot().isSetId()) {
diskImage.setVmSnapshotId(GuidUtils.asGuid(disk.getSnapshot().getId()));
}
if (disk.isSetSparse()) {
diskImage.setVolumeType(disk.isSparse() ? VolumeType.Sparse : VolumeType.Preallocated);
}
// TODO: relevant when adding disk, needs to be removed when the initial size will be passed in the parameters.
if (disk.isSetInitialSize()) {
diskImage.setActualSizeInBytes(disk.getInitialSize());
}
if (disk.isSetStorageDomains() && disk.getStorageDomains().isSetStorageDomains() && disk.getStorageDomains().getStorageDomains().get(0).isSetId()) {
StorageDomain storageDomain = disk.getStorageDomains().getStorageDomains().get(0);
diskImage.setStorageIds(new ArrayList<>());
diskImage.getStorageIds().add(Guid.createGuidFromStringDefaultEmpty(storageDomain.getId()));
}
if (disk.isSetQuota() && disk.getQuota().isSetId()) {
diskImage.setQuotaId(GuidUtils.asGuid(disk.getQuota().getId()));
}
if (disk.isSetDiskProfile() && disk.getDiskProfile().isSetId()) {
diskImage.setDiskProfileId(GuidUtils.asGuid(disk.getDiskProfile().getId()));
}
if (disk.isSetOpenstackVolumeType() && disk.getOpenstackVolumeType().isSetName()) {
diskImage.setCinderVolumeType(disk.getOpenstackVolumeType().getName());
}
}
use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.
the class BackendExternalVmImportsResource method add.
@Override
public Response add(ExternalVmImport externalVmImport) {
validateParameters(externalVmImport, "provider", "url", "name", "sparse", "cluster.id|name", "storageDomain.id|name");
ImportVmFromExternalUrlParameters parameters = buildImportParameters(externalVmImport);
VM createdVm = performAction(ActionType.ImportVmFromExternalUrl, parameters, VM.class);
// Postprocess output entity to clear sensitive data and resolve links.
externalVmImport.setPassword(null);
externalVmImport.setVm(withIdLink(new Vm(), createdVm.getId()));
externalVmImport.setCluster(withIdLink(new org.ovirt.engine.api.model.Cluster(), parameters.getClusterId()));
externalVmImport.setStorageDomain(withIdLink(new StorageDomain(), parameters.getStorageDomainId()));
if (externalVmImport.isSetHost()) {
externalVmImport.setHost(withIdLink(new Host(), parameters.getProxyHostId()));
}
return Response.ok(externalVmImport).status(Response.Status.CREATED).build();
}
use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.
the class BackendAttachedStorageDomainsResourceTest method doTestBadAdd.
private void doTestBadAdd(boolean valid, boolean success, String detail) throws Exception {
setUriInfo(setUpActionExpectations(ActionType.AttachStorageDomainToPool, AttachStorageDomainToPoolParameters.class, new String[] { "StorageDomainId", "StoragePoolId" }, new Object[] { GUIDS[0], GUIDS[NAMES.length - 1] }, valid, success));
StorageDomain model = new StorageDomain();
model.setId(GUIDS[0].toString());
try {
collection.add(model);
fail("expected WebApplicationException");
} catch (WebApplicationException wae) {
verifyFault(wae, detail);
}
}
Aggregations