summaryrefslogtreecommitdiff
path: root/cloudinit/sources
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-04-12 11:54:31 -0400
committerScott Moser <smoser@ubuntu.com>2016-04-12 11:54:31 -0400
commitcc549350c6010908add773a8b74e5d1ac840bbf1 (patch)
tree60eabad58e4a125b0c003c4153ebc7d915b5d90f /cloudinit/sources
parent763be4ecccca0c0ccb62466699cc9cd22f79adc7 (diff)
downloadvyos-cloud-init-cc549350c6010908add773a8b74e5d1ac840bbf1.tar.gz
vyos-cloud-init-cc549350c6010908add773a8b74e5d1ac840bbf1.zip
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
Diffstat (limited to 'cloudinit/sources')
-rw-r--r--cloudinit/sources/DataSourceNoCloud.py7
1 files changed, 6 insertions, 1 deletions
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'])