[PATCH] esx: Support vSphere 5.x

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

Based on http://www.redhat.com/archives/libvir-list/2010-July/msg00480.html, I created this quick patch to accept connection to vSphere 5.x
Notes:
- I had to remove the warnings for version > 4.1 & 5 because they were generating errors when running scripts encapsulating virsh commands with opennebula. A better option might be to relie on an environment variable (for example DONT_BLAME_LIBVIRT!) to toggle warnings on/off
- Ran only a few tests but it works as expected.
- Next steps should be to work on VMware API 5. integration

Patrice

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 41086ef..78872d4 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -730,9 +730,11 @@ esxConnectToHost(esxPrivate *priv, virConnectAuthPtr auth,
         if (priv->host->productVersion != esxVI_ProductVersion_ESX35 &&
             priv->host->productVersion != esxVI_ProductVersion_ESX40 &&
             priv->host->productVersion != esxVI_ProductVersion_ESX41 &&
-            priv->host->productVersion != esxVI_ProductVersion_ESX4x) {
+            priv->host->productVersion != esxVI_ProductVersion_ESX4x &&
+            priv->host->productVersion != esxVI_ProductVersion_ESX50 &&
+            priv->host->productVersion != esxVI_ProductVersion_ESX5x) {
             ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
-                      _("%s is neither an ESX 3.5 host nor an ESX 4.x host"),
+                      _("%s is neither an ESX 3.5, 4.x nor 5.x host"),
                       hostname);
             goto cleanup;
         }
@@ -857,10 +859,11 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
     if (priv->vCenter->productVersion != esxVI_ProductVersion_VPX25 &&
         priv->vCenter->productVersion != esxVI_ProductVersion_VPX40 &&
         priv->vCenter->productVersion != esxVI_ProductVersion_VPX41 &&
-        priv->vCenter->productVersion != esxVI_ProductVersion_VPX4x) {
+        priv->vCenter->productVersion != esxVI_ProductVersion_VPX4x &&
+        priv->vCenter->productVersion != esxVI_ProductVersion_VPX50 &&
+        priv->vCenter->productVersion != esxVI_ProductVersion_VPX5x) {
         ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
-                  _("%s is neither a vCenter 2.5 server nor a vCenter "
-                    "4.x server"), hostname);
+                  _("%s is neither a vCenter 2.5, 4.x nor 5.x server"), hostname);
         goto cleanup;
     }
 
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 325157c..3a11116 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -675,9 +675,23 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
 
             VIR_WARN("Found untested VI API major/minor version '%s'",
                      ctx->service->about->apiVersion);
+        } else if (STRPREFIX(ctx->service->about->apiVersion, "5.0")) {
+            ctx->apiVersion = esxVI_APIVersion_50;
+
+    /*
+            VIR_WARN("Found untested VI API major/minor version '%s'",
+                     ctx->service->about->apiVersion);
+    */
+        } else if (STRPREFIX(ctx->service->about->apiVersion, "5.")) {
+            ctx->apiVersion = esxVI_APIVersion_5x;
+
+    /*
+            VIR_WARN("Found untested VI API major/minor version '%s'",
+                     ctx->service->about->apiVersion);
+    */
         } else {
             ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
-                         _("Expecting VI API major/minor version '2.5' or '4.x' "
+                         _("Expecting VI API major/minor version '2.5', '4.x' or '5.x' "
                            "but found '%s'"), ctx->service->about->apiVersion);
             return -1;
         }
@@ -704,10 +718,24 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
 
                 VIR_WARN("Found untested ESX major/minor version '%s'",
                          ctx->service->about->version);
+            } else if (STRPREFIX(ctx->service->about->version, "5.0")) {
+                ctx->productVersion = esxVI_ProductVersion_ESX50;
+
+    /*
+                VIR_WARN("Found untested ESX major/minor version '%s'",
+                         ctx->service->about->version);
+    */
+            } else if (STRPREFIX(ctx->service->about->version, "5.")) {
+                ctx->productVersion = esxVI_ProductVersion_ESX5x;
+
+    /*
+                VIR_WARN("Found untested ESX major/minor version '%s'",
+                         ctx->service->about->version);
+    */
             } else {
                 ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
-                             _("Expecting ESX major/minor version '3.5' or "
-                               "'4.x' but found '%s'"),
+                             _("Expecting ESX major/minor version '3.5', '4.x' or "
+                               "'5.x' but found '%s'"),
                              ctx->service->about->version);
                 return -1;
             }
@@ -723,9 +751,23 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
 
                 VIR_WARN("Found untested VPX major/minor version '%s'",
                          ctx->service->about->version);
+            } else if (STRPREFIX(ctx->service->about->version, "5.0")) {
+                ctx->productVersion = esxVI_ProductVersion_VPX50;
+
+    /*
+                VIR_WARN("Found untested VPX major/minor version '%s'",
+                         ctx->service->about->version);
+    */
+            } else if (STRPREFIX(ctx->service->about->version, "5.")) {
+                ctx->productVersion = esxVI_ProductVersion_VPX5x;
+
+    /*
+                VIR_WARN("Found untested VPX major/minor version '%s'",
+                         ctx->service->about->version);
+    */
             } else {
                 ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
-                             _("Expecting VPX major/minor version '2.5' or '4.x' "
+                             _("Expecting VPX major/minor version '2.5', '4.x' or '5.x' "
                                "but found '%s'"), ctx->service->about->version);
                 return -1;
             }
@@ -3919,6 +3961,12 @@ esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersio
       case esxVI_ProductVersion_VPX4x:
         return 7;
 
+      case esxVI_ProductVersion_ESX50:
+      case esxVI_ProductVersion_VPX50:
+      case esxVI_ProductVersion_ESX5x:
+      case esxVI_ProductVersion_VPX5x:
+        return 8;
+
       default:
         ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
                      _("Unexpected product version"));
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index b8e921f..fbf3fb2 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -99,7 +99,9 @@ enum _esxVI_APIVersion {
     esxVI_APIVersion_25,
     esxVI_APIVersion_40,
     esxVI_APIVersion_41,
-    esxVI_APIVersion_4x /* > 4.1 */
+    esxVI_APIVersion_4x,
+    esxVI_APIVersion_50,
+    esxVI_APIVersion_5x /* > 5.0 */
 };
 
 /*
@@ -116,13 +118,17 @@ enum _esxVI_ProductVersion {
     esxVI_ProductVersion_ESX35 = esxVI_ProductVersion_ESX | 1,
     esxVI_ProductVersion_ESX40 = esxVI_ProductVersion_ESX | 2,
     esxVI_ProductVersion_ESX41 = esxVI_ProductVersion_ESX | 3,
-    esxVI_ProductVersion_ESX4x = esxVI_ProductVersion_ESX | 4, /* > 4.1 */
+    esxVI_ProductVersion_ESX4x = esxVI_ProductVersion_ESX | 4,
+    esxVI_ProductVersion_ESX50 = esxVI_ProductVersion_ESX | 5,
+    esxVI_ProductVersion_ESX5x = esxVI_ProductVersion_ESX | 6, /* > 5.0 */
 
     esxVI_ProductVersion_VPX   = (1 << 2) << 16,
     esxVI_ProductVersion_VPX25 = esxVI_ProductVersion_VPX | 1,
     esxVI_ProductVersion_VPX40 = esxVI_ProductVersion_VPX | 2,
     esxVI_ProductVersion_VPX41 = esxVI_ProductVersion_VPX | 3,
-    esxVI_ProductVersion_VPX4x = esxVI_ProductVersion_VPX | 4  /* > 4.1 */
+    esxVI_ProductVersion_VPX4x = esxVI_ProductVersion_VPX | 4,
+    esxVI_ProductVersion_VPX50 = esxVI_ProductVersion_VPX | 5,
+    esxVI_ProductVersion_VPX5x = esxVI_ProductVersion_VPX | 6  /* > 5.0 */
 };
 
 enum _esxVI_Occurrence {


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]