shwstppr commented on a change in pull request #4895:
URL: https://github.com/apache/cloudstack/pull/4895#discussion_r610590349



##########
File path: 
vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
##########
@@ -2211,4 +2253,36 @@ public static void 
createBaseFolderInDatastore(DatastoreMO dsMo, VmwareHyperviso
             dsMo.makeDirectory(hiddenFolderPath, 
hyperHost.getHyperHostDatacenter());
         }
     }
+
+    public static Integer getHostHardwareVersion(VmwareHypervisorHost host) {
+        Integer version = null;
+        HostMO hostMo = new HostMO(host.getContext(), host.getMor());
+        String hostApiVersion = "";
+        try {
+            hostApiVersion = hostMo.getHostAboutInfo().getApiVersion();
+        } catch (Exception ignored) {
+        }
+        if (hostApiVersion == null) {
+            hostApiVersion = "";
+        }
+        version = apiVersionHardwareVersionMap.get(hostApiVersion);
+        return version;
+    }
+
+    /*
+      Finds minimum host hardware version as String, of two hosts when both of 
them are not null
+      and hardware version of both hosts is different.
+      Return null otherwise
+     */
+    public static String getMinimumHostHardwareVersion(VmwareHypervisorHost 
host1, VmwareHypervisorHost host2) {
+        String hardwareVersion = null;
+        if (host1 != null & host2 != null) {
+            Integer host1Version = getHostHardwareVersion(host1);
+            Integer host2Version = getHostHardwareVersion(host2);
+            if (host1Version != null && host2Version != null && 
!host1Version.equals(host2Version)) {
+                hardwareVersion = String.valueOf(Math.min(host1Version, 
host2Version));

Review comment:
       When `null` hardwareVersion is passed in `createWorkerVM`, it will use 
host's hardwareVersion




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to