diff options
author | Ben Howard <ben.howard@canonical.com> | 2015-01-14 12:24:09 -0700 |
---|---|---|
committer | Ben Howard <ben.howard@canonical.com> | 2015-01-14 12:24:09 -0700 |
commit | 28c8aa7270a04adea69065477b13cfc0dd244acc (patch) | |
tree | 76f2535102b42f25995e25a5829ede283510cf03 /cloudinit/sources/DataSourceCloudSigma.py | |
parent | 62e9e73e3ed8467fc4d4d95f76ed0443c50f176c (diff) | |
download | vyos-cloud-init-28c8aa7270a04adea69065477b13cfc0dd244acc.tar.gz vyos-cloud-init-28c8aa7270a04adea69065477b13cfc0dd244acc.zip |
Drop reliance on dmidecode executable.
Diffstat (limited to 'cloudinit/sources/DataSourceCloudSigma.py')
-rw-r--r-- | cloudinit/sources/DataSourceCloudSigma.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/cloudinit/sources/DataSourceCloudSigma.py b/cloudinit/sources/DataSourceCloudSigma.py index 707cd0ce..76597116 100644 --- a/cloudinit/sources/DataSourceCloudSigma.py +++ b/cloudinit/sources/DataSourceCloudSigma.py @@ -44,27 +44,25 @@ class DataSourceCloudSigma(sources.DataSource): def is_running_in_cloudsigma(self): """ - Uses dmidecode to detect if this instance of cloud-init is running + Uses dmi data to detect if this instance of cloud-init is running in the CloudSigma's infrastructure. """ uname_arch = os.uname()[4] if uname_arch.startswith("arm") or uname_arch == "aarch64": - # Disabling because dmidecode in CMD_DMI_SYSTEM crashes kvm process + # Disabling because dmi data on ARM processors LOG.debug("Disabling CloudSigma datasource on arm (LP: #1243287)") return False - dmidecode_path = util.which('dmidecode') - if not dmidecode_path: + LOG.debug("determining hypervisor product name via dmi data") + sys_product_name = util.read_dmi_data("system-product-name") + if not sys_product_name: + LOG.warn("failed to get hypervisor product name via dmi data") return False + else: + LOG.debug("detected hypervisor as {}".format(sys_product_name)) + return 'cloudsigma' in sys_product_name.lower() - LOG.debug("Determining hypervisor product name via dmidecode") - try: - cmd = [dmidecode_path, "--string", "system-product-name"] - system_product_name, _ = util.subp(cmd) - return 'cloudsigma' in system_product_name.lower() - except: - LOG.warn("Failed to get hypervisor product name via dmidecode") - + LOG.warn("failed to query dmi data for system product name") return False def get_data(self): |