From cc549350c6010908add773a8b74e5d1ac840bbf1 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 12 Apr 2016 11:54:31 -0400 Subject: DataSourceNoCloud: fix check_instance_id when upgraded A system that had booted, upgraded, and then rebooted would show a cloud-init stack trace as it attempted to run new code with the old pickled object. The old object would not have the seed_dirs attribute. So we check and fallback correctly if that is not present. LP: #1568150 --- cloudinit/sources/DataSourceNoCloud.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cloudinit/sources') diff --git a/cloudinit/sources/DataSourceNoCloud.py b/cloudinit/sources/DataSourceNoCloud.py index c2fba4d2..74d0e5ec 100644 --- a/cloudinit/sources/DataSourceNoCloud.py +++ b/cloudinit/sources/DataSourceNoCloud.py @@ -216,8 +216,11 @@ class DataSourceNoCloud(sources.DataSource): if not current: return None + # LP: #1568150 need getattr in the case that an old class object + # has been loaded from a pickled file and now executing new source. + dirs = getattr(self, 'seed_dirs', [self.seed_dir]) quick_id = _quick_read_instance_id(cmdline_id=self.cmdline_id, - dirs=self.seed_dirs) + dirs=dirs) if not quick_id: return None return quick_id == current @@ -238,6 +241,8 @@ def _quick_read_instance_id(cmdline_id, dirs=None): return fill[iid_key] for d in dirs: + if d is None: + continue try: data = util.pathprefix2dict(d, required=['meta-data']) md = util.load_yaml(data['meta-data']) -- cgit v1.2.3 From 5cfe3d6fa2d50a68f9b6c7ceb4b9d5db09687782 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 12 Apr 2016 12:57:50 -0400 Subject: SmartOS, CloudSigma: fix error when dmi data is not availble In Cloudsigma, the datasource would warn if no product id was availble. SmartOS would log exception. This fixes both of those, changing the warning to a debug message. LP: #1569469 --- cloudinit/sources/DataSourceCloudSigma.py | 2 +- cloudinit/sources/DataSourceSmartOS.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'cloudinit/sources') diff --git a/cloudinit/sources/DataSourceCloudSigma.py b/cloudinit/sources/DataSourceCloudSigma.py index f8f94759..d7d4e844 100644 --- a/cloudinit/sources/DataSourceCloudSigma.py +++ b/cloudinit/sources/DataSourceCloudSigma.py @@ -56,7 +56,7 @@ class DataSourceCloudSigma(sources.DataSource): 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") + LOG.debug("system-product-name not available in dmi data") return False else: LOG.debug("detected hypervisor as %s", sys_product_name) diff --git a/cloudinit/sources/DataSourceSmartOS.py b/cloudinit/sources/DataSourceSmartOS.py index 5edab152..6cbd8dfa 100644 --- a/cloudinit/sources/DataSourceSmartOS.py +++ b/cloudinit/sources/DataSourceSmartOS.py @@ -242,7 +242,7 @@ class DataSourceSmartOS(sources.DataSource): # SDC KVM instances will provide dmi data, LX-brand does not if self.smartos_type == 'kvm': dmi_info = dmi_data() - if dmi_info is False: + if dmi_info is None: LOG.debug("No dmidata utility found") return False -- cgit v1.2.3