From ee03480e670c10d48a4825a458fac18aaf4fbec0 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 19 Jan 2011 18:35:07 +0000 Subject: initial /var/lib rework still lots to do. includes a fix for LP: #704509 LP: #704509 --- cloud-init.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'cloud-init.py') diff --git a/cloud-init.py b/cloud-init.py index 28828648..1278d2eb 100755 --- a/cloud-init.py +++ b/cloud-init.py @@ -56,6 +56,13 @@ def main(): if cmd == "start-local": source_type = "local" + if cmd == "start-local": + try: + cloudinit.initfs() + except: + warn("failed to initfs, likely bad things to come") + + cloudinit.logging_set_from_cfg_file() log = logging.getLogger() log.info(msg) @@ -74,6 +81,9 @@ def main(): sys.stderr.write("no instance data found in %s\n" % cmd) sys.exit(1) + # set this as the current instance + cloud.set_cur_instance() + # store the metadata cloud.update_cache() @@ -103,13 +113,6 @@ def main(): #print "user data is:" + cloud.get_user_data() - # set the defaults (like what ec2-set-defaults.py did) - try: - cloud.sem_and_run("set_defaults", "once-per-instance", - set_defaults,[ cloud ],False) - except: - warn("failed to set defaults\n") - # finish, send the cloud-config event cloud.initctl_emit() -- cgit v1.2.3 From 9f4a828037e76ab6636f79a30eaa56fc6fddef52 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 19 Jan 2011 18:49:40 +0000 Subject: cloud-init.py: log exception on failure to set hostname --- cloud-init.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cloud-init.py') diff --git a/cloud-init.py b/cloud-init.py index 1278d2eb..bda1ef8f 100755 --- a/cloud-init.py +++ b/cloud-init.py @@ -108,7 +108,8 @@ def main(): set_hostname, [ hostname, log ], False) cloud.sem_and_run("update_hostname", "always", update_hostname, [ hostname, log ], False) - except: + except Exception, e: + util.logexc(log) warn("failed to set hostname\n") #print "user data is:" + cloud.get_user_data() -- cgit v1.2.3 From a4edfa9ec71e901c53dc155d1ae910044a91cdf2 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 19 Jan 2011 18:54:15 +0000 Subject: improve log message on failure of initfs. run on both start-local and start --- cloud-init.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'cloud-init.py') diff --git a/cloud-init.py b/cloud-init.py index bda1ef8f..32add699 100755 --- a/cloud-init.py +++ b/cloud-init.py @@ -56,11 +56,10 @@ def main(): if cmd == "start-local": source_type = "local" - if cmd == "start-local": - try: - cloudinit.initfs() - except: - warn("failed to initfs, likely bad things to come") + try: + cloudinit.initfs() + except Exception, e: + warn("failed to initfs, likely bad things to come: %s" % str(e)) cloudinit.logging_set_from_cfg_file() -- cgit v1.2.3 From 27032a10e8c9234ee4444be206da7b568bfa872a Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 19 Jan 2011 20:27:37 +0000 Subject: write the previous-hostname file to persistent cloud/data This change just uses a different facility for coming up with the path. But, by design I'm chosing to put 'previous-hostname' in /var/lib/cloud/data/ rather than in /var/lib/cloud/instance/data/ The idea is that if the user: - started an instance - modified /etc/hostname - bundled instance (or create-image from it) - started new instance They would expect their modified /etc/hostname to persist. As such, the previous-hostname file should be cross-instance data. Bugs in this area include LP: #596993 and LP: #514492 --- cloud-init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cloud-init.py') diff --git a/cloud-init.py b/cloud-init.py index 32add699..bdfa9f01 100755 --- a/cloud-init.py +++ b/cloud-init.py @@ -146,7 +146,7 @@ def set_hostname(hostname, log): log.error("failed to set_hostname") def update_hostname(hostname, log): - prev_file="%s/%s" % (cloudinit.datadir,"previous-hostname") + prev_file="%s/%s" % (cloudinit.get_cpath('datadir'),"previous-hostname") etc_file = "/etc/hostname" hostname_prev = None -- cgit v1.2.3