Repository: canonical/cloud-init (Python)

Issue:
DS VMware: Fails to locate open-vm-tools libdeployPkgPlugin.so due to multi-arch compliant on Debian12 32-bit
# Bug report
DS VMware: Fails to locate open-vm-tools libdeployPkgPlugin.so due to multi-arch compliant on Debian12 32-bit

## Steps to reproduce the problem
See details in https://bugs.launchpad.net/cloud-init/+bug/1944946, path of open-vm-tools libdeployPkgPlugin.so is now multi-arch compliant. For Debian12 32-bit, the path is /usr/lib/i386-linux-gnu/open-vm-tools/plugins/vmsvc/libdeployPkgPlugin.so

In commit https://github.com/canonical/cloud-init/commit/76166caff42b82aa55c6bcd9528f2c1e3575232a, we've added 2 multi-arch paths: 
/usr/lib/x86_64-linux-gnu/open-vm-tools/plugins/vmsvc/libdeployPkgPlugin.so
/usr/lib/aarch64-linux-gnu/open-vm-tools/plugins/vmsvc/libdeployPkgPlugin.so

Need add the i386-linux-gnu path /usr/lib/i386-linux-gnu/open-vm-tools/plugins/vmsvc/libdeployPkgPlugin.so too.

## Environment details
- Cloud-init version: 22.4.2
- Operating System Distribution: Debian 12 32-bit
- Cloud provider, platform or installer type: VMware vSphere

## cloud-init logs
NA


Tracked by VMware internal bug: 3235506


Discussion:

Patch:
diff --git a/cloudinit/sources/helpers/vmware/imc/guestcust_util.py b/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
index 92e71370027..6e3230b197f 100644
--- a/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
+++ b/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
@@ -614,6 +614,7 @@ def is_cust_plugin_available():
         "/usr/lib64/open-vm-tools",
         "/usr/lib/x86_64-linux-gnu/open-vm-tools",
         "/usr/lib/aarch64-linux-gnu/open-vm-tools",
+        "/usr/lib/i386-linux-gnu/open-vm-tools",
     )
     cust_plugin = "libdeployPkgPlugin.so"
     for path in search_paths:
diff --git a/tools/ds-identify b/tools/ds-identify
index bac385dc9cb..ce983e24c38 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -931,14 +931,16 @@ vmware_guest_customization() {
 
     # we have to have the plugin to do vmware customization
     local found="" pkg="" pre="${PATH_ROOT}/usr/lib"
-    local x86="x86_64-linux-gnu" aarch="aarch64-linux-gnu"
+    local x86="x86_64-linux-gnu" aarch="aarch64-linux-gnu" i386="i386-linux-gnu"
     local ppath="plugins/vmsvc/libdeployPkgPlugin.so"
     for pkg in vmware-tools open-vm-tools; do
         if [ -f "$pre/$pkg/$ppath" -o -f "${pre}64/$pkg/$ppath" ]; then
             found="$pkg"; break;
         fi
         # search in multiarch dir
-        if [ -f "$pre/$x86/$pkg/$ppath" -o -f "$pre/$aarch/$pkg/$ppath" ]; then
+        if [ -f "$pre/$x86/$pkg/$ppath" ] || \
+           [ -f "$pre/$aarch/$pkg/$ppath" ] || \
+           [ -f "$pre/$i386/$pkg/$ppath" ]; then
             found="$pkg"; break;
         fi
     done


Test patch:
diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
index 725c622c662..ea7683d53fb 100644
--- a/tests/unittests/test_ds_identify.py
+++ b/tests/unittests/test_ds_identify.py
@@ -832,6 +832,21 @@ def test_vmware_on_vmware_open_vm_tools_aarch64_linux_gnu(self):
             cust64, RC_FOUND, dslist=[cust64.get("ds"), DS_NONE]
         )
 
+    def test_vmware_on_vmware_open_vm_tools_i386_linux_gnu(self):
+        """VMware is identified when open-vm-tools installed in
+        /usr/lib/i386-linux-gnu."""
+        cust64 = copy.deepcopy(VALID_CFG["VMware-vmware-customization"])
+        p32 = "usr/lib/vmware-tools/plugins/vmsvc/libdeployPkgPlugin.so"
+        i386 = (
+            "usr/lib/i386-linux-gnu/open-vm-tools/plugins/vmsvc/"
+            "libdeployPkgPlugin.so"
+        )
+        cust64["files"][i386] = cust64["files"][p32]
+        del cust64["files"][p32]
+        return self._check_via_dict(
+            cust64, RC_FOUND, dslist=[cust64.get("ds"), DS_NONE]
+        )
+
     def test_vmware_envvar_no_data(self):
         """VMware: envvar transport no data"""
         self._test_ds_not_found("VMware-EnvVar-NoData")