diff options
| author | chengcheng-chcheng <63850735+chengcheng-chcheng@users.noreply.github.com> | 2020-06-10 00:20:47 +0800 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-09 12:20:47 -0400 | 
| commit | c6d09af67626c2f2241c64c10c9e27e8752ba87b (patch) | |
| tree | d72d4e1918edc5a182dc2a549e513c29a70b9f9d /cloudinit/sources/helpers | |
| parent | e52ec4ebb8042e3be8c409252f6bbeb1fd767ee2 (diff) | |
| download | vyos-cloud-init-c6d09af67626c2f2241c64c10c9e27e8752ba87b.tar.gz vyos-cloud-init-c6d09af67626c2f2241c64c10c9e27e8752ba87b.zip | |
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)
Diffstat (limited to 'cloudinit/sources/helpers')
| -rw-r--r-- | cloudinit/sources/helpers/vmware/imc/guestcust_util.py | 31 | 
1 files changed, 19 insertions, 12 deletions
| diff --git a/cloudinit/sources/helpers/vmware/imc/guestcust_util.py b/cloudinit/sources/helpers/vmware/imc/guestcust_util.py index 893b1365..d919f693 100644 --- a/cloudinit/sources/helpers/vmware/imc/guestcust_util.py +++ b/cloudinit/sources/helpers/vmware/imc/guestcust_util.py @@ -133,23 +133,30 @@ def get_tools_config(section, key, defaultVal):              'vmware-toolbox-cmd not installed, returning default value')          return defaultVal -    retValue = defaultVal      cmd = ['vmware-toolbox-cmd', 'config', 'get', section, key]      try:          (outText, _) = subp.subp(cmd) -        m = re.match(r'([^=]+)=(.*)', outText) -        if m: -            retValue = m.group(2).strip() -            logger.debug("Get tools config: [%s] %s = %s", -                         section, key, retValue) -        else: -            logger.debug( -                "Tools config: [%s] %s is not found, return default value: %s", -                section, key, retValue)      except subp.ProcessExecutionError as e: -        logger.error("Failed running %s[%s]", cmd, e.exit_code) -        logger.exception(e) +        if e.exit_code == 69: +            logger.debug( +                "vmware-toolbox-cmd returned 69 (unavailable) for cmd: %s." +                " Return default value: %s", " ".join(cmd), defaultVal) +        else: +            logger.error("Failed running %s[%s]", cmd, e.exit_code) +            logger.exception(e) +        return defaultVal + +    retValue = defaultVal +    m = re.match(r'([^=]+)=(.*)', outText) +    if m: +        retValue = m.group(2).strip() +        logger.debug("Get tools config: [%s] %s = %s", +                     section, key, retValue) +    else: +        logger.debug( +            "Tools config: [%s] %s is not found, return default value: %s", +            section, key, retValue)      return retValue | 
