summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-05-26 21:54:33 -0400
committerScott Moser <smoser@ubuntu.com>2016-05-26 21:54:33 -0400
commit3ce4cebd417043e1d0a3bb387998f9b71bb76e03 (patch)
treea5cd944d15b8440b5bea1cc248377289c5e77ad4 /cloudinit
parentf63f16c31be4f3b993a671e95b74550150f5715f (diff)
downloadvyos-cloud-init-3ce4cebd417043e1d0a3bb387998f9b71bb76e03.tar.gz
vyos-cloud-init-3ce4cebd417043e1d0a3bb387998f9b71bb76e03.zip
fix is_new_instance() to work better
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/stages.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
index e34662b1..20c334b7 100644
--- a/cloudinit/stages.py
+++ b/cloudinit/stages.py
@@ -52,6 +52,7 @@ from cloudinit import util
LOG = logging.getLogger(__name__)
NULL_DATA_SOURCE = None
+NO_PREVIOUS_INSTANCE_ID = "NO_PREVIOUS_INSTANCE_ID"
class Init(object):
@@ -68,6 +69,8 @@ class Init(object):
self.datasource = NULL_DATA_SOURCE
self.ds_restored = False
self._previous_iid = None
+ # simply ensure this gets set
+ self.previous_iid()
if reporter is None:
reporter = events.ReportEventStack(
@@ -345,11 +348,15 @@ class Init(object):
try:
self._previous_iid = util.load_file(iid_fn).strip()
except Exception:
+ self._previous_iid = NO_PREVIOUS_INSTANCE_ID
pass
return self._previous_iid
def is_new_instance(self):
- return self.datasource.get_instance_id() != self.previous_iid()
+ previous = self.previous_iid()
+ ret = (previous == NO_PREVIOUS_INSTANCE_ID or
+ previous != self.datasource.get_instance_id())
+ return ret
def fetch(self, existing="check"):
return self._get_data_source(existing=existing)