aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--steuermann/run.py16
-rw-r--r--steuermann/run_all.py20
2 files changed, 25 insertions, 11 deletions
diff --git a/steuermann/run.py b/steuermann/run.py
index 73e9409..3b098da 100644
--- a/steuermann/run.py
+++ b/steuermann/run.py
@@ -68,10 +68,10 @@ class runner(object):
#####
#
- def __init__( self, nodes ) :
+ def __init__( self, nodes, hosts_ini ) :
self.all_procs = { }
self.node_index = nodes
- self.load_host_info()
+ self.load_host_info(filename = hosts_ini)
self.host_info_cache = { }
self.howmany = { }
@@ -293,14 +293,20 @@ class runner(object):
print "No config section in hosts.ini: %s"%section
return { }
- def load_host_info( self, filename=None ) :
+
+ def load_host_info( self, filename ) :
+
+ if os.path.exists(filename):
+ print 'READING HOST INFO FROM %s' %filename
+ else:
+ print 'ERROR - %s does not exist' %filename
+ sys.exit(1)
# read the config file
- if filename is None :
- filename = os.path.dirname(__file__) + '/hosts.ini'
self.cfg = ConfigParser.RawConfigParser()
self.cfg.read(filename)
+
def get_host_info(self, host) :
if not host in self.host_info_cache :
d = self._host_get_names(self.cfg, host)
diff --git a/steuermann/run_all.py b/steuermann/run_all.py
index d61f10d..28d6398 100644
--- a/steuermann/run_all.py
+++ b/steuermann/run_all.py
@@ -58,6 +58,7 @@ def main() :
'-a' : '' , # run all nodes non-interactively
'-r' : '=' , # give run name
'-n' : '' , # do not actually execute any processes
+ '-h' : '=' , # give hosts (*.ini) file
} )
#
@@ -70,17 +71,24 @@ def main() :
xnodes = di_nodes.node_index
+ # get run name
if '-r' in opt :
run_name = opt['-r']
else :
run_name = "user_%s_%s"%(username,str(datetime.datetime.now()).replace(' ','_'))
+ # get hosts (*.ini) file name
+ if '-h' in opt :
+ hosts_ini = opt['-h']
+ else :
+ hosts_ini = os.path.join(os.path.dirname(__file__), 'hosts.ini')
+
db = steuermann.config.open_db()
if all :
- run_all(xnodes, run_name, db)
+ run_all(xnodes, run_name, hosts_ini, db)
else :
- run_interactive( xnodes, run_name, db )
+ run_interactive( xnodes, run_name, hosts_ini, db )
#
@@ -182,14 +190,14 @@ report show report
"""
-def run_interactive( xnodes, run_name, db) :
+def run_interactive( xnodes, run_name, hosts_ini, db) :
org_run_name = run_name
run_count = 0
register_database(db, run_name, xnodes)
- runner = run.runner( xnodes )
+ runner = run.runner( xnodes, hosts_ini )
for x in xnodes :
xnodes[x].finished = 0
@@ -364,7 +372,7 @@ def register_database(db, run, xnodes ) :
#
-def run_all(xnodes, run_name, db) :
+def run_all(xnodes, run_name, hosts_ini, db) :
for x in xnodes :
x = xnodes[x]
@@ -375,7 +383,7 @@ def run_all(xnodes, run_name, db) :
register_database(db, run_name, xnodes)
- runner = run.runner( xnodes )
+ runner = run.runner( xnodes, hosts_ini )
none_running = 0
# will count how many times through there was nothing running