summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorMohammed Junaid Ahmed <junaid@gluster.com>2011-02-11 01:06:55 +0000
committerAnand V. Avati <avati@dev.gluster.com>2011-02-11 08:35:42 -0800
commit7b16a08989e804e857589c8a34881140150dc11c (patch)
treef2bb0a7ec57621c5b6360c78e894a5f7d5c8de8e /xlators/features
parentd6407c59a4fd262749edd11ecb457b1e5be7a77a (diff)
syncdaemon: configinterface.py file moved under xlators/features/marker/utils/syncdaemon/ directory.
Signed-off-by: Junaid <junaid@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1570 (geosync related changes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1570
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/marker/utils/syncdaemon/Makefile.am2
-rw-r--r--xlators/features/marker/utils/syncdaemon/configinterface.py50
2 files changed, 51 insertions, 1 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/Makefile.am b/xlators/features/marker/utils/syncdaemon/Makefile.am
index 047a8cbaad7..fc1b42e7f3f 100644
--- a/xlators/features/marker/utils/syncdaemon/Makefile.am
+++ b/xlators/features/marker/utils/syncdaemon/Makefile.am
@@ -1,5 +1,5 @@
syncdaemondir = $(libexecdir)/python/syncdaemon
-syncdaemon_PYTHON = gconf.py gsyncd.py __init__.py master.py README.md repce.py resource.py
+syncdaemon_PYTHON = gconf.py gsyncd.py __init__.py master.py README.md repce.py resource.py configinterface.py
CLEANFILES =
diff --git a/xlators/features/marker/utils/syncdaemon/configinterface.py b/xlators/features/marker/utils/syncdaemon/configinterface.py
new file mode 100644
index 00000000000..7bc1d4731a7
--- /dev/null
+++ b/xlators/features/marker/utils/syncdaemon/configinterface.py
@@ -0,0 +1,50 @@
+import ConfigParser
+
+DEF_SECT = 'global'
+
+class GConffile(object):
+
+ def __init__(self, path, peers):
+ if peers:
+ self.section = 'peers ' + ' '.join(peers)
+ else:
+ self.section = DEF_SECT
+ self.path = path
+ self.config = ConfigParser.RawConfigParser({}, dict)
+ self.config.read(path)
+
+ def update_to(self, dct):
+ for sect in set([DEF_SECT, self.section]):
+ if self.config.has_section(sect):
+ dct.update(self.config._sections[sect])
+
+ def get(self, opt=None):
+ d = {}
+ self.update_to(d)
+ if opt:
+ d = {opt: d.get(opt, "")}
+ for k, v in d.iteritems():
+ if k == '__name__':
+ continue
+ print("%s: %s" % (k, v))
+
+ def write(self):
+ f = None
+ try:
+ f = open(self.path, 'wb')
+ self.config.write(f)
+ finally:
+ if f:
+ f.close()
+
+ def set(self, opt, val):
+ if not self.config.has_section(self.section):
+ self.config.add_section(self.section)
+ self.config.set(self.section, opt, val)
+ self.write()
+
+ def delete(self, opt):
+ if not self.config.has_section(self.section):
+ return
+ if self.config.remove_option(self.section, opt):
+ self.write()