Commits

Anonymous committed e626079

Initial import of scripts

Comments (0)

Files changed (4)

create_drbl_hostlist.py

+#!/usr/bin/python
+"""
+Convert the DRBL hostlist file into a format readable by SGE.
+
+Padraig Kitterick <info@padraigkitterick.com>
+"""
+import os
+import sys
+
+if len(sys.argv) < 2:
+    sys.exit("Please specify an output filename for the host list...")
+
+output = sys.argv[1]
+
+fp_hosts = open('/etc/drbl/IP_HOST_TABLE','r')
+
+hosts = []
+try:
+    for line in fp_hosts:
+        if not line.startswith('#'):
+            ip,host = line.strip().split()
+            hosts.append("%s\n" % host)
+finally:
+    fp_hosts.close()
+
+fp_output = open(output,'w')
+fp_output.writelines(hosts)
+fp_output.close()

create_sge_nodeconfig.py

+#!/usr/bin/python
+"""
+Create SGE node configurations based on a template config
+file, which can created using the command:
+
+    qconf -sconf hostname > node.conf.template
+    
+for some valid hostname.
+
+Padraig Kitterick <info@padraigkitterick.com>
+"""
+import subprocess
+import os
+import sys
+
+if len(sys.argv) < 2:
+    sys.exit("Please specify a template configuration file for the nodes...")
+
+sgepath = '/opt/n1ge6'
+template = sys.argv[1]
+
+fp_hosts = open('/etc/drbl/IP_HOST_TABLE','r')
+
+os.chdir(sgepath)
+try:
+    for line in fp_hosts:
+        if not line.startswith('#'):
+            ip,host = line.strip().split()
+            hostconf = "%s/%s" % (sgepath,host)
+            os.rename(template,hostconf)
+            subprocess.call(['/opt/n1ge6/bin/lx24-x86/qconf','-Aconf',host])
+            os.rename(hostconf,template)
+finally:
+    fp_hosts.close()

create_sge_nodequeues.py

+#!/usr/bin/python
+"""
+Create SGE queues for each node based on a template
+config file, which can be created with:
+
+    qconf -sq all.q > node.queue.template
+
+The template should be modified to insert the string
+"%HOST%" wherever the node hostname should be inserted.
+
+Padraig Kitterick <info@padraigkitterick.com>
+"""
+import subprocess
+import os
+import sys
+
+if len(sys.argv) < 2:
+    sys.exit("Please specify a template configuration file for the node queues...")
+
+sgepath = '/opt/n1ge6'
+
+template = sys.argv[1]
+fp_template = open(template,'r')
+templ_orig = fp_template.read()
+fp_template.close()
+
+fp_hosts = open('/etc/drbl/IP_HOST_TABLE','r')
+
+os.chdir(sgepath)
+try:
+    for line in fp_hosts:
+        if not line.startswith('#'):
+            ip,host = line.strip().split()
+            this_templ = templ_orig.replace('%HOST%',host)
+            tmpfile = "%s/%s" % (sgepath,host)
+            fp_tmp = open(tmpfile,'w')
+            fp_tmp.write(this_templ)
+            fp_tmp.close()
+            subprocess.call(['/opt/n1ge6/bin/lx24-x86/qconf','-Aq',tmpfile])
+            os.remove(tmpfile)
+finally:
+    fp_hosts.close()

update_sge_nodequeues.py

+#!/usr/bin/python
+"""
+Modify existing SGE queue configurations for each node based
+on a template config file, generated with the command:
+
+    qconf -sq all.q > node.queue.template
+
+The template should be modified to insert the string
+"%HOST%" wherever the node hostname should be inserted.
+
+Padraig Kitterick <info@padraigkitterick.com>
+"""
+import subprocess
+import os
+import sys
+
+if len(sys.argv) < 2:
+    sys.exit("Please specify a template configuration file for the node queues...")
+
+sgepath = '/opt/n1ge6'
+
+template = sys.argv[1]
+fp_template = open(template,'r')
+templ_orig = fp_template.read()
+fp_template.close()
+
+fp_hosts = open('/etc/drbl/IP_HOST_TABLE','r')
+
+os.chdir(sgepath)
+try:
+    for line in fp_hosts:
+        if not line.startswith('#'):
+            ip,host = line.strip().split()
+            this_templ = templ_orig.replace('%HOST%',host)
+            tmpfile = "%s/%s" % (sgepath,host)
+            fp_tmp = open(tmpfile,'w')
+            fp_tmp.write(this_templ)
+            fp_tmp.close()
+            subprocess.call(['/opt/n1ge6/bin/lx24-x86/qconf','-Mq',tmpfile])
+            os.remove(tmpfile)
+finally:
+    fp_hosts.close()