Eli Mesika has uploaded a new change for review.

Change subject: core: handle host architecture in fence flow
......................................................................

core: handle host architecture in fence flow

This patch adds a getArchitecture method to VDS.
It is used in order to get the host architecture using its cpu flags, in
case that this is null, the architecture of the containing cluster is
used.

Please note that a separate call to get VdsDynamic information for the
host since the VDS object passed to the fencing code is slim and does
not contain any dymanic information.

Change-Id: I081361c9f956ea71a715acf0368c79c7130674c7
Bug-Url: core: support default fencing params for PPC
Signed-off-by: Eli Mesika <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java
3 files changed, 36 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/71/34671/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
index b08a170..a67ddfd 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
@@ -242,9 +242,7 @@
     private String getManagementOptions(FenceAgentOrder order) {
         String managementOptions = "";
         ArchitectureType architectureType = null;
-        if (_vds.getCpuName() != null) {
-            architectureType =  _vds.getCpuName().getArchitecture();
-        }
+        architectureType = 
VdsArchitectureHelper.getArchitecture(_vds.getStaticData());
         if (order == FenceAgentOrder.Primary) {
             managementOptions = 
VdsFenceOptions.getDefaultAgentOptions(_vds.getPmType(), _vds.getPmOptions(), 
architectureType);
         }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
index fca6be2..1194a78 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
@@ -590,7 +590,7 @@
         // subsequent 'on' command issued during this delay will be overridden 
by the actual shutdown
         String agent = (order == FenceAgentOrder.Primary) ? 
getVds().getPmType() : getVds().getPmSecondaryType();
         String options =  (order == FenceAgentOrder.Primary) ? 
getVds().getPmOptions() : getVds().getPmSecondaryOptions();
-        ArchitectureType architectureType = (getVds().getCpuName() != null) ? 
getVds().getCpuName().getArchitecture() : null;
+        ArchitectureType architectureType = 
VdsArchitectureHelper.getArchitecture(getVds().getStaticData());
         options = VdsFenceOptions.getDefaultAgentOptions(agent, options, 
architectureType);
         HashMap<String, String> optionsMap = 
VdsStatic.pmOptionsStringToMap(options);
         String powerWaitParamSettings = 
FenceConfigHelper.getFenceConfigurationValue(ConfigValues.FencePowerWaitParam.name(),
 ConfigCommon.defaultConfigurationVersion);
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java
new file mode 100644
index 0000000..fd5c909
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java
@@ -0,0 +1,34 @@
+package org.ovirt.engine.core.bll;
+
+import org.ovirt.engine.core.common.businessentities.ArchitectureType;
+import org.ovirt.engine.core.common.businessentities.ServerCpu;
+import org.ovirt.engine.core.common.businessentities.VDSGroup;
+import org.ovirt.engine.core.common.businessentities.VdsDynamic;
+import org.ovirt.engine.core.common.businessentities.VdsStatic;
+import org.ovirt.engine.core.dal.dbbroker.DbFacade;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class VdsArchitectureHelper {
+
+    static final Logger log = 
LoggerFactory.getLogger(VdsArchitectureHelper.class);
+
+    /**
+     * Gets the architecture type of the given host using its cpu flags, if 
not found, return the cluster architecture
+     * @param host
+     *            The host
+     * @return
+     *            The host architecture type
+     */
+    public static ArchitectureType getArchitecture(VdsStatic host) {
+        VDSGroup cluster = 
DbFacade.getInstance().getVdsGroupDao().get(host.getVdsGroupId());
+        VdsDynamic vdsDynamic = 
DbFacade.getInstance().getVdsDynamicDao().get(host.getId());
+        ServerCpu cpu = 
CpuFlagsManagerHandler.FindMaxServerCpuByFlags(vdsDynamic.getcpu_flags(), 
cluster.getcompatibility_version());
+        if (cpu != null && cpu.getArchitecture() != null) {
+            return cpu.getArchitecture();
+        }
+        // take architecture from the cluster if it is null on the host level
+        log.info("Failed to get architecture type from host information for 
host '{}'. Using cluster '{}' architecture value instead.", host.getName(), 
cluster.getName());
+        return cluster.getArchitecture();
+    }
+}


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

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

Reply via email to