sailesh1993 / rpms / cloud-init

Forked from rpms/cloud-init 10 months ago
Clone
376cca
From 07755100b11abd4d429577f9f3f57a2c43592089 Mon Sep 17 00:00:00 2001
376cca
From: Eduardo Otubo <otubo@redhat.com>
376cca
Date: Mon, 17 Aug 2020 11:14:45 +0200
376cca
Subject: [PATCH 1/2] When tools.conf does not exist, running cmd
376cca
 "vmware-toolbox-cmd config get deployPkg enable-custom-scripts", the return
376cca
 code will be EX_UNAVAILABLE(69), on this condition, it should not take it as
376cca
 error. (#413)
376cca
376cca
RH-Author: Eduardo Otubo <otubo@redhat.com>
376cca
Message-id: <20200710094434.9711-1-otubo@redhat.com>
376cca
Patchwork-id: 97934
376cca
O-Subject: [RHEL-7.9.z/RHEL-8.2.1/RHEL-8.3.0 cloud-init PATCH] When tools.conf does not exist, running cmd "vmware-toolbox-cmd config get deployPkg enable-custom-scripts", the return code will be EX_UNAVAILABLE(69), on this condition, it should not take it as error. (#413)
376cca
Bugzilla: 1839662
376cca
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
376cca
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
376cca
376cca
From: chengcheng-chcheng <63850735+chengcheng-chcheng@users.noreply.github.com>
376cca
376cca
The diff seems slightly different from upstream because of some parts
376cca
being in different positions. But the final result is the file patched
376cca
guestcust_util.py (within this block) exactly identical to the one
376cca
upstream.
376cca
376cca
Also: Sorry for the commit message being just a Subject and this being
376cca
enormous. I kept the original from upstream.
376cca
376cca
commit c6d09af67626c2f2241c64c10c9e27e8752ba87b
376cca
Author: chengcheng-chcheng <63850735+chengcheng-chcheng@users.noreply.github.com>
376cca
Date:   Wed Jun 10 00:20:47 2020 +0800
376cca
376cca
    When tools.conf does not exist, running cmd "vmware-toolbox-cmd config get deployPkg enable-custom-scripts", the return code will be EX_UNAVAILABLE(69), on this condition, it should not take it as error. (#413)
376cca
376cca
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
376cca
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
376cca
---
376cca
 .../sources/helpers/vmware/imc/guestcust_util.py   | 33 +++++++++++++---------
376cca
 1 file changed, 20 insertions(+), 13 deletions(-)
376cca
376cca
diff --git a/cloudinit/sources/helpers/vmware/imc/guestcust_util.py b/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
376cca
index 3d369d0..a270d9f 100644
376cca
--- a/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
376cca
+++ b/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
376cca
@@ -133,23 +133,30 @@ def get_tools_config(section, key, defaultVal):
376cca
             'vmware-toolbox-cmd not installed, returning default value')
376cca
         return defaultVal
376cca
 
376cca
-    retValue = defaultVal
376cca
     cmd = ['vmware-toolbox-cmd', 'config', 'get', section, key]
376cca
 
376cca
     try:
376cca
-        (outText, _) = util.subp(cmd)
376cca
-        m = re.match(r'([^=]+)=(.*)', outText)
376cca
-        if m:
376cca
-            retValue = m.group(2).strip()
376cca
-            logger.debug("Get tools config: [%s] %s = %s",
376cca
-                         section, key, retValue)
376cca
-        else:
376cca
+        (outText, _) = subp.subp(cmd)
376cca
+    except subp.ProcessExecutionError as e:
376cca
+        if e.exit_code == 69:
376cca
             logger.debug(
376cca
-                "Tools config: [%s] %s is not found, return default value: %s",
376cca
-                section, key, retValue)
376cca
-    except util.ProcessExecutionError as e:
376cca
-        logger.error("Failed running %s[%s]", cmd, e.exit_code)
376cca
-        logger.exception(e)
376cca
+                "vmware-toolbox-cmd returned 69 (unavailable) for cmd: %s."
376cca
+                " Return default value: %s", " ".join(cmd), defaultVal)
376cca
+        else:
376cca
+            logger.error("Failed running %s[%s]", cmd, e.exit_code)
376cca
+            logger.exception(e)
376cca
+        return defaultVal
376cca
+
376cca
+    retValue = defaultVal
376cca
+    m = re.match(r'([^=]+)=(.*)', outText)
376cca
+    if m:
376cca
+        retValue = m.group(2).strip()
376cca
+        logger.debug("Get tools config: [%s] %s = %s",
376cca
+                     section, key, retValue)
376cca
+    else:
376cca
+        logger.debug(
376cca
+            "Tools config: [%s] %s is not found, return default value: %s",
376cca
+            section, key, retValue)
376cca
 
376cca
     return retValue
376cca
 
376cca
-- 
376cca
1.8.3.1
376cca