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;
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 {
# 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';
return sort grep { $set{$_} } keys %set;
}
+sub host_name($) {
+ my ($mach) = @_;
+ return $machines{$mach}->{'Host'} // $mach;
+}
+
require 'BEX.cf';
42;