Shahar Havivi has uploaded a new change for review.

Change subject: engine: cannot set payload and cloud-init on same devices.
......................................................................

engine: cannot set payload and cloud-init on same devices.

On initial run we automatic set cloud-init/sysprep as cdrom/floppy
device - this cause conflict when using the same media.

Change-Id: Ic5b701f058a2d87b2836d337f822d2f012d10bbe
Bug-Url: https://bugzilla.redhat.com/1138314
Signed-off-by: Shahar Havivi <shah...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
1 file changed, 28 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/18/33318/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 6194d05..0ed78eb 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
@@ -53,6 +53,7 @@
 import org.ovirt.engine.core.common.businessentities.VmDevice;
 import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType;
 import org.ovirt.engine.core.common.businessentities.VmDeviceId;
+import org.ovirt.engine.core.common.businessentities.VmPayload;
 import org.ovirt.engine.core.common.businessentities.VmPool;
 import org.ovirt.engine.core.common.businessentities.VmPoolType;
 import org.ovirt.engine.core.common.businessentities.VmRngDevice;
@@ -74,6 +75,7 @@
 import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.Version;
+import org.ovirt.engine.core.dal.dbbroker.DbFacade;
 import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector;
 import org.ovirt.engine.core.dal.job.ExecutionMessageDirector;
 import org.ovirt.engine.core.dao.SnapshotDao;
@@ -665,14 +667,16 @@
             // if vm not initialized, use sysprep/cloud-init
             if (!getVm().isInitialized()) {
                 VmHandler.updateVmInitFromDB(getVm().getStaticData(), false);
+                getVm().setInitializationType(InitializationType.None);
                 if (osRepository.isWindows(getVm().getVmOsId())) {
-                    getVm().setInitializationType(InitializationType.Sysprep);
+                    if (!isPaloadExists(VmDeviceType.FLOPPY.getName())) {
+                        
getVm().setInitializationType(InitializationType.Sysprep);
+                    }
                 }
                 else if (getVm().getVmInit() != null) {
-                    
getVm().setInitializationType(InitializationType.CloudInit);
-                }
-                else {
-                    getVm().setInitializationType(InitializationType.None);
+                    if (!isPaloadExists(VmDeviceType.CDROM.getName())) {
+                        
getVm().setInitializationType(InitializationType.CloudInit);
+                    }
                 }
             }
         } else {
@@ -694,6 +698,25 @@
         }
     }
 
+    // Device name CDROM/Floppy
+    protected boolean isPaloadExists(String deviceName) {
+        if (getVm().getVmPayload() != null) {
+            return true;
+        }
+        List<VmDevice> vmDevices =
+                DbFacade.getInstance()
+                        .getVmDeviceDao()
+                        .getVmDeviceByVmIdTypeAndDevice(getVm().getId(),
+                                VmDeviceGeneralType.DISK,
+                                deviceName);
+        for (VmDevice vmDevice : vmDevices) {
+            if (VmPayload.isPayload(vmDevice.getSpecParams())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     protected void fetchVmDisksFromDb() {
         if (getVm().getDiskMap().isEmpty()) {
             VmHandler.updateDisksFromDb(getVm());


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

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

Reply via email to