diff options
Diffstat (limited to 'extras/volgen/CreateVolfile.py')
| -rw-r--r-- | extras/volgen/CreateVolfile.py | 219 | 
1 files changed, 117 insertions, 102 deletions
diff --git a/extras/volgen/CreateVolfile.py b/extras/volgen/CreateVolfile.py index 052ed987a94..ca5043a8d78 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")  | 
