Vitor de Lima has uploaded a new change for review.

Change subject: core, engine: Disable Migrate On Error on ppc64 clusters
......................................................................

core, engine: Disable Migrate On Error on ppc64 clusters

This change handles the use case where a host enters a cluster without
a CPU name, changing this value to have the same value as the one
reported by the host. If the architecture of the host does not support
migration, this change forces the Migrate On Error option to be
disabled.

Change-Id: I556ef1ce4896ddeb39b93a93520fd0535b4fa28c
Signed-off-by: Vitor de Lima <vitor.l...@eldorado.org.br>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HandleVdsCpuFlagsOrClusterChangedCommand.java
1 file changed, 34 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/44/21644/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HandleVdsCpuFlagsOrClusterChangedCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HandleVdsCpuFlagsOrClusterChangedCommand.java
index a74bcda..3ca5ddb 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HandleVdsCpuFlagsOrClusterChangedCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HandleVdsCpuFlagsOrClusterChangedCommand.java
@@ -3,12 +3,16 @@
 import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
+import org.ovirt.engine.core.bll.architecture.IsMigrationSupported;
 import org.ovirt.engine.core.bll.job.ExecutionHandler;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.SetNonOperationalVdsParameters;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.action.VdsActionParameters;
 import org.ovirt.engine.core.common.action.VdsGroupOperationParameters;
+import org.ovirt.engine.core.common.archstrategy.ArchStrategyFactory;
+import org.ovirt.engine.core.common.businessentities.ArchitectureType;
+import org.ovirt.engine.core.common.businessentities.MigrateOnErrorOptions;
 import org.ovirt.engine.core.common.businessentities.NonOperationalReason;
 import org.ovirt.engine.core.common.businessentities.ServerCpu;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
@@ -60,6 +64,8 @@
                 VDSGroup grp = 
DbFacade.getInstance().getVdsGroupDao().get(getVds().getVdsGroupId());
                 grp.setcpu_name(sc.getCpuName());
 
+                updateMigrateOnError(grp);
+
                 // use suppress in order to update group even if action fails
                 // (out of the transaction)
                 VdsGroupOperationParameters tempVar = new 
VdsGroupOperationParameters(grp);
@@ -93,6 +99,34 @@
         setSucceeded(true);
     }
 
+    private void updateMigrateOnError(VDSGroup group) {
+        boolean isMigrationSupported = true;
+
+        ArchitectureType arch = getArchitecture(group);
+
+        if (!arch.equals(ArchitectureType.undefined)) {
+            isMigrationSupported =
+                    ArchStrategyFactory.getStrategy(arch)
+                            .run(new 
IsMigrationSupported(group.getcompatibility_version()))
+                            .returnValue();
+        }
+
+        if (!isMigrationSupported) {
+            group.setMigrateOnError(MigrateOnErrorOptions.NO);
+        }
+    }
+
+    protected ArchitectureType getArchitecture(VDSGroup group) {
+        if (StringUtils.isNotEmpty(group.getcpu_name())) {
+            return 
CpuFlagsManagerHandler.getArchitectureByCpuName(group.getcpu_name(),
+                    group.getcompatibility_version());
+        } else if (group.getArchitecture() == null) {
+            return ArchitectureType.undefined;
+        }
+
+        return group.getArchitecture();
+    }
+
     @Override
     public AuditLogType getAuditLogTypeValue() {
         // check first if no flags and then if succeeded


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I556ef1ce4896ddeb39b93a93520fd0535b4fa28c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Vitor de Lima <vitor.l...@eldorado.org.br>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to