cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #00137
[Merge] lp:~smoser/cloud-init/filesem-check-canon into lp:cloud-init
Scott Moser has proposed merging lp:~smoser/cloud-init/filesem-check-canon into lp:cloud-init.
Requested reviews:
cloud init development team (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~smoser/cloud-init/filesem-check-canon/+merge/133294
--
https://code.launchpad.net/~smoser/cloud-init/filesem-check-canon/+merge/133294
Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/filesem-check-canon into lp:cloud-init.
=== modified file 'cloudinit/helpers.py'
--- cloudinit/helpers.py 2012-10-28 02:25:48 +0000
+++ cloudinit/helpers.py 2012-11-07 16:56:21 +0000
@@ -107,7 +107,7 @@
# This is a race condition since nothing atomic is happening
# here, but this should be ok due to the nature of when
# and where cloud-init runs... (file writing is not a lock...)
- sem_file = self._get_path(name, freq)
+ sem_file = self._get_path(_canon_sem_name(name), freq)
contents = "%s: %s\n" % (os.getpid(), time())
try:
util.write_file(sem_file, contents)
@@ -119,11 +119,15 @@
def has_run(self, name, freq):
if not freq or freq == PER_ALWAYS:
return False
- sem_file = self._get_path(name, freq)
+
+ # check for both the name, and canonicalized name
+ cand_list = set([self._get_path(n, freq)
+ for n in [name, _canon_sem_name(name)]])
# This isn't really a good atomic check
# but it suffices for where and when cloudinit runs
- if os.path.exists(sem_file):
- return True
+ for cand in cand_list:
+ if os.path.exists(cand):
+ return True
return False
def _get_path(self, name, freq):
@@ -426,3 +430,7 @@
if header:
contents = "\n".join([header, contents])
return contents
+
+
+def _canon_sem_name(name):
+ return(name.replace("-", "_"))
Follow ups