summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-11 20:11:44 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-11 20:11:44 -0700
commit1f120980a3217289f4bad02b813053664732e4bf (patch)
treebc462f3196962dec334226707856f1a89895d2a8 /cloudinit
parent08fa7fc2fb32764eac25fba9d83f61ce1243aa7b (diff)
downloadvyos-cloud-init-1f120980a3217289f4bad02b813053664732e4bf.tar.gz
vyos-cloud-init-1f120980a3217289f4bad02b813053664732e4bf.zip
Rename sem class to file sem class, add clear_all methods, add empty methods to dummy sem class.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/helpers.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/cloudinit/helpers.py b/cloudinit/helpers.py
index 16548001..e5f33a26 100644
--- a/cloudinit/helpers.py
+++ b/cloudinit/helpers.py
@@ -49,8 +49,14 @@ class DummySemaphores(object):
def has_run(self, _name, _freq):
return False
+ def clear(self, _name, _freq):
+ return True
+
+ def clear_all(self):
+ pass
+
-class Semaphores(object):
+class FileSemaphores(object):
def __init__(self, sem_path):
self.sem_path = sem_path
@@ -71,6 +77,12 @@ class Semaphores(object):
return False
return True
+ def clear_all(self):
+ try:
+ util.del_dir(self.sem_path)
+ except (IOError, OSError):
+ pass
+
def _acquire(self, name, freq):
if self.has_run(name, freq):
return None
@@ -117,7 +129,7 @@ class Runners(object):
if not sem_path:
return None
if sem_path not in self.sems:
- self.sems[sem_path] = Semaphores(sem_path)
+ self.sems[sem_path] = FileSemaphores(sem_path)
return self.sems[sem_path]
def run(self, name, functor, args, freq=None, clear_on_fail=False):