From 90072a96485b15bff37e3023cea394f17ac30ae7 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Tue, 28 Nov 2006 21:35:58 +0000 Subject: [PATCH] - generate proper configuration file from slice attribute proper_op --- proper.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 proper.py diff --git a/proper.py b/proper.py new file mode 100644 index 0000000..a5ebd75 --- /dev/null +++ b/proper.py @@ -0,0 +1,41 @@ +"""Generate Proper configuration file""" + +import os +import logger + +def GetSlivers(data): + # anyone can execute the get_file_flags operation (since it is applied + # within the caller's vserver and the command lsattr gives the same + # info anyway) or get the version string. wait is harmless too since + # the caller needs to know the child ID. and we let any slice unmount + # directories in its own filesystem, mostly as a workaround for some + # Stork problems. + buf = """ +*: get_file_flags +*: version +*: wait ++: unmount +""".lstrip() + + for d in data: + for sliver in d['slivers']: + for attribute in sliver['attributes']: + if attribute['name'] == 'proper_op': + buf += "%s: %s\n" % (sliver['name'], attribute['value']) + + try: os.makedirs("/etc/proper") + except OSError: pass + propd_conf = open("/etc/proper/propd.conf", "r+") + + if propd_conf.read() != buf: + logger.log('proper: updating /etc/propd.conf') + propd_conf.seek(0) + propd_conf.write(buf) + propd_conf.truncate() + logger.log('proper: restarting proper') + os.system('/etc/init.d/proper restart') + + propd_conf.close() + +def start(options, config): + pass -- 2.43.0