summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-08-31 15:44:50 -0400
committerScott Moser <smoser@ubuntu.com>2012-08-31 15:44:50 -0400
commit27118e7406237510ca56e969aa1b6d9152c8afbf (patch)
tree781517557785592eb8dbe40fd52a0752af774ced /cloudinit/util.py
parentc6e4c646287e26d15b8d2402527e1f77e21113cd (diff)
parentff60020fa3d8e457cf9d1d543af9193376bf598c (diff)
downloadvyos-cloud-init-27118e7406237510ca56e969aa1b6d9152c8afbf.tar.gz
vyos-cloud-init-27118e7406237510ca56e969aa1b6d9152c8afbf.zip
support launch index specific user-data
EC2 and openstack provide 'launch_index' in their metadata. This allows the user to specify cloud-config or multipart mime data that includes the 'Launch-Index' header. If launch index is available in the metadata service, then: * any part that contains a launch index other than the current launch-index of this instance will be ignored. * any part that does not contain a launch index will be considered as for this instance. If there is no such header, or launch_index is not available in the metadata service, then no such filtering will be done. LP: #1023177
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 6872cc31..33da73eb 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -1285,12 +1285,15 @@ def ensure_file(path, mode=0644):
write_file(path, content='', omode="ab", mode=mode)
-def chmod(path, mode):
- real_mode = None
+def safe_int(possible_int):
try:
- real_mode = int(mode)
+ return int(possible_int)
except (ValueError, TypeError):
- pass
+ return None
+
+
+def chmod(path, mode):
+ real_mode = safe_int(mode)
if path and real_mode:
with SeLinuxGuard(path):
os.chmod(path, real_mode)