Moti Asayag has uploaded a new change for review.

Change subject: engine: Allow to associate a provider with a vm
......................................................................

engine: Allow to associate a provider with a vm

Change-Id: I9df76ab2a7858758a203eb45b416ae3c82718b88
Bug-Url: https://bugzilla.redhat.com/1157377
Signed-off-by: Moti Asayag <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
1 file changed, 20 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/18/40718/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
index a7306cb..fa29851 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
@@ -9,6 +9,8 @@
 import java.util.Map;
 import java.util.Objects;
 
+import javax.inject.Inject;
+
 import org.apache.commons.codec.CharEncoding;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang.ObjectUtils;
@@ -21,9 +23,9 @@
 import org.ovirt.engine.core.bll.quota.QuotaVdsGroupConsumptionParameter;
 import org.ovirt.engine.core.bll.snapshots.SnapshotsManager;
 import org.ovirt.engine.core.bll.utils.IconUtils;
-import org.ovirt.engine.core.bll.validator.IconValidator;
 import org.ovirt.engine.core.bll.utils.PermissionSubject;
 import org.ovirt.engine.core.bll.utils.VmDeviceUtils;
+import org.ovirt.engine.core.bll.validator.IconValidator;
 import org.ovirt.engine.core.bll.validator.VmValidator;
 import org.ovirt.engine.core.bll.validator.VmWatchdogValidator;
 import org.ovirt.engine.core.common.AuditLogType;
@@ -43,6 +45,8 @@
 import org.ovirt.engine.core.common.businessentities.GraphicsDevice;
 import org.ovirt.engine.core.common.businessentities.GraphicsType;
 import org.ovirt.engine.core.common.businessentities.MigrationSupport;
+import org.ovirt.engine.core.common.businessentities.Provider;
+import org.ovirt.engine.core.common.businessentities.ProviderType;
 import org.ovirt.engine.core.common.businessentities.Snapshot;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
@@ -77,6 +81,7 @@
 import org.ovirt.engine.core.dao.SnapshotDao;
 import org.ovirt.engine.core.dao.VmDeviceDAO;
 import org.ovirt.engine.core.dao.VmNumaNodeDAO;
+import org.ovirt.engine.core.dao.provider.ProviderDao;
 import org.ovirt.engine.core.utils.linq.LinqUtils;
 import org.ovirt.engine.core.utils.linq.Predicate;
 
@@ -84,6 +89,9 @@
         implements QuotaVdsDependent, RenamedEntityInfoProvider{
 
     private static final Base64 BASE_64 = new Base64(0, null);
+
+    @Inject
+    private ProviderDao providerDao;
 
     private VM oldVm;
     private boolean quotaSanityOnly = false;
@@ -712,6 +720,17 @@
             return false;
         }
 
+        if (vmFromParams.getProviderId() != null) {
+            Provider<?> provider = 
providerDao.get(vmFromParams.getProviderId());
+            if (provider == null) {
+                return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_PROVIDER_DOESNT_EXIST);
+            }
+
+            if (provider.getType() != ProviderType.FOREMAN) {
+                return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_HOST_PROVIDER_TYPE_MISMATCH);
+            }
+        }
+
         return true;
     }
 


-- 
To view, visit https://gerrit.ovirt.org/40718
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9df76ab2a7858758a203eb45b416ae3c82718b88
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Moti Asayag <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to