diff options
author | Amar Tumballi <amar@gluster.com> | 2010-07-19 06:09:57 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-07-19 05:11:13 -0700 |
commit | ddd614192d05c767012fccedb73b30cef5bf4927 (patch) | |
tree | fd34d48b166723686c5239536766cfc1b0836cff /extras/volgen/glusterfs-volgen.in | |
parent | 8f8739ea6709128f1a01ad26f677e8da12e0c726 (diff) |
volgen now takes 'num-replica' and 'num-stripe' options
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 1155 (currently volgen doesn't take num-replica and num-stripe options)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1155
Diffstat (limited to 'extras/volgen/glusterfs-volgen.in')
-rwxr-xr-x | extras/volgen/glusterfs-volgen.in | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/extras/volgen/glusterfs-volgen.in b/extras/volgen/glusterfs-volgen.in index a8e157e2e7d..0b96f0d2818 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 |