diff options
-rw-r--r-- | extras/volgen/CreateVolfile.py | 110 | ||||
-rwxr-xr-x | extras/volgen/glusterfs-volgen.in | 3 |
2 files changed, 58 insertions, 55 deletions
diff --git a/extras/volgen/CreateVolfile.py b/extras/volgen/CreateVolfile.py index c9744a21da2..f243f7e9c7a 100644 --- a/extras/volgen/CreateVolfile.py +++ b/extras/volgen/CreateVolfile.py @@ -30,8 +30,6 @@ class CreateVolfile: self.volume_name = options.volume_name self.transport = transport self.transports = transports - self.gfs_port = options.port - self.gfs_ib_port = options.port + 1 self.auth_parameters = options.auth_param self.raid_type = options.raid_type self.ib_devport = options.ib_dev @@ -43,6 +41,12 @@ class CreateVolfile: self.nfs = options.need_nfs self.num_replica = options.num_replica self.num_stripe = options.num_stripe + if options.port: + self.gfs_port = options.port + self.gfs_ib_port = options.port + 1 + else: + self.gfs_port = None + self.gfs_ib_port = None def create_mount_volfile (self): @@ -67,7 +71,7 @@ class CreateVolfile: subvolumes = [] for host in self.host_dict.keys(): i = 1 - for exports in self.host_dict[host]: + for export in self.host_dict[host]: mount_fd.write ("volume %s-%s\n" % (host,i)) mount_fd.write (" type protocol/client\n") mount_fd.write (" option transport-type %s\n" % @@ -76,15 +80,15 @@ class CreateVolfile: if self.transport == 'ib-verbs': mount_fd.write (" option transport.ib-verbs.port %d\n" % self.ib_devport) - mount_fd.write (" option remote-port %d\n" % - self.gfs_ib_port) + if self.gfs_ib_port: + 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 remote-port %d\n" % - self.gfs_port) + if self.gfs_port: + mount_fd.write (" option remote-port %d\n" % self.gfs_port) - mount_fd.write (" option remote-subvolume brick%s\n" % - i) + mount_fd.write (" option remote-subvolume %s\n" % export) mount_fd.write ("end-volume\n\n") i += 1 @@ -249,20 +253,21 @@ class CreateVolfile: 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") - - print "Generating server volfiles.. for server %s as '%s'" % (self.host, - export_volfile) - - 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) - total_bricks = [] - i=1 + i = 0 for export in self.host_dict[self.host]: - exp_fd.write ("volume posix%d\n" % i) + export_volfile = "%s/%s-%d.vol" % (self.conf_dir, + str(self.host + '-' + self.volume_name), + i) + i += 1 + exp_fd = file ("%s" % (export_volfile),"w") + + print "Generating server volfiles.. for server %s as '%s'" % (self.host, + export_volfile) + + 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) + exp_fd.write ("volume posix\n") 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") @@ -274,65 +279,64 @@ class CreateVolfile: exp_fd.write ("end-volume\n\n") if self.nfs: - exp_fd.write ("volume posix-ac%d\n" % i) + exp_fd.write ("volume posix-ac\n") exp_fd.write (" type features/access-control\n") - exp_fd.write (" subvolumes posix%d\n" % i) + exp_fd.write (" subvolumes posix\n") exp_fd.write ("end-volume\n\n") if self.volume_size_server: - exp_fd.write ("volume quota%d\n" % i) + exp_fd.write ("volume quota\n") 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) + exp_fd.write (" subvolumes posix-ac\n") else: - exp_fd.write (" subvolumes posix%d\n" % i) + exp_fd.write (" subvolumes posix\n") exp_fd.write ("end-volume\n\n") - exp_fd.write ("volume locks%d\n" % i) + exp_fd.write ("volume locks\n") exp_fd.write (" type features/locks\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) + exp_fd.write (" subvolumes quota\n") + elif self.nfs: + exp_fd.write (" subvolumes posix-ac\n") else: - exp_fd.write (" subvolumes posix%d\n" % i) + exp_fd.write (" subvolumes posix\n") exp_fd.write ("end-volume\n\n") - exp_fd.write ("volume brick%d\n" % i) + exp_fd.write ("volume %s\n" % export) exp_fd.write (" type performance/io-threads\n") exp_fd.write (" option thread-count 8\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 (" subvolumes locks\n") exp_fd.write ("end-volume\n\n") - total_bricks.append("brick%s" % i) - i += 1 - - for transport in self.transports: - exp_fd.write ("volume server-%s\n" % transport) - exp_fd.write (" type protocol/server\n") - exp_fd.write (" option transport-type %s\n" % transport) - for brick in total_bricks: + for transport in self.transports: + exp_fd.write ("volume server-%s\n" % transport) + exp_fd.write (" type protocol/server\n") + exp_fd.write (" option transport-type %s\n" % transport) exp_fd.write (" option auth.addr.%s.allow %s\n" % - (brick, self.auth_parameters)) - - if transport == 'ib-verbs': - exp_fd.write (" option transport.ib-verbs.listen-port %d\n" % self.gfs_ib_port) - exp_fd.write (" option transport.ib-verbs.port %d\n" % - self.ib_devport) - if transport == 'tcp': - exp_fd.write (" option transport.socket.listen-port %d\n" % self.gfs_port) - exp_fd.write (" option transport.socket.nodelay on\n") - - exp_fd.write (" subvolumes %s\n" % - string.join(total_bricks, ' ')) - exp_fd.write ("end-volume\n\n") + (export, self.auth_parameters)) + + if transport == 'ib-verbs': + if self.gfs_ib_port: + exp_fd.write (" option listen-port %d\n" % self.gfs_ib_port) + exp_fd.write (" option transport.ib-verbs.port %d\n" % + self.ib_devport) + if transport == 'tcp': + if self.gfs_port: + exp_fd.write (" option listen-port %d\n" % self.gfs_port) + exp_fd.write (" option transport.socket.nodelay on\n") + + exp_fd.write (" subvolumes %s\n" % export) + exp_fd.write ("end-volume\n\n") return diff --git a/extras/volgen/glusterfs-volgen.in b/extras/volgen/glusterfs-volgen.in index 0b96f0d2818..3ab5aa1cdc0 100755 --- a/extras/volgen/glusterfs-volgen.in +++ b/extras/volgen/glusterfs-volgen.in @@ -45,8 +45,7 @@ def generate_volume_files (): group.add_option("-t", "--transport", dest="transport_type", default="tcp", help="tcp,ib-verbs default: tcp") group.add_option("-p", "--port", type="int", - dest="port", default=6969, - help="<port> number") + dest="port", help="<port> number") group.add_option("--auth", dest="auth_param", default="*", help="comma seperated ip range") group.add_option("-r", "--raid", type="int", dest="raid_type", |