use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class HostDeviceMapper method map.
@Mapping(from = org.ovirt.engine.core.common.businessentities.HostDevice.class, to = HostDevice.class)
public static HostDevice map(org.ovirt.engine.core.common.businessentities.HostDevice entity, HostDevice model) {
if (model == null) {
model = new HostDevice();
}
if (!model.isSetHost()) {
model.setHost(new Host());
}
model.getHost().setId(entity.getHostId().toString());
model.setId(HexUtils.string2hex(entity.getDeviceName()));
model.setName(entity.getDeviceName());
model.setCapability(entity.getCapability());
model.setParentDevice(getSameHostDeviceReference(entity.getHostId(), entity.getParentDeviceName()));
model.setDriver(entity.getDriver());
if (entity.getProductId() != null || entity.getProductName() != null) {
if (!model.isSetProduct()) {
model.setProduct(new Product());
}
model.getProduct().setId(entity.getProductId());
model.getProduct().setName(entity.getProductName());
}
if (entity.getVendorId() != null || entity.getVendorName() != null) {
if (!model.isSetVendor()) {
model.setVendor(new Vendor());
}
model.getVendor().setId(entity.getVendorId());
model.getVendor().setName(entity.getVendorName());
}
model.setIommuGroup(entity.getIommuGroup());
if (entity.getParentPhysicalFunction() != null) {
model.setPhysicalFunction(getSameHostDeviceReference(entity.getHostId(), entity.getParentPhysicalFunction()));
}
model.setVirtualFunctions(entity.getTotalVirtualFunctions());
if (entity.getVmId() != null) {
model.setVm(new Vm());
model.getVm().setId(entity.getVmId().toString());
}
return model;
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendStorageDomainVmResource method setVolumesTypeFormat.
private void setVolumesTypeFormat(Action action) {
if (action.isSetVm()) {
Vm modelVm = action.getVm();
if (!modelVm.isSetDiskAttachments()) {
return;
}
Map<Guid, org.ovirt.engine.core.common.businessentities.storage.Disk> entityDisks = getDiskMap();
for (DiskAttachment modelDiskAttachment : modelVm.getDiskAttachments().getDiskAttachments()) {
Disk modelDisk = modelDiskAttachment.getDisk();
if (modelDisk != null) {
validateParameters(modelDisk, "id");
Guid modelDiskId = Guid.createGuidFromString(modelDisk.getId());
DiskImage entityDisk = (DiskImage) entityDisks.get(modelDiskId);
if (entityDisk == null) {
continue;
}
if (modelDisk.isSetFormat()) {
VolumeFormat entityDiskFormat = DiskMapper.map(modelDisk.getFormat(), null);
entityDisk.setVolumeFormat(entityDiskFormat);
}
if (modelDisk.isSetSparse()) {
entityDisk.setVolumeType(modelDisk.isSparse() ? VolumeType.Sparse : VolumeType.Preallocated);
}
}
}
}
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendStorageDomainVmsResource method list.
@Override
public Vms list() {
Vms vms = new Vms();
boolean unregistered = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, UNREGISTERED_CONSTRAINT_PARAMETER, true, false);
if (unregistered) {
List<org.ovirt.engine.core.common.businessentities.VM> unregisteredVms = getBackendCollection(QueryType.GetUnregisteredVms, new IdQueryParameters(storageDomainId));
List<Vm> collection = new ArrayList<>();
for (org.ovirt.engine.core.common.businessentities.VM entity : unregisteredVms) {
Vm vm = map(entity);
collection.add(addLinks(populate(vm, entity)));
}
vms.getVms().addAll(collection);
} else {
vms.getVms().addAll(getCollection());
}
return vms;
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendSnapshotsResource method addVmConfiguration.
protected Snapshot addVmConfiguration(org.ovirt.engine.core.common.businessentities.Snapshot entity, Snapshot snapshot) {
if (entity.isVmConfigurationAvailable()) {
snapshot.setVm(new Vm());
getMapper(org.ovirt.engine.core.common.businessentities.VM.class, Vm.class).map(getVmPreview(snapshot), snapshot.getVm());
} else {
snapshot.setVm(null);
snapshot.getLinks().clear();
}
return snapshot;
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendSnapshotsResource method addParents.
@Override
protected Snapshot addParents(Snapshot snapshot) {
snapshot.setVm(new Vm());
snapshot.getVm().setId(parentId.toString());
return snapshot;
}
Aggregations