use of org.ovirt.engine.core.common.businessentities.VmPayload in project ovirt-engine by oVirt.
the class ProcessDownVmCommand method createUpdateVmParameters.
private VmManagementParametersBase createUpdateVmParameters() {
// clear non updateable fields got from config
getVm().setExportDate(null);
getVm().setOvfVersion(null);
VmManagementParametersBase updateVmParams = new VmManagementParametersBase(getVm());
updateVmParams.setUpdateWatchdog(true);
updateVmParams.setSoundDeviceEnabled(false);
updateVmParams.setBalloonEnabled(false);
updateVmParams.setVirtioScsiEnabled(false);
updateVmParams.setClearPayload(true);
updateVmParams.setUpdateRngDevice(true);
for (GraphicsType graphicsType : GraphicsType.values()) {
updateVmParams.getGraphicsDevices().put(graphicsType, null);
}
for (VmDevice device : getVm().getManagedVmDeviceMap().values()) {
switch(device.getType()) {
case WATCHDOG:
updateVmParams.setWatchdog(new VmWatchdog(device));
break;
case SOUND:
updateVmParams.setSoundDeviceEnabled(true);
break;
case BALLOON:
updateVmParams.setBalloonEnabled(true);
break;
case CONTROLLER:
if (VmDeviceType.VIRTIOSCSI.getName().equals(device.getDevice())) {
updateVmParams.setVirtioScsiEnabled(true);
}
break;
case DISK:
if (VmPayload.isPayload(device.getSpecParams())) {
updateVmParams.setVmPayload(new VmPayload(device));
}
break;
case CONSOLE:
updateVmParams.setConsoleEnabled(true);
break;
case RNG:
updateVmParams.setRngDevice(new VmRngDevice(device));
break;
case GRAPHICS:
updateVmParams.getGraphicsDevices().put(GraphicsType.fromString(device.getDevice()), new GraphicsDevice(device));
break;
default:
}
}
// clear these fields as these are non updatable
getVm().getManagedVmDeviceMap().clear();
getVm().getUnmanagedDeviceList().clear();
return updateVmParams;
}
use of org.ovirt.engine.core.common.businessentities.VmPayload in project ovirt-engine by oVirt.
the class VmMapper method map.
@Mapping(from = VmPayload.class, to = Payload.class)
public static Payload map(VmPayload entity, Payload template) {
if (entity.getDeviceType() != null || entity.getFiles().isEmpty()) {
Payload model = template != null ? template : new Payload();
if (entity.getDeviceType() != null) {
org.ovirt.engine.api.model.VmDeviceType deviceType = map(entity.getDeviceType(), null);
if (deviceType != null) {
model.setType(deviceType);
}
}
model.setVolumeId(entity.getVolumeId());
if (entity.getFiles().size() > 0) {
model.setFiles(new Files());
for (Map.Entry<String, String> entry : entity.getFiles().entrySet()) {
File file = new File();
file.setName(entry.getKey());
file.setContent(entry.getValue());
model.getFiles().getFiles().add(file);
}
}
return model;
}
return null;
}
use of org.ovirt.engine.core.common.businessentities.VmPayload in project ovirt-engine by oVirt.
the class BackendVmResourceTest method getPayloadModel.
private VmPayload getPayloadModel() {
VmPayload payload = new VmPayload();
payload.setDeviceType(VmDeviceType.CDROM);
payload.getFiles().put("payloadFile", new String(Base64.decodeBase64(PAYLOAD_COMTENT)));
return payload;
}
use of org.ovirt.engine.core.common.businessentities.VmPayload in project ovirt-engine by oVirt.
the class GetVmPayloadQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
if (multiLevelAdministrationHandler.isAdminUser(getUser())) {
List<VmDevice> disks = dao.getVmDeviceByVmIdAndType(getParameters().getId(), VmDeviceGeneralType.DISK);
for (VmDevice disk : disks) {
if (disk.isManaged() && VmPayload.isPayload(disk.getSpecParams())) {
VmPayload payload = new VmPayload(disk);
for (Map.Entry<String, String> entry : payload.getFiles().entrySet()) {
entry.setValue(new String(Base64.decodeBase64(entry.getValue())));
}
getQueryReturnValue().setReturnValue(payload);
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.VmPayload in project ovirt-engine by oVirt.
the class VmInfoBuildUtils method createSysprepPayloadDevice.
public VmDevice createSysprepPayloadDevice(String sysPrepContent, VM vm) {
// We do not validate the size of the content being passed to the VM payload by VmPayload.isPayloadSizeLegal().
// The sysprep file size isn't being verified for 3.0 clusters and below, so we maintain the same behavior here.
VmPayload vmPayload = new VmPayload();
vmPayload.setDeviceType(VmDeviceType.FLOPPY);
vmPayload.getFiles().put(osRepository.getSysprepFileName(vm.getOs(), vm.getCompatibilityVersion()), new String(BASE_64.encode(sysPrepContent.getBytes()), StandardCharsets.UTF_8));
return new VmDevice(new VmDeviceId(Guid.newGuid(), vm.getId()), VmDeviceGeneralType.DISK, VmDeviceType.FLOPPY.getName(), "", vmPayload.getSpecParams(), true, true, true, "", null, null, null);
}
Aggregations