Frank Kobzik has uploaded a new change for review. Change subject: engine: Fix clone and clone from snapshot functionality ......................................................................
engine: Fix clone and clone from snapshot functionality Clone from snapshot: - graphics setting logic was missing in VmSnapshotListModel Clone: - missing overriding of graphics devices on vm clone caused the possibility of inheriting graphics device from vm template. Fixed by overriding graphics devices in CloneVmCommand. Change-Id: I6dd6a3be2ee78cb1a4a940518bb2b7c467f6b856 Bug-Url: https://bugzilla.redhat.com/1179140 Signed-off-by: Frantisek Kobzik <fkob...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CloneVmCommand.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmSnapshotListModel.java 2 files changed, 33 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/33/36633/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CloneVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CloneVmCommand.java index 04e7624..ada5dea 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CloneVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CloneVmCommand.java @@ -17,6 +17,8 @@ import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.businessentities.Disk; import org.ovirt.engine.core.common.businessentities.DiskImage; +import org.ovirt.engine.core.common.businessentities.GraphicsDevice; +import org.ovirt.engine.core.common.businessentities.GraphicsType; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.VmDevice; @@ -220,6 +222,7 @@ getParameters().setConsoleEnabled(containsDeviceWithType(devices, VmDeviceGeneralType.CONSOLE)); getParameters().setVirtioScsiEnabled(containsDeviceWithType(devices, VmDeviceGeneralType.CONTROLLER, VmDeviceType.VIRTIOSCSI)); getParameters().setBalloonEnabled(containsDeviceWithType(devices, VmDeviceGeneralType.BALLOON)); + setGraphicsDevices(devices); VdcQueryReturnValue watchdogs = runInternalQuery(VdcQueryType.GetWatchdog, new IdQueryParameters(oldVmId)); if (!((List<VmWatchdog>) watchdogs.getReturnValue()).isEmpty()) { @@ -232,6 +235,19 @@ fillDisksToParameters(); } + private void setGraphicsDevices(List<VmDevice> devices) { + for (GraphicsType graphicsType : GraphicsType.values()) { + getParameters().getGraphicsDevices().put(graphicsType, null); // prevent copying from the template + } + + for (VmDevice device : devices) { + if (device.getType() == VmDeviceGeneralType.GRAPHICS) { + GraphicsDevice graphicsDevice = new GraphicsDevice(device); + getParameters().getGraphicsDevices().put(graphicsDevice.getGraphicsType(), graphicsDevice); + } + } + } + private boolean containsDeviceWithType(List<VmDevice> devices, VmDeviceGeneralType generalType, VmDeviceType deviceType) { for (VmDevice device : devices) { if (device.getType() == generalType) { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmSnapshotListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmSnapshotListModel.java index 94a52f3..f53c3b0 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmSnapshotListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmSnapshotListModel.java @@ -16,6 +16,8 @@ import org.ovirt.engine.core.common.action.VdcReturnValueBase; import org.ovirt.engine.core.common.businessentities.Disk; import org.ovirt.engine.core.common.businessentities.DiskImage; +import org.ovirt.engine.core.common.businessentities.GraphicsDevice; +import org.ovirt.engine.core.common.businessentities.GraphicsType; import org.ovirt.engine.core.common.businessentities.Snapshot; import org.ovirt.engine.core.common.businessentities.SnapshotActionEnum; import org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus; @@ -720,6 +722,7 @@ parameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity()); parameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity()); parameters.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity()); + setGraphicsDevicesToParams(model, parameters); model.startProgress(null); @@ -740,6 +743,20 @@ }, this); } + private void setGraphicsDevicesToParams(final UnitVmModel model, AddVmFromSnapshotParameters params) { + if (model.getDisplayType().getSelectedItem() == null || model.getGraphicsType().getSelectedItem() == null) { + return; + } + + for (GraphicsType graphicsType : GraphicsType.values()) { + params.getGraphicsDevices().put(graphicsType, null); // reset + if (model.getGraphicsType().getSelectedItem().getBackingGraphicsType().contains(graphicsType)) { + GraphicsDevice d = new GraphicsDevice(graphicsType.getCorrespondingDeviceType()); + params.getGraphicsDevices().put(d.getGraphicsType(), d); + } + } + } + protected static void buildVmOnClone(UnitVmModel model, VM vm) { BuilderExecutor.build(model, vm.getStaticData(), new FullUnitToVmBaseBuilder()); BuilderExecutor.build(model, vm, new VmSpecificUnitToVmBuilder()); -- To view, visit http://gerrit.ovirt.org/36633 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6dd6a3be2ee78cb1a4a940518bb2b7c467f6b856 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Frank Kobzik <fkob...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches