summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extras/volgen/Common.py80
-rw-r--r--extras/volgen/CreateBooster.py140
-rw-r--r--extras/volgen/CreateVolfile.py219
-rw-r--r--extras/volgen/Makefile.am2
-rwxr-xr-xextras/volgen/glusterfs-volgen.in121
5 files changed, 241 insertions, 321 deletions
diff --git a/extras/volgen/Common.py b/extras/volgen/Common.py
new file mode 100644
index 000000000..10425096c
--- /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
diff --git a/extras/volgen/CreateBooster.py b/extras/volgen/CreateBooster.py
deleted file mode 100644
index 13a72f03b..000000000
--- a/extras/volgen/CreateBooster.py
+++ /dev/null
@@ -1,140 +0,0 @@
-# Copyright (c) 2009-2010 Gluster, Inc. <http://www.gluster.com>
-# This file is part of GlusterFS.
-
-# GlusterFS is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published
-# by the Free Software Foundation; either version 3 of the License,
-# or (at your option) any later version.
-
-# GlusterFS is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see
-# <http://www.gnu.org/licenses/>.
-
-GLUSTERFS_BOOSTER_FSTAB = "booster.fstab"
-GLUSTERFS_UNFS3_EXPORTS = "boosterexports"
-GLUSTERFS_CIFS_CONFIG = "boostersmb.conf"
-LOGDIR = "/var/log/glusterfs"
-fstype = "glusterfs"
-
-class CreateBooster:
-
- def __init__ (self, options, transports):
-
- self.volume_name = options.volume_name
- self.need_nfs = options.need_nfs
- self.need_cifs = options.need_cifs
- self.username = options.cifs_username
- self.enable_guest = options.enable_guest
- self.conf_dir = options.conf_dir
- self.transports = transports
-
- def configure_booster_fstab (self):
-
- _fstab = ""
- _options = ""
- _options_log = ""
- _options_ext = ""
-
- if self.conf_dir:
- booster_fstab_fd = file ("%s/%s" % (str(self.conf_dir),
- GLUSTERFS_BOOSTER_FSTAB), "a")
- else:
- booster_fstab_fd = file (GLUSTERFS_BOOSTER_FSTAB, "a")
-
- if self.need_nfs:
- for transport in self.transports:
- if self.conf_dir:
- _fstab = "%s/%s-%s.vol %s" % (str(self.conf_dir),
- self.volume_name,
- transport,
- str("/nfs/" +
- self.volume_name))
- else:
- _fstab = "%s-%s.vol %s" % (self.volume_name,
- transport,
- str("/nfs/" +
- self.volume_name))
-
- _options = "%s" % fstype
- _options_log = "logfile=%s/%s-nfs.log" % (LOGDIR, self.volume_name)
- _options_ext = "loglevel=ERROR,attr_timeout=0"
- booster_fstab_fd.write ("%s %s %s,%s\n" %
- (_fstab,
- _options,
- _options_log,
- _options_ext))
-
- if self.need_cifs:
- for transport in self.transports:
- if self.conf_dir:
- _fstab = "%s/%s-%s.vol %s" % (self.conf_dir,
- self.volume_name,
- transport,
- str("/cifs/" +
- self.volume_name))
- else:
- _fstab = "%s-%s.vol %s" % (self.volume_name,
- transport,
- str("/cifs/" +
- self.volume_name))
-
- _options = "%s" % fstype
- _options_log = "logfile=%s/%s-cifs.log" % (LOGDIR, self.volume_name)
- _options_ext = "loglevel=ERROR,attr_timeout=0"
- booster_fstab_fd.write ("%s %s %s,%s\n" %
- (_fstab,
- _options,
- _options_log,
- _options_ext))
-
- return
-
- def configure_nfs_booster (self):
-
- if self.conf_dir:
- nfs_exports_fd = file ("%s/%s" % (str(self.conf_dir),
- GLUSTERFS_UNFS3_EXPORTS), "a")
- else:
- nfs_exports_fd = file (GLUSTERFS_UNFS3_EXPORTS, "a")
-
- nfs_exports_fd.write ("%s 0.0.0.0/0(rw,no_root_squash)\n" %
- str("/nfs/" + self.volume_name))
- return
-
- def configure_cifs_booster (self):
-
- if self.conf_dir:
- cifs_config_fd = file ("%s/%s" % (str(self.conf_dir),
- GLUSTERFS_CIFS_CONFIG), "a")
- else:
- cifs_config_fd = file (GLUSTERFS_CIFS_CONFIG, "a")
- cifs_config_fd.write ("[%s]\n" % self.volume_name)
- cifs_config_fd.write ("comment = %s volume served by Gluster\n" %
- self.volume_name)
- cifs_config_fd.write ("path = %s\n" % str("/cifs/" + self.volume_name))
-
- if self.enable_guest:
- cifs_config_fd.write ("guest ok = yes\n")
-
- cifs_config_fd.write ("public = yes\n")
- cifs_config_fd.write ("writable = yes\n")
- cifs_config_fd.write ("users = %s\n" % self.username)
- cifs_config_fd.close()
- return
-
- def configure_booster (self):
-
- self.configure_booster_fstab()
- if self.need_nfs:
- self.configure_nfs_booster()
- print "Generating booster configuration for NFS reexport"
- if self.need_cifs:
- self.configure_cifs_booster()
- print "Generating booster configuration for CIFS reexport"
-
- return
diff --git a/extras/volgen/CreateVolfile.py b/extras/volgen/CreateVolfile.py
index 052ed987a..ca5043a8d 100644
--- a/extras/volgen/CreateVolfile.py
+++ b/extras/volgen/CreateVolfile.py
@@ -16,7 +16,6 @@
# <http://www.gnu.org/licenses/>.
import os, sys, string
-import subprocess
num_replica = 2
num_stripe = 4
@@ -38,33 +37,25 @@ class CreateVolfile:
self.auth_parameters = options.auth_param
self.raid_type = options.raid_type
self.ib_devport = options.ib_dev
- self.num_servers = len (self.host_dict.keys())
self.conf_dir = options.conf_dir
self.host_array = server_array
- self.unused = options.unused
- self.debug = options.debug
+ self.enable_safe_mode = options.enable_safe_mode
self.volume_size_server = options.size_server
self.volume_size_client = options.size_client
+ self.nfs = options.need_nfs
def create_mount_volfile (self):
raid_type = self.raid_type
- if self.conf_dir:
- mount_fd = file ("%s/%s-%s.vol" % (self.conf_dir,
- str(self.volume_name),
- str(self.transport)), "w")
- else:
- mount_fd = file ("%s-%s.vol" % (str(self.volume_name),
- str(self.transport)), "w")
-
- print "Generating client volfiles.. for transport '%s'" % (self.transport)
+ mount_volfile = "%s/%s-%s.vol" % (self.conf_dir, str(self.volume_name), str(self.transport))
+ mount_fd = file ("%s" % (mount_volfile), "w")
+ print "Generating client volfiles.. '%s'" % mount_volfile
cmdline = string.join (sys.argv, ' ')
- mount_fd.write ("## file auto generated by %s (mount.vol)\n" %
- sys.argv[0])
+ mount_fd.write ("## file auto generated by %s\n" % sys.argv[0])
mount_fd.write ("# Cmd line:\n")
mount_fd.write ("# $ %s\n\n" % cmdline)
@@ -81,7 +72,6 @@ class CreateVolfile:
mount_fd.write (" type protocol/client\n")
mount_fd.write (" option transport-type %s\n" %
self.transport)
-
mount_fd.write (" option remote-host %s\n" % host)
if self.transport == 'ib-verbs':
mount_fd.write (" option transport.ib-verbs.port %d\n" %
@@ -115,9 +105,8 @@ class CreateVolfile:
while index < max_stripe_idx:
mount_fd.write ("volume stripe-%d\n" % index)
mount_fd.write (" type cluster/stripe\n")
- if self.unused:
- mount_fd.write ("# option block-size 128k\n")
- mount_fd.write ("# option use-xattr no\n")
+ mount_fd.write ("# option block-size 128k\n")
+ mount_fd.write ("# option use-xattr no\n")
mount_fd.write (" subvolumes %s %s %s %s\n" %
(subvolumes[stripe_idx],
@@ -150,6 +139,7 @@ class CreateVolfile:
while flag < index:
subvolumes.append ("stripe-%d" % flag)
flag += 1
+
if raid_type is 1:
subvolumes = []
flag = 0
@@ -160,91 +150,111 @@ class CreateVolfile:
if len (subvolumes) > 1:
mount_fd.write ("volume distribute\n")
mount_fd.write (" type cluster/distribute\n")
- if self.unused:
- mount_fd.write("# option unhashed-sticky-bit yes # Used for migrating data while adding new nodes\n")
- mount_fd.write("# option min-free-disk 5% # Minimum free disk available on the volume\n")
-
-
+ mount_fd.write ("# option unhashed-sticky-bit yes"
+ " # Used for migrating data while adding new nodes\n")
+ mount_fd.write ("# option min-free-disk 5%"
+ " # Minimum free disk available on the volume\n")
mount_fd.write (" subvolumes %s\n" %
string.join (subvolumes,' '))
mount_fd.write ("end-volume\n\n")
subvolumes[0] = "distribute"
+
+ if self.nfs:
+ mount_fd.write ("volume nfsxlator\n")
+ mount_fd.write (" type nfs/server\n")
+ mount_fd.write (" subvolumes %s\n" % subvolumes[0])
+ mount_fd.write ("# option rpc-auth.auth-unix off #Enabled by default\n")
+ mount_fd.write ("# option rpc-auth.auth-null off #Enabled by default\n")
+ mount_fd.write ("# By default all addresses are rejected until allowed.\n")
+ mount_fd.write ("# option rpc-auth.addr.reject 127.*\n")
+ mount_fd.write ("# option rpc-auth.addr.allow localhost\n")
+ mount_fd.write (" option rpc-auth.addr.%s.allow %s\n" % (subvolumes[0], self.auth_parameters))
+ mount_fd.write ("# By default insecure ports are not allowed.\n")
+ mount_fd.write ("# option rpc-auth.ports.insecure on\n")
+ mount_fd.write ("# option rpc-auth.ports.<volume>.insecure on\n")
+ mount_fd.write ("# By default all access is read-write.\n")
+ mount_fd.write ("# option nfs3.<volume>.volume-access read-only\n")
+ mount_fd.write ("# option nfs3.<volume>.volume-access read-only\n")
+ mount_fd.write ("# option nfs3.read-size 128Kb\n")
+ mount_fd.write ("# option nfs3.write-size 32Kb\n")
+ mount_fd.write ("# option nfs3.readdir-size 64Kb\n")
+ mount_fd.write ("# option nfs3.<volume>.read-size 64Kb\n")
+ mount_fd.write ("# option nfs3.<volume>.write-size 64Kb\n")
+ mount_fd.write ("# option nfs3.posix1.readdir-size 128Kb\n")
+ mount_fd.write ("end-volume\n\n")
+ return
+
if self.volume_size_client:
mount_fd.write ("volume quota\n")
mount_fd.write (" type features/quota\n")
mount_fd.write (" option disk-usage-limit %s\n" % self.volume_size_client)
- if self.unused:
- mount_fd.write ("# option minimum-free-disk-limit 10GB "
- "# minimum free disk value (default) 0\n")
- mount_fd.write ("# option refresh-interval 10\n")
+ mount_fd.write ("# option minimum-free-disk-limit 10GB\n"
+ "# minimum free disk value (default) 0\n")
+ mount_fd.write ("# option refresh-interval 10\n")
mount_fd.write (" subvolumes %s\n" % subvolumes[0])
mount_fd.write ("end-volume\n\n")
+ if self.enable_safe_mode:
+ return
- mount_fd.write ("volume writebehind\n")
- mount_fd.write (" type performance/write-behind\n")
- mount_fd.write (" option cache-size 4MB\n")
- if self.unused:
- mount_fd.write ("# option enable-trickling-writes yes # Flush final write calls when network is free\n")
- mount_fd.write ("# option enable-O_SYNC yes # Enable O_SYNC for write-behind\n")
- mount_fd.write ("# option disable-for-first-nbytes 1 # Disable first nbytes with very small initial writes\n")
- if self.volume_size_client:
- mount_fd.write (" subvolumes quota\n")
- else:
- mount_fd.write (" subvolumes %s\n" % subvolumes[0])
-
- mount_fd.write ("end-volume\n\n")
-
- mount_fd.write ("volume readahead\n")
- mount_fd.write (" type performance/read-ahead\n")
- mount_fd.write (" option page-count 4\n")
-
- if self.unused:
- mount_fd.write ("# option force-atime-update yes # force updating atimes, default off\n")
- mount_fd.write (" subvolumes writebehind\n")
- mount_fd.write ("end-volume\n\n")
-
- mount_fd.write ("volume iocache\n")
- mount_fd.write (" type performance/io-cache\n")
- mount_fd.write (" option cache-size %sMB\n" % cache_size)
- mount_fd.write (" option cache-timeout 1\n")
- if self.unused:
- mount_fd.write ("# option priority *.html:1,abc*:2 # Priority list for iocaching files\n")
- mount_fd.write (" subvolumes readahead\n")
- mount_fd.write ("end-volume\n\n")
+ self.performance_mode (subvolumes[0], mount_fd)
- mount_fd.write ("volume quickread\n")
- mount_fd.write (" type performance/quick-read\n")
- mount_fd.write (" option cache-timeout 1\n")
- mount_fd.write (" option max-file-size 64kB\n")
- mount_fd.write (" subvolumes iocache\n")
- mount_fd.write ("end-volume\n\n")
-
- mount_fd.write ("volume statprefetch\n")
- mount_fd.write (" type performance/stat-prefetch\n")
- mount_fd.write (" subvolumes quickread\n")
- mount_fd.write ("end-volume\n\n")
+ return
+ def performance_mode (self, cluster_subvolume, volfile_fd):
+ volfile_fd.write ("volume writebehind\n")
+ volfile_fd.write (" type performance/write-behind\n")
+ volfile_fd.write (" option cache-size 4MB\n")
+ volfile_fd.write ("# option enable-trickling-writes yes # Flush final write calls when network is free\n")
+ volfile_fd.write ("# option enable-O_SYNC yes # Enable O_SYNC for write-behind\n")
+ volfile_fd.write ("# option disable-for-first-nbytes 1 # Disable first nbytes with very small initial writes\n")
+ if self.volume_size_client:
+ volfile_fd.write (" subvolumes quota\n")
+ else:
+ volfile_fd.write (" subvolumes %s\n" % cluster_subvolume)
+ volfile_fd.write ("end-volume\n\n")
+
+ volfile_fd.write ("volume readahead\n")
+ volfile_fd.write (" type performance/read-ahead\n")
+ volfile_fd.write (" option page-count 4\n")
+ volfile_fd.write ("# option force-atime-update yes # force updating atimes, default off\n")
+ volfile_fd.write (" subvolumes writebehind\n")
+ volfile_fd.write ("end-volume\n\n")
+
+ volfile_fd.write ("volume iocache\n")
+ volfile_fd.write (" type performance/io-cache\n")
+ volfile_fd.write (" option cache-size %sMB\n" % cache_size)
+ volfile_fd.write (" option cache-timeout 1\n")
+ volfile_fd.write ("# option priority *.html:1,abc*:2 # Priority list for iocaching files\n")
+ volfile_fd.write (" subvolumes readahead\n")
+ volfile_fd.write ("end-volume\n\n")
+
+ volfile_fd.write ("volume quickread\n")
+ volfile_fd.write (" type performance/quick-read\n")
+ volfile_fd.write (" option cache-timeout 1\n")
+ volfile_fd.write (" option max-file-size 64kB\n")
+ volfile_fd.write (" subvolumes iocache\n")
+ volfile_fd.write ("end-volume\n\n")
+
+ volfile_fd.write ("volume statprefetch\n")
+ volfile_fd.write (" type performance/stat-prefetch\n")
+ volfile_fd.write (" subvolumes quickread\n")
+ volfile_fd.write ("end-volume\n\n")
return
def create_export_volfile (self):
cmdline = string.join (sys.argv, ' ')
+ export_volfile = "%s/%s-export.vol" % (self.conf_dir, str(self.host + '-' + self.volume_name))
+ exp_fd = file ("%s" % (export_volfile),"w")
- if self.conf_dir:
- exp_fd = file ("%s/%s-export.vol" %
- (self.conf_dir,
- str(self.host + '-' + self.volume_name)),"w")
- else:
- exp_fd = file ("%s-export.vol" %
- (str(self.host + '-' + self.volume_name)),"w")
-
- print "Generating server volfiles.. for server '%s'" % (self.host)
+ print "Generating server volfiles.. for server %s as '%s'" % (self.host,
+ export_volfile)
- exp_fd.write ("## file auto generated by %s (export.vol)\n" %
+ exp_fd.write ("## file auto generated by %s\n" %
sys.argv[0])
exp_fd.write ("# Cmd line:\n")
exp_fd.write ("# $ %s\n\n" % cmdline)
@@ -252,33 +262,39 @@ class CreateVolfile:
i=1
for export in self.host_dict[self.host]:
exp_fd.write ("volume posix%d\n" % i)
- exp_fd.write (" type storage/posix\n")
- if self.unused:
- exp_fd.write("# option o-direct enable # (default: disable) boolean type only\n")
- exp_fd.write("# option export-statfs-size no # (default: yes) boolean type only\n")
- exp_fd.write("# option mandate-attribute off # (default: on) boolean type only\n")
- exp_fd.write("# option span-devices 8 # (default: 0) integer value\n")
- exp_fd.write("# option background-unlink yes # (default: no) boolean type\n")
-
- exp_fd.write (" option directory %s\n" % export)
+ exp_fd.write (" type storage/posix\n")
+ exp_fd.write ("# option o-direct enable # (default: disable) boolean type only\n")
+ exp_fd.write ("# option export-statfs-size no # (default: yes) boolean type only\n")
+ exp_fd.write ("# option mandate-attribute off # (default: on) boolean type only\n")
+ exp_fd.write ("# option span-devices 8 # (default: 0) integer value\n")
+ exp_fd.write ("# option background-unlink yes # (default: no) boolean type\n")
+
+ exp_fd.write (" option directory %s\n" % export)
exp_fd.write ("end-volume\n\n")
+ if self.nfs:
+ exp_fd.write ("volume posix-ac%d\n" % i)
+ exp_fd.write (" type features/access-control\n")
+ exp_fd.write (" subvolumes posix%d\n" % i)
+ exp_fd.write ("end-volume\n\n")
+
if self.volume_size_server:
exp_fd.write ("volume quota%d\n" % i)
- exp_fd.write (" type features/quota\n")
- exp_fd.write (" option disk-usage-limit %s\n" % self.volume_size_server)
- if self.unused:
- exp_fd.write ("# option minimum-free-disk-limit 10GB "
- "# minimum free disk value (default) 0\n")
- exp_fd.write ("# option refresh-interval 10\n")
- exp_fd.write (" subvolumes posix%d\n" % i)
+ exp_fd.write (" type features/quota\n")
+ exp_fd.write (" option disk-usage-limit %s\n" % self.volume_size_server)
+ exp_fd.write ("# option minimum-free-disk-limit 10GB"
+ " # minimum free disk value (default) 0\n")
+ exp_fd.write ("# option refresh-interval 10\n")
+ if self.nfs:
+ exp_fd.write (" subvolumes posix-ac%d\n" % i)
+ else:
+ exp_fd.write (" subvolumes posix%d\n" % i)
exp_fd.write ("end-volume\n\n")
exp_fd.write ("volume locks%d\n" % i)
exp_fd.write (" type features/locks\n")
- if self.unused:
- exp_fd.write ("# option mandatory on # Default off, used in specific applications\n")
+ exp_fd.write ("# option mandatory on # Default off, used in specific applications\n")
if self.volume_size_server:
exp_fd.write (" subvolumes quota%d\n" % i)
else:
@@ -288,10 +304,9 @@ class CreateVolfile:
exp_fd.write ("volume brick%d\n" % i)
exp_fd.write (" type performance/io-threads\n")
exp_fd.write (" option thread-count 8\n")
- if self.unused:
- exp_fd.write ("# option autoscaling yes # Heuristic for autoscaling threads on demand\n")
- exp_fd.write ("# option min-threads 2 # min count for thread pool\n")
- exp_fd.write ("# option max-threads 64 # max count for thread pool\n")
+ exp_fd.write ("# option autoscaling yes # Heuristic for autoscaling threads on demand\n")
+ exp_fd.write ("# option min-threads 2 # min count for thread pool\n")
+ exp_fd.write ("# option max-threads 64 # max count for thread pool\n")
exp_fd.write (" subvolumes locks%d\n" % i)
exp_fd.write ("end-volume\n\n")
diff --git a/extras/volgen/Makefile.am b/extras/volgen/Makefile.am
index 73b62356e..e36bd159b 100644
--- a/extras/volgen/Makefile.am
+++ b/extras/volgen/Makefile.am
@@ -1,6 +1,6 @@
volgendir = $(datadir)/glusterfs
-dist_volgen_DATA = CreateVolfile.py CreateBooster.py
+dist_volgen_DATA = CreateVolfile.py Common.py
dist_bin_SCRIPTS = glusterfs-volgen
diff --git a/extras/volgen/glusterfs-volgen.in b/extras/volgen/glusterfs-volgen.in
index 4fc28f6af..d36a5b668 100755
--- a/extras/volgen/glusterfs-volgen.in
+++ b/extras/volgen/glusterfs-volgen.in
@@ -27,51 +27,7 @@ if not (prefix + "/share/glusterfs") in sys.path:
sys.path.append(prefix + "/share/glusterfs")
from CreateVolfile import *
-from CreateBooster import *
-
-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
+from Common import *
def generate_volume_files ():
@@ -93,48 +49,39 @@ def generate_volume_files ():
group.add_option("-p", "--port", type="int",
dest="port", default=6996,
help="<port> number")
- group.add_option("-a", "--auth", dest="auth_param", default="*",
+ group.add_option("--auth", dest="auth_param", default="*",
help="comma seperated ip range")
group.add_option("-r", "--raid", type="int", dest="raid_type",
help="0|1")
+ group.add_option("-c", "--conf-dir", dest="conf_dir",
+ default=os.getcwd(),
+ help="output directory for volume files")
group.add_option("--nfs", action="store_true", dest="need_nfs",
- default=False, help="booster nfs reexport")
- group.add_option("--cifs", action="store_true", dest="need_cifs",
- default=False, help="booster cifs reexport")
- parse.add_option_group(group)
-
- # CIFS option list
- group = OptionGroup(parse, "CIFS Options")
- group.add_option("--username", dest="cifs_username",
- default="gluster", help="<cifs_username>")
- group.add_option("--guest", action="store_true",
- dest="enable_guest", default=False,
- help="enable guest access")
+ default=False, help="enable nfs translator")
parse.add_option_group(group)
- # NFS option list
# Advanced option list
group = OptionGroup(parse, "Advanced Options")
group.add_option("--ibdev", type="int", dest="ib_dev",
default=1, help="Infiniband device number <N>")
- group.add_option("-c", "--conf-dir", dest="conf_dir",
- help="output directory for volume files")
group.add_option("--volume-size-server", dest="size_server",
help="volume size for each server")
group.add_option("--volume-size-client", dest="size_client",
help="volume size for each client")
+ group.add_option("--safe-mode", action="store_true",
+ dest="enable_safe_mode", default=False,
+ help="generate volume files in safe mode")
parse.add_option_group(group)
- group = OptionGroup(parse, "Extra Options")
- group.add_option("--unused", action="store_true",
- dest="unused", default=False,
- help="enable unused options")
- group.add_option("--debug", action="store_true",
- dest="debug", default=False,
- help="add all debug modules to volumes")
+ # Changes for Dynamic Volume Manager
+ #group = OptionGroup(parse, "Dynamic Volume Options")
+ #group.add_option("--add-server", dest="add_server_args",
+ # help="Add server to existing volume")
+ #group.add_option("--migrate", dest="migrate_server_args",
+ # help="Migrate servers from existing volumes")
- parse.add_option_group(group)
+ #parse.add_option_group(group)
(options, args) = parse.parse_args()
@@ -142,6 +89,10 @@ def generate_volume_files ():
print "Error: volume name is mandatory, please provide volume name"
raise ValueError
+ if options.need_nfs and options.size_client:
+ print "Error: Currently quota not supported with native NFS, please use server side instead"
+ raise ValueError
+
if options.transport_type:
transports = options.transport_type.split(',')
for transport in transports:
@@ -155,13 +106,33 @@ def generate_volume_files ():
print "Error: --raid: option " + str(options.raid_type) + " is not valid raid type"
raise ValueError
-
- check_duplicate_entry(args)
+ if options.conf_dir:
+ if not os.path.isdir(options.conf_dir):
+ print "Specified directory %s doesn't exist" % options.conf_dir
+ raise ValueError
server_dict = {}
- server_dict = args2dict(args)
+ # Dynamic Volume Manager
+ #if options.add_server_args:
+ # add_server_list = (options.add_server_args).strip().split()
+ # check_duplicate_entry(add_server_list)
+ # old_server_list = get_old_server_args(list_export_vols(options.conf_dir,
+ # options.volume_name),
+ # options.conf_dir)
+ # for new_server in add_server_list:
+ # old_server_list.append(new_server)
+
+ # server_dict = args2dict(old_server_list)
+ # server_array = args2array(old_server_list)
+ # if len (server_dict.keys()) == 0:
+ # print "Error: no servers provided, please provide atleast one server"
+ # raise ValueError
+
+ #else:
+ check_duplicate_entry(args)
+ server_dict = args2dict(args)
server_array = args2array(args)
if len (server_dict.keys()) == 0:
@@ -199,12 +170,6 @@ def generate_volume_files ():
print "Got %s creating client volfiles for transport '%s'" % (strerror, transport)
- create_booster = CreateBooster (options, transports)
- try:
- create_booster.configure_booster ()
- except IOError, (errno, strerror):
- print "Got %s creating booster configuration" % (strerror)
-
def main ():
try: