diff options
Diffstat (limited to 'extras')
-rw-r--r-- | extras/volgen/CreateVolfile.py | 40 | ||||
-rwxr-xr-x | extras/volgen/glusterfs-volgen.in | 26 |
2 files changed, 40 insertions, 26 deletions
diff --git a/extras/volgen/CreateVolfile.py b/extras/volgen/CreateVolfile.py index 378766cf7..c9744a21d 100644 --- a/extras/volgen/CreateVolfile.py +++ b/extras/volgen/CreateVolfile.py @@ -17,8 +17,6 @@ import os, sys, string -num_replica = 2 -num_stripe = 4 #Cachesize calculator cache_size = "`echo $(( $(grep 'MemTotal' /proc/meminfo | sed 's/[^0-9]//g') / 5120 ))`" @@ -43,6 +41,8 @@ class CreateVolfile: self.volume_size_server = options.size_server self.volume_size_client = options.size_client self.nfs = options.need_nfs + self.num_replica = options.num_replica + self.num_stripe = options.num_stripe def create_mount_volfile (self): @@ -76,11 +76,11 @@ class CreateVolfile: if self.transport == 'ib-verbs': mount_fd.write (" option transport.ib-verbs.port %d\n" % self.ib_devport) - mount_fd.write (" option transport.remote-port %d\n" % + mount_fd.write (" option remote-port %d\n" % self.gfs_ib_port) if self.transport == 'tcp': mount_fd.write (" option transport.socket.nodelay on\n") - mount_fd.write (" option transport.remote-port %d\n" % + mount_fd.write (" option remote-port %d\n" % self.gfs_port) mount_fd.write (" option remote-subvolume brick%s\n" % @@ -99,7 +99,7 @@ class CreateVolfile: # Stripe section.. if given if raid_type is 0: - max_stripe_idx = len (subvolumes) / num_stripe + max_stripe_idx = len (subvolumes) / self.num_stripe stripe_idx = 0 index = 0 while index < max_stripe_idx: @@ -107,29 +107,30 @@ class CreateVolfile: mount_fd.write (" type cluster/stripe\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], - subvolumes[stripe_idx+1], - subvolumes[stripe_idx+2], - subvolumes[stripe_idx+3])) - mount_fd.write ("end-volume\n\n") - stripe_idx += 4 + mount_fd.write (" subvolumes %s" % subvolumes[stripe_idx]) + sub_idx = 1 + while sub_idx < self.num_stripe: + mount_fd.write (" %s" % subvolumes[stripe_idx+sub_idx]) + sub_idx += 1 + mount_fd.write ("\nend-volume\n\n") + stripe_idx += self.num_stripe index +=1 # Replicate section if raid_type is 1: - max_mirror_idx = len (subvolumes) / num_replica + max_mirror_idx = len (subvolumes) / self.num_replica mirror_idx = 0 index = 0 while index < max_mirror_idx: mount_fd.write ("volume mirror-%d\n" % index) mount_fd.write (" type cluster/replicate\n") - mount_fd.write (" subvolumes %s %s\n" % - (subvolumes[mirror_idx], - subvolumes[mirror_idx+1])) - mount_fd.write ("end-volume\n\n") - mirror_idx += 2 + mount_fd.write (" subvolumes %s" % subvolumes[mirror_idx]) + sub_idx = 1 + while sub_idx < self.num_replica: + mount_fd.write (" %s" % subvolumes[mirror_idx + sub_idx]) + sub_idx += 1 + mount_fd.write ("\nend-volume\n\n") + mirror_idx += self.num_replica index += 1 # Distribute section @@ -270,7 +271,6 @@ class CreateVolfile: exp_fd.write ("# option background-unlink yes # (default: no) boolean type\n") exp_fd.write (" option directory %s\n" % export) - exp_fd.write (" option hostname %s\n" % host) exp_fd.write ("end-volume\n\n") if self.nfs: diff --git a/extras/volgen/glusterfs-volgen.in b/extras/volgen/glusterfs-volgen.in index a8e157e2e..0b96f0d28 100755 --- a/extras/volgen/glusterfs-volgen.in +++ b/extras/volgen/glusterfs-volgen.in @@ -31,10 +31,8 @@ from Common import * def generate_volume_files (): - num_stripe = 4 - num_replica = 2 - - usage_str = "%prog: -n <VOLUMENAME> -t <TRANSPORT> -p <NUMBER> -a <AUTH> -r <TYPE>" + usage_str = "%s%s" % ("%prog: -n <VOLUMENAME> -t <TRANSPORT> -p <NUMBER> -a <AUTH> ", + "-r <TYPE> [--num-replica N] [--num-stripe N]") version_str = "%prog 3.0" desc_str = "A tool to generate volume files for GlusterFS." @@ -71,6 +69,10 @@ def generate_volume_files (): group.add_option("--safe-mode", action="store_true", dest="enable_safe_mode", default=False, help="generate volume files in safe mode") + group.add_option("--num-replica", type="int", dest="num_replica", + help="number of file replica needed") + group.add_option("--num-stripe", type="int", dest="num_stripe", + help="number of stripe count needed") parse.add_option_group(group) @@ -139,14 +141,26 @@ def generate_volume_files (): print "Error: no servers provided, please provide atleast one server" raise ValueError + if options.num_replica is None: + options.num_replica = 2 + + if options.num_stripe is None: + options.num_stripe = 4 + + if options.num_replica < 2: + print "--num-replica option (%d) is not valid" % options.num_replica + + if options.num_stripe < 2: + print "--num-stripe option (%d) is not valid" % options.num_stripe + if options.raid_type == 1: - if (len(server_array) % num_replica) != 0: + if (len(server_array) % options.num_replica) != 0: print "raid type (%d) and number of volumes (%d) invalid" % (options.raid_type, len(server_array)) raise ValueError if options.raid_type == 0: - if (len(server_array) % num_stripe) != 0: + if (len(server_array) % options.num_stripe) != 0: print "raid type (%d) and number of volumes (%d) invalid" % (options.raid_type, len(server_array)) raise ValueError |