summaryrefslogtreecommitdiffstats
path: root/extras/volgen/Common.py
diff options
context:
space:
mode:
authorHarshavardhana <harsha@gluster.com>2010-04-14 20:20:38 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-04-22 07:05:07 -0700
commitbf18a37a1b66ca3ac75713d39e68dde1a116f4cf (patch)
tree45ac161136890acf9bfe92acdda39f00f83f531e /extras/volgen/Common.py
parent7c7bafa3b17dcc0c799b5d42ccb5726e52c4d94f (diff)
extras/volgen: Volgen patchset
-- Supports NFS Translator. -- Consolidated common API's into Common.py. -- Removed unused CreateBooster.py. -- Added code for "--add-server" for dynamic volumes. Currently its commented out we will use it when needed. -- No more options hiding in background anymore. All options specified for each translator are commented and exposed. Only necessary values are enabled. This is done due to necessary cleanup of unwanted options by exposing them. PENDING: "replicate" translator -- Quota is disabled for native NFS on client side. Only server side quota can be used as of now. -- Additional code cleanup. Signed-off-by: Harshavardhana <harsha@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 822 (Volgen changes supporting NFS) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=822
Diffstat (limited to 'extras/volgen/Common.py')
-rw-r--r--extras/volgen/Common.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/extras/volgen/Common.py b/extras/volgen/Common.py
new file mode 100644
index 00000000000..10425096c85
--- /dev/null
+++ b/extras/volgen/Common.py
@@ -0,0 +1,80 @@
+import os, sys, re, string
+
+def check_duplicate_entry(args):
+ """Check duplicate entries in incoming arguments"""
+ _tmp = []
+ for server in args:
+ if server not in _tmp:
+ _tmp.append (server)
+ else:
+ print "Duplicate arguments detected (%s)" % server
+ raise ValueError
+
+ return
+
+def args2dict(args):
+
+ keyvalue = {}
+ for arg in args:
+ if int(arg.find(':')) == -1:
+ continue
+ first = arg.split(':')[0]
+ keyvalue[first] = []
+
+ for arg in args:
+ if int(arg.find(':')) == -1:
+ continue
+ first = arg.split(':')[0]
+ if arg.split(':')[1] not in keyvalue[first]:
+ if arg.split(':')[1][0] != '/':
+ print "Absolute export path required for %s" % arg
+ raise ValueError
+ keyvalue[first].append (arg.split(':')[1])
+
+ return keyvalue
+
+def args2array(args):
+
+ array = []
+
+ for arg in args:
+ if int(arg.find(':')) == -1:
+ continue
+ array.append(arg)
+
+ return array
+
+def list_export_vols(configdir, volumename):
+
+ list_export = []
+ if os.path.isdir(configdir):
+ for line in os.listdir(configdir):
+ if re.match(r'[a-zA-Z0-9_]\S+%s-export.vol' % volumename, line):
+ list_export.append(line)
+
+ return list_export
+
+def get_old_server_args(exports, configdir):
+
+ list_args = []
+ for export in exports:
+ array = gfParser("%s/%s" % (configdir, export))
+ for dt in array:
+ if dt.has_key('option'):
+ if re.match("\w+tory", dt['option']):
+ list_args.append(export.split('-')[0] + ":" + dt['option'].split()[1])
+
+ return list_args
+
+def gfParser (volfile):
+
+ volfile_rl = open (volfile).readlines()
+ volume_array = []
+ for line in volfile_rl:
+ line = line.strip()
+ volfile_dict = {}
+ if re.match(r"[a-zA-Z0-9_]+", line):
+ volfile_dict[line.split()[0]] = string.join (line.split()[1:], ' ') if line.split() > 1 else " "
+ volume_array.append(volfile_dict)
+
+ return volume_array