Tomas Jelinek has uploaded a new change for review.

Change subject: engine: Run Once dialog ingores emtpy boot options (#857848)
......................................................................

engine: Run Once dialog ingores emtpy boot options (#857848)

https://bugzilla.redhat.com/857848

When you set the linux boot options in Edit dialog,
than in Run Once dialog remove this options, the run once will
use the boot options set up in the Edit dialog.

The problem was in RunVmCommand.refreshBootParameters method
which expected, that when the parameter is empty, it is run VM,
when it is not empty, it is run once VM, which is not true in
this case.

Fixed by moving the run once specific code to the RunVmOnceCommand.

Change-Id: I32e59783d9c4d8e8b61ec96c6bae5577fc59756c
Signed-off-by: Tomas Jelinek <tjeli...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java
2 files changed, 40 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/83/8083/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
index 8764fc4..b034de4 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
@@ -67,7 +67,6 @@
 import org.ovirt.engine.core.utils.log.LogFactory;
 import org.ovirt.engine.core.utils.vmproperties.VmPropertiesUtils;
 
-
 @LockIdNameAttribute
 @NonTransactiveCommandAttribute
 public class RunVmCommand<T extends RunVmParams> extends RunVmCommandBase<T>
@@ -128,38 +127,20 @@
     }
 
     /**
-     * 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')
-     * @param runVmParameters
+     * Set up the basic boot parameters. If needed to set up some of them 
according to the RunVmParams, override this
+     * method.
      */
-    private void refreshBootParameters(RunVmParams runVmParameters) {
-        // if not run once then use default boot sequence
+    protected void refreshBootParameters(RunVmParams runVmParameters) {
         refreshBootSequenceParameter(runVmParameters);
-
-        if (!StringUtils.isEmpty(runVmParameters.getinitrd_url())) {
-            getVm().setinitrd_url(runVmParameters.getinitrd_url());
-        }
-
-        if (!StringUtils.isEmpty(runVmParameters.getkernel_url())) {
-            getVm().setkernel_url(runVmParameters.getkernel_url());
-        }
-
-        if (!StringUtils.isEmpty(runVmParameters.getkernel_params())) {
-            getVm().setkernel_params(runVmParameters.getkernel_params());
-        }
-
-        if (!StringUtils.isEmpty(runVmParameters.getCustomProperties())) {
-            getVm().setCustomProperties(runVmParameters.getCustomProperties());
-        }
 
         getVm().setLastStartTime(new Date());
     }
 
-    private void refreshBootSequenceParameter(RunVmParams runVmParameters) {
-        if (runVmParameters != null) {
-            getVm().setboot_sequence(((runVmParameters.getBootSequence()) != 
null) ? runVmParameters.getBootSequence()
-                    : getVm().getdefault_boot_sequence());
-        }
+    /**
+     * By default use default boot sequence. This method can be overridden to 
it up according to the RunVmParams.
+     */
+    protected void refreshBootSequenceParameter(RunVmParams runVmParameters) {
+        getVm().setboot_sequence(getVm().getdefault_boot_sequence());
     }
 
     /**
@@ -167,7 +148,6 @@
      * path of the domain on the Iso Domain server<BR/>
      * otherwise, returns the original name.<BR/>
      * Note: The prefix is not case sensitive.
-     *
      * @param url
      *            - String of the file url. ("iso://initrd.ini" or 
"/init/initrd.ini".
      * @return String of the full file path.
@@ -300,7 +280,8 @@
                 getVm().setCdPath(getVm().getiso_path());
                 GuestToolsVersionTreatment();
                 refreshBootSequenceParameter(getParameters());
-                if (getVm().getboot_sequence() != null && 
getVm().getboot_sequence().containsSubsequence(BootSequence.D)) {
+                if (getVm().getboot_sequence() != null
+                        && 
getVm().getboot_sequence().containsSubsequence(BootSequence.D)) {
                     getVm().setCdPath(getVm().getiso_path());
                 }
                 
getVm().setCdPath(ImagesHandler.cdPathWindowsToLinux(getVm().getCdPath(), 
getVm().getstorage_pool_id()));
@@ -556,8 +537,8 @@
     }
 
     /**
-     * If vds version greater then vm's and vm not running with cd and there 
is appropriate RhevAgentTools image -
-     * add it to vm as cd.
+     * If vds version greater then vm's and vm not running with cd and there 
is appropriate RhevAgentTools image - add
+     * it to vm as cd.
      */
     private void GuestToolsVersionTreatment() {
         boolean attachCd = false;
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 3e63b8e..797b54d 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
@@ -8,6 +8,7 @@
 import org.ovirt.engine.core.bll.quota.QuotaManager;
 import org.ovirt.engine.core.bll.quota.StorageQuotaValidationParameter;
 import org.ovirt.engine.core.common.action.RunVmOnceParams;
+import org.ovirt.engine.core.common.action.RunVmParams;
 import org.ovirt.engine.core.common.action.SysPrepParams;
 import org.ovirt.engine.core.common.businessentities.DiskImage;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
@@ -15,6 +16,9 @@
 import org.ovirt.engine.core.dal.VdcBllMessages;
 
 public class RunVmOnceCommand<T extends RunVmOnceParams> extends 
RunVmCommand<T> {
+
+    private static final long serialVersionUID = 733173884556573136L;
+
     public RunVmOnceCommand(T runVmParams) {
         super(runVmParams);
     }
@@ -56,6 +60,29 @@
         ExecutionHandler.endJob(executionContext, success);
     }
 
+    /**
+     * 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')
+     */
+    @Override
+    protected void refreshBootParameters(RunVmParams runVmParameters) {
+        super.refreshBootParameters(runVmParameters);
+
+        getVm().setinitrd_url(runVmParameters.getinitrd_url());
+        getVm().setkernel_url(runVmParameters.getkernel_url());
+        getVm().setkernel_params(runVmParameters.getkernel_params());
+        getVm().setCustomProperties(runVmParameters.getCustomProperties());
+    }
+
+    @Override
+    protected void refreshBootSequenceParameter(RunVmParams runVmParameters) {
+        super.refreshBootSequenceParameter(runVmParameters);
+
+        if (runVmParameters != null) {
+            getVm().setboot_sequence(runVmParameters.getBootSequence());
+        }
+    }
+
     @Override
     public boolean validateAndSetQuota() {
         if (isInternalExecution()) {
@@ -65,7 +92,7 @@
         if (!quotaAcc) {
             return false;
         }
-        //Only if this is run-stateless mode we calculate storage quota.
+        // Only if this is run-stateless mode we calculate storage quota.
         if (!Boolean.TRUE.equals(getParameters().getRunAsStateless())) {
             return quotaAcc;
         }


--
To view, visit http://gerrit.ovirt.org/8083
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I32e59783d9c4d8e8b61ec96c6bae5577fc59756c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Tomas Jelinek <tjeli...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to