summaryrefslogtreecommitdiffstats
path: root/extras/volgen/CreateBooster.py
diff options
context:
space:
mode:
authorHarshavardhana Ranganath <harsha@gluster.com>2009-11-26 12:08:44 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-11-26 11:29:54 -0800
commit03949adaf0c7fcfe10f31a802723613b357ec191 (patch)
tree8f0f6d93f68fbf94f1c665e1835f3ae6ae5a91ea /extras/volgen/CreateBooster.py
parent9b2159c6111cff889c543fdaf7628fce03e50154 (diff)
Volgen rewritten using option parser and added proper support for booster.
Signed-off-by: Harshavardhana <harsha@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 411 (Rewrite volgen using option parser and extend cifs/nfs support) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=411
Diffstat (limited to 'extras/volgen/CreateBooster.py')
-rw-r--r--extras/volgen/CreateBooster.py67
1 files changed, 44 insertions, 23 deletions
diff --git a/extras/volgen/CreateBooster.py b/extras/volgen/CreateBooster.py
index 9051f44017f..3f56db34d3e 100644
--- a/extras/volgen/CreateBooster.py
+++ b/extras/volgen/CreateBooster.py
@@ -7,50 +7,71 @@ fstype = "glusterfs"
class CreateBooster:
- def __init__ (self, main_name, export_dir):
+ def __init__ (self, options):
- self.volume_name = main_name
- self.export = export_dir
+ 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
def configure_booster_fstab (self):
- if self.volume_name is None or self.export is None:
- sys.exit(1)
booster_fstab_fd = file (GLUSTERFS_BOOSTER_FSTAB, "a")
- _fstab = "%s/%s.vol %s" % (CONFDIR, self.volume_name, self.export)
- _options = "%s subvolume=io-cache" % fstype
- _options_log = "logfile=%s/%s.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_nfs:
+ _fstab = "%s/%s.vol %s" % (CONFDIR, self.volume_name, 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:
+ _fstab = "%s/%s.vol %s" % (CONFDIR, self.volume_name, 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.volume_name is None or self.export is None:
- sys.exit(1)
nfs_exports_fd = file (GLUSTERFS_UNFS3_EXPORTS, "a")
nfs_exports_fd.write ("%s 0.0.0.0/0(rw,no_root_squash)\n" %
- self.export)
+ str("/nfs/" + self.volume_name))
return
def configure_cifs_booster (self):
- if self.volume_name is None or self.export is None:
- sys.exit(1)
-
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" % self.export)
- cifs_config_fd.write ("guest ok = yes\n")
+ 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 ("admin users = gluster\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