summaryrefslogtreecommitdiffstats
path: root/func/minion/utils.py
diff options
context:
space:
mode:
authorSeth Vidal <skvidal@fedoraproject.org>2007-10-08 14:59:28 -0400
committerSeth Vidal <skvidal@fedoraproject.org>2007-10-08 14:59:28 -0400
commit9033fe7cc3c6a59bd90c4742a47536699dee612d (patch)
tree7464fb9f366e121d86947f2f900755d681612e14 /func/minion/utils.py
parentce379bdb3d6ade0a6326d5d7cf9446389cf4d94b (diff)
downloadfunc-9033fe7cc3c6a59bd90c4742a47536699dee612d.tar.gz
func-9033fe7cc3c6a59bd90c4742a47536699dee612d.tar.xz
func-9033fe7cc3c6a59bd90c4742a47536699dee612d.zip
fine-grained acls per minion
- adds minion-acl.conf
Diffstat (limited to 'func/minion/utils.py')
-rwxr-xr-xfunc/minion/utils.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/func/minion/utils.py b/func/minion/utils.py
index d13808e..447acc8 100755
--- a/func/minion/utils.py
+++ b/func/minion/utils.py
@@ -157,3 +157,40 @@ def daemonize(pidfile=None):
if pidfile is not None:
open(pidfile, "w").write(str(pid))
sys.exit(0)
+
+def get_acls_from_config(fn='/etc/func/minion-acl.conf'):
+ """
+ takes a fn = filename of config file
+ returns a dict of hostname+hash = [methods, to, run]
+
+ """
+
+ acls = {}
+ if not os.path.exists(fn):
+ print 'acl config file does not exist: %s' % fn
+ return acls
+ try:
+ fo = open(fn, 'r')
+ except (IOError, OSError), e:
+ print 'cannot open acl config file: %s' % e
+ return acls
+
+ for line in fo.readlines():
+ if line.startswith('#'): continue
+ if line.strip() == '': continue
+ line = line.replace('\n', '')
+ (host, methods) = line.split('=')
+ host = host.strip().lower()
+ methods = methods.strip()
+ methods = methods.replace(',',' ')
+ methods = methods.split()
+ if not acls.has_key(host):
+ acls[host] = []
+ acls[host].extend(methods)
+
+ return acls
+
+
+
+
+