Shahar Havivi has uploaded a new change for review. Change subject: core: Payload is not attach via run once. ......................................................................
core: Payload is not attach via run once. Bug-Url: https://bugzilla.redhat.com/1082979 Change-Id: I096d5a8c9e4ed3dfeddb95cd3e48e1c4ef63b819 Signed-off-by: Shahar Havivi <shah...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java 2 files changed, 27 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/99/27499/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java index 87ebd2c..984e409 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java @@ -17,9 +17,14 @@ import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.VmBase; +import org.ovirt.engine.core.common.businessentities.VmDevice; +import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType; +import org.ovirt.engine.core.common.businessentities.VmPayload; import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.common.utils.VmDeviceType; import org.ovirt.engine.core.common.vdscommands.CreateVmVDSCommandParameters; import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.dao.VmDeviceDAO; import org.ovirt.engine.core.utils.OsRepositoryImpl; @LockIdNameAttribute @@ -27,6 +32,11 @@ public class RunVmOnceCommand<T extends RunVmOnceParams> extends RunVmCommand<T> implements QuotaStorageDependent { public RunVmOnceCommand(T runVmParams) { super(runVmParams); + + // Load payload if user didn't send via run-once + if (getParameters().getVmPayload() == null) { + loadPayload(); + } } @Override @@ -58,6 +68,21 @@ return true; } + private void loadPayload() { + VmDeviceDAO dao = getDbFacade().getVmDeviceDao(); + List<VmDevice> disks = dao.getVmDeviceByVmIdAndType(getParameters().getVmId(), VmDeviceGeneralType.DISK); + + for (VmDevice disk : disks) { + if (VmPayload.isPayload(disk.getSpecParams())) { + VmPayload payload = new VmPayload(VmDeviceType.valueOf(disk.getType().name()), + disk.getSpecParams()); + payload.setType(VmDeviceType.valueOf(disk.getDevice().toUpperCase())); + getVm().setVmPayload(payload); + break; + } + } + } + /** * Refresh the associated values of the VM boot parameters with the values from the command parameters. The method * is used when VM is reloaded from the DB while its parameters hasn't been persisted (e.g. when running 'as once') diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java index affae71..a5b500a 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java @@ -133,7 +133,7 @@ VmDeviceType.CDROM.getName(), "", 0, - (vm.getVmPayload() == null) ? null : vm.getVmPayload().getSpecParams(), + vm.getVmPayload().getSpecParams(), true, true, true, @@ -152,7 +152,7 @@ VmDeviceType.CDROM.getName(), "", 0, - (vm.getVmPayload() == null) ? null : vm.getVmPayload().getSpecParams(), + null, true, true, true, -- To view, visit http://gerrit.ovirt.org/27499 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I096d5a8c9e4ed3dfeddb95cd3e48e1c4ef63b819 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.4 Gerrit-Owner: Shahar Havivi <shav...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches