From 8ba08be9c27852aa2a40f1c6fbd497d95443eb3e Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Mon, 7 Feb 2011 11:10:40 -0500 Subject: add config option 'manual_cache_clean'. This option allows user to specify manual cleaning of the /var/lib/cloud/instance/ link, for a data source that might not be present on every boot. --- ChangeLog | 3 +++ cloud-init.py | 5 ++++- cloudinit/__init__.py | 5 +++-- doc/examples/cloud-config.txt | 10 ++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7daf418e..80bb4d12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,9 @@ - turn resize_rootfs default to True - avoid mounts in DataSourceOVF if 'read' on device fails 'mount /dev/sr0' for an empty virtual cdrom device was taking 18 seconds + - add 'manual_cache_clean' option to select manual cleaning of + the /var/lib/cloud/instance/ link, for a data source that might + not be present on every boot 0.6.0: - change permissions of /var/log/cloud-init.log to accomodate syslog writing to it (LP: #704509) diff --git a/cloud-init.py b/cloud-init.py index c9c03b3f..e8454eaa 100755 --- a/cloud-init.py +++ b/cloud-init.py @@ -93,7 +93,10 @@ def main(): # but we want 'start' to benefit from a cache if # a previous start-local populated one if cmd == "start-local": - cloudinit.purge_cache() + manclean = util.get_cfg_option_bool(cfg, 'manual_cache_clean',False) + if manclean: + log.debug("not purging cache, manual_cache_clean = True") + cloudinit.purge_cache(not manclean) cloud = cloudinit.CloudInit(ds_deps=deps[cmd]) diff --git a/cloudinit/__init__.py b/cloudinit/__init__.py index 99cc4d46..02147461 100644 --- a/cloudinit/__init__.py +++ b/cloudinit/__init__.py @@ -501,8 +501,9 @@ def initfs(): if g == "-1" or g == "None": g = None util.chownbyname(log_file, u, g) -def purge_cache(): - rmlist = ( boot_finished , cur_instance_link ) +def purge_cache(rmcur=True): + rmlist = [ boot_finished ] + if rmcur: rmlist.append(cur_instance_link) for f in rmlist: try: os.unlink(f) diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index 0a1d4279..8d47234d 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -383,3 +383,13 @@ syslog_fix_perms: syslog:root password: passw0rd chpasswd: { expire: False } ssh_pwauth: True + +# manual cache clean. +# By default, the link from /var/lib/cloud/instance to +# the specific instance in /var/lib/cloud/instances/ is removed on every +# boot. The cloud-init code then searches for a DataSource on every boot +# if your DataSource will not be present on every boot, then you can set +# this option to 'True', and maintain (remove) that link before the image +# will be booted as a new instance. +# default is False +manual_cache_clean = False -- cgit v1.2.3