diff options
author | James Meyer <james.meyer@operamail.com> | 2012-09-02 01:07:56 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2012-09-02 01:07:56 (GMT) |
commit | e98d93babfa1fc1d248e2433e566329fe5a92ff0 (patch) | |
tree | 1b2c65e2850424f2e545d02902c50689ab4d6f62 /abs/core/LinHES-config/mv_misc.py | |
parent | 9aa30f297ad0cb6dbc9c9b2f1bcc1c89ff0a5db6 (diff) | |
download | linhes_pkgbuild-e98d93babfa1fc1d248e2433e566329fe5a92ff0.zip linhes_pkgbuild-e98d93babfa1fc1d248e2433e566329fe5a92ff0.tar.gz linhes_pkgbuild-e98d93babfa1fc1d248e2433e566329fe5a92ff0.tar.bz2 |
LinHES-config: moved config of file shares to it's own modules.
Diffstat (limited to 'abs/core/LinHES-config/mv_misc.py')
-rwxr-xr-x | abs/core/LinHES-config/mv_misc.py | 96 |
1 files changed, 1 insertions, 95 deletions
diff --git a/abs/core/LinHES-config/mv_misc.py b/abs/core/LinHES-config/mv_misc.py index 587295f..d03bdca 100755 --- a/abs/core/LinHES-config/mv_misc.py +++ b/abs/core/LinHES-config/mv_misc.py @@ -56,37 +56,7 @@ def setup_tz(timezone,TEMPLATES): #mv_common.cp_and_log(TEMPLATES+"/rc.conf","/etc/rc.conf") logging.info("__End of timezone\n") -def setup_nfs(systemconfig): - nfslist=[] - logging.info("____Start of setup_nfs____") - scrubnfs(systemconfig.get("TEMPLATES")) - - if systemconfig.get("HaveCentralNFS") == "yes": - logging.debug(" Using a Central NFS server") - if systemconfig.get("NFSserver") == "file:nfsmap": - #if it's a file check for it, failure results in downloading attempt from MBE - nfsmap_file=data_config.MYTHHOME+"/templates/nfsmap" - if not os.path.exists(nfsmap_file): - logging.debug(" Couldn't find local %s",nfsmap_file) - logging.info(" Trying to download nfsmap from MBE") - nfsmap_file = download_nfsmap(systemconfig.get("dbhost")) - nfslist = process_nfsmap_file(nfsmap_file) - # if it's an ip parse ip and download file - elif re.search(systemconfig.get("NFSserver"),":nfsmap"): - ip=systemconfig.get("NFSserver").split(":")[0] - nfsmap_file = download_nfsmap(ip) - nfslist = process_nfsmap_file(nfsmap_file) - #else treat it as a single mount point - else: - item = (systemconfig.get("NFSserver") , systemconfig["NFSmount"]) - nfslist.append(item) - else: - #if standalone or slave try to use MBE - if systemconfig.get("SystemType") == "Frontend_only" or systemconfig["SystemType"] == "Slave_Backend": - item = (systemconfig.get("dbhost")+":"+ data_config.DATAMOUNT, data_config.DATAMOUNT) - nfslist.append(item) - setup_nfs_fstab(nfslist) - logging.info("__End of nfs\n") + def setup_sleep(systemconfig): logging.debug("____Setting up sleep____") @@ -115,67 +85,3 @@ def setup_sleep(systemconfig): logging.debug("__End of sleep\n") -def process_nfsmap_file(mapfile): - logging.debug(" processing nfsmap file %s",mapfile) - nfslist = [] - try: - f = open(mapfile,"r") - for line in f.readlines(): - if line.startswith("#"): - continue - item = line.split() - if len(item) <= 1 : - continue - logging.debug(" %s",item) - nfslist.append(item) - except : - logging.critical("Couldn't read file %s, or some other error",mapfile) - return nfslist - -def scrubnfs(templates): - logging.info(" Scrubbing nfs") - mv_common.cp_and_log("/etc/fstab",templates+"/fstab.conf.template") - #used this sed cmd because it's clean and took me forever to figure out =) - cmd='''sed '/^#STARTSCRUB.*$/,/^#ENDSCRUB.*$/d' %s/fstab.conf.template > /etc/fstab''' %templates - mv_common.runcmd(cmd) - -def download_nfsmap(ip): - nfsmap_file="/tmp/nfsmap" - myurl="http://%s:1337/templates/nfsmap" %ip - req = Request(myurl) - try: - f = urlopen(req) - logging.info(" downloading %s", myurl) - local_file = open(nfsmap_file, "w") - #Write to our local file - local_file.write(f.read()) - local_file.close() - #handle errors - except HTTPError, e: - logging.info(" File download failed") - logging.debug(" %s", myurl) - logging.debug(" HTTP Error: %s", e.code) - except URLError, e: - logging.info(" File download failed") - logging.debug(" %s",myurl) - logging.debug(" URL Error: %s ", e.reason) - - return nfsmap_file - -def setup_nfs_fstab(nfslist): - logging.info(" Adding nfs paths to fstab") - try: - f = open('/etc/fstab', 'a') - line = "#STARTSCRUB --------------anything in this block will be scrubbed\n" - f.write(line) - for s, m in nfslist: - line = "%s %s nfs \n" %(s,m) - logging.debug(" %s",line) - f.write(line) - line = "#ENDSCRUB\n" - f.write(line) - f.close() - except: - logging.critical(" *Couldn't open /etc/fstab for writing") - logging.debug(" Done adding nfs paths to fstab") - |