]> mj.ucw.cz Git - bex.git/commitdiff
Host names are configurable
authorMartin Mares <mj@ucw.cz>
Mon, 31 Oct 2011 10:41:18 +0000 (11:41 +0100)
committerMartin Mares <mj@ucw.cz>
Mon, 31 Oct 2011 10:41:18 +0000 (11:41 +0100)
BEX.cf
TODO
brun
lib/BEX/Config.pm

diff --git a/BEX.cf b/BEX.cf
index f7499114ded3d93b25f08c112f4418944e1f8ef8..09c1b1ba4c13aeebdce867ce6db603429b94be20 100644 (file)
--- a/BEX.cf
+++ b/BEX.cf
@@ -4,7 +4,7 @@
 package BEX::Config;
 
 %machines = (
-       'albireo' => {},
+       'albireo' => { 'Host' => 'albireo.burrow.ucw.cz' },
        'localhost' => {},
        'home' => ['albireo', 'localhost'],
 );
diff --git a/TODO b/TODO
index 6b146e7b1551f4ddca487625a52640b21f33fb29..b1b2a01b7d232a96f2421a38bd4fb8c0a1a68b7e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -10,4 +10,4 @@
 - ssh options
 - Detector of orphans (unused queue dirs, jobs on non-existent machines, non-queued jobs)
 - job failed => give a more explanatory message
-- configurable hostnames of hosts
+- configurable ping
diff --git a/brun b/brun
index 767eefb7038644a242e20897ea640e29cb34ee01..b22d5b656f8e819c2e7f882f3322a56a02e9f67e 100755 (executable)
--- a/brun
+++ b/brun
@@ -45,13 +45,15 @@ sub update_status($$$$;$) {
 sub ping_machine($) {
        my ($mach) = @_;
        update_status($mach, '-', 'PING', undef);
-       `ping -c1 -n $mach >/dev/null 2>/dev/null`;
+       my $host = BEX::Config::host_name($mach);
+       `ping -c1 -n $host >/dev/null 2>/dev/null`;
        return !$?;
 }
 
 sub run_job($$$) {
        my ($job, $queue, $mach) = @_;
        my $jid = $job->{'ID'};
+       my $host = BEX::Config::host_name($mach);
 
        my $tmp = $queue->temp_file($mach, $jid);
        open T, '>', $tmp or die;
@@ -73,13 +75,13 @@ sub run_job($$$) {
 
        update_status($mach, $jid, 'SEND', undef);
        my $cmd = 't=$(mktemp -t bex-XXXXXXXX) && cat >$t && chmod u+x $t && echo $t';
-       my $rtmp = `ssh <$tmp $mach '$cmd'`;
+       my $rtmp = `ssh <$tmp $host '$cmd'`;
        !$? && defined($rtmp) && $rtmp ne '' or return ('NOXFER', 'Transfer failed');
        chomp $rtmp;
 
        update_status($mach, $jid, 'RUN', $queue);
        my $lf = $queue->log_file($mach, $jid);
-       system 'bash', '-o', 'pipefail', '-c', "ssh -t $mach '$rtmp ; e=\$? ; rm -f $rtmp ; exit \$e' 2>&1 | tee -a $lf";
+       system 'bash', '-o', 'pipefail', '-c', "ssh -t $host '$rtmp ; e=\$? ; rm -f $rtmp ; exit \$e' 2>&1 | tee -a $lf";
        if ($?) {
                return ('FAILED', 'Job failed');
        } else {
index a364b2cd540727fb9b035fc7c90922936486d63e..90c5700a70ca1c048399416657e35e6a43a42dd5 100644 (file)
@@ -9,11 +9,13 @@ package BEX::Config;
 # This file specifies default values, which can be overridden in BEX.cf
 
 # A hash of all known machines and groups
-# 'name' => { }                        for a machine
+# 'name' => { Option => ... }  for a machine; options:
+#      Host => 'name'                  Host name to use in ssh, ping, ...
 # 'name' => ['a','b','c']      for a group containing specified machines/subgroups
 our %machines = (
 );
 
+
 # A file whose contents should be prepended before the job. Should start with the "#!" line.
 our $job_prolog = 'prolog';
 
@@ -54,6 +56,11 @@ sub parse_machine_list(@) {
        return sort grep { $set{$_} } keys %set;
 }
 
+sub host_name($) {
+       my ($mach) = @_;
+       return $machines{$mach}->{'Host'} // $mach;
+}
+
 require 'BEX.cf';
 
 42;