Update DataSourceVMwareGuestInfo for 20.3 cloud-init
PRODX-18058
Change-Id: I3d56124a36f68196cecdb88104c5fbf0923dcaee
diff --git a/DataSourceVMwareGuestInfo.py b/DataSourceVMwareGuestInfo.py
index b4d2fc0..b86938e 100644
--- a/DataSourceVMwareGuestInfo.py
+++ b/DataSourceVMwareGuestInfo.py
@@ -29,6 +29,12 @@
LOG = logging.getLogger(__name__)
+# from cloud-init >= 20.3 subp is in its own module
+try:
+ from cloudinit.subp import subp, ProcessExecutionError
+except ImportError:
+ from cloudinit.util import subp, ProcessExecutionError
+
# This cloud-init datasource was designed for use with CentOS 7,
# which uses cloud-init 0.7.9. However, this datasource should
# work with any Linux distribution for which cloud-init is
@@ -171,14 +177,14 @@
NOVAL = "No value found"
LOG.debug("Getting guestinfo value for key %s", key)
try:
- (stdout, stderr) = util.subp([self.vmtoolsd, "--cmd", "info-get guestinfo." + key])
+ (stdout, stderr) = subp([self.vmtoolsd, "--cmd", "info-get guestinfo." + key])
if stderr == NOVAL:
LOG.debug("No value found for key %s", key)
elif not stdout:
LOG.error("Failed to get guestinfo value for key %s", key)
else:
return stdout.rstrip()
- except util.ProcessExecutionError as error:
+ except ProcessExecutionError as error:
if error.stderr == NOVAL:
LOG.debug("No value found for key %s", key)
else: