summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2011-02-07 11:10:40 -0500
committerScott Moser <smoser@ubuntu.com>2011-02-07 11:10:40 -0500
commit8ba08be9c27852aa2a40f1c6fbd497d95443eb3e (patch)
tree969f678e6374d00c1f943228589242f074119fae
parent7077e1481ee22d99126ceb011b8819bd1a23487c (diff)
downloadvyos-cloud-init-8ba08be9c27852aa2a40f1c6fbd497d95443eb3e.tar.gz
vyos-cloud-init-8ba08be9c27852aa2a40f1c6fbd497d95443eb3e.zip
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.
-rw-r--r--ChangeLog3
-rwxr-xr-xcloud-init.py5
-rw-r--r--cloudinit/__init__.py5
-rw-r--r--doc/examples/cloud-config.txt10
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