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



##########
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:
       @nvazquez not just comparison, the minimum hardware version is needed 
when migration is between different hosts so the worker VM can be created with 
a lower hardware version. eg - when migrating between ESXi 6.0 and 6.5 hosts, 
VM should have hardwareVersion of ESXi 6.0.
   I couldn't find any in-built method to get integer version from ESXi API 
version. We discussed the same during #4385 




-- 
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