-
-
Save akutz/40825fc02b11d14072706e5c26dc80a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cloudinit/sources/DataSourceVMware.py b/cloudinit/sources/DataSourceVMware.py | |
index 3cf410b7..bfa596ad 100644 | |
--- a/cloudinit/sources/DataSourceVMware.py | |
+++ b/cloudinit/sources/DataSourceVMware.py | |
@@ -141,8 +141,12 @@ class DataSourceVMware(sources.DataSource): | |
_get_data loads the metadata, userdata, and vendordata from one of | |
the following locations in the given order: | |
- * guestinfo | |
* envvars | |
+ * guestinfo | |
+ | |
+ Please note when updating this function with support for new data | |
+ transports, the order should match the order in the dscheck_VMware | |
+ function from the file ds-identify. | |
""" | |
# Initialize the locally scoped metadata, userdata, and vendordata | |
@@ -150,24 +154,24 @@ class DataSourceVMware(sources.DataSource): | |
# access method. | |
md, ud, vd = None, None, None | |
- # First check to see if there is data via guestinfo. | |
- if self.vmware_rpctool: | |
- md = guestinfo("metadata", self.vmware_rpctool) | |
- ud = guestinfo("userdata", self.vmware_rpctool) | |
- vd = guestinfo("vendordata", self.vmware_rpctool) | |
+ # First check to see if there is data via env vars. | |
+ if os.environ.get(VMX_GUESTINFO, ""): | |
+ md = guestinfo_envvar("metadata") | |
+ ud = guestinfo_envvar("userdata") | |
+ vd = guestinfo_envvar("vendordata") | |
if md or ud or vd: | |
- self.data_access_method = DATA_ACCESS_METHOD_GUESTINFO | |
+ self.data_access_method = DATA_ACCESS_METHOD_ENVVAR | |
- # If data has not been loaded, check via envvars. | |
+ # If no data was detected, check the guestinfo transport next. | |
if not self.data_access_method: | |
- if os.environ.get(VMX_GUESTINFO, ""): | |
- md = guestinfo_envvar("metadata") | |
- ud = guestinfo_envvar("userdata") | |
- vd = guestinfo_envvar("vendordata") | |
+ if self.vmware_rpctool: | |
+ md = guestinfo("metadata", self.vmware_rpctool) | |
+ ud = guestinfo("userdata", self.vmware_rpctool) | |
+ vd = guestinfo("vendordata", self.vmware_rpctool) | |
if md or ud or vd: | |
- self.data_access_method = DATA_ACCESS_METHOD_ENVVAR | |
+ self.data_access_method = DATA_ACCESS_METHOD_GUESTINFO | |
if not self.data_access_method: | |
LOG.error("failed to find a valid data access method") | |
diff --git a/tools/ds-identify b/tools/ds-identify | |
index 17e4ea27..234ffa81 100755 | |
--- a/tools/ds-identify | |
+++ b/tools/ds-identify | |
@@ -1397,6 +1397,16 @@ vmware_rpctool_guestinfo_vendordata() { | |
} | |
dscheck_VMware() { | |
+ # Checks to see if there is valid data for the VMware datasource. | |
+ # The data transports are checked in the following order: | |
+ # | |
+ # * envvars | |
+ # * guestinfo | |
+ # | |
+ # Please note when updating this function with support for new data | |
+ # transports, the order should match the order in the _get_data | |
+ # function from the file DataSourceVMware.py. | |
+ | |
# Check to see if running in a container and the VMware | |
# datasource is configured via environment variables. | |
if vmware_has_envvar_vmx_guestinfo; then |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
+1 This looks good and aligns w/ your logic ordering in ds-identify