| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
|
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Based on the idea of IPC::PerlSSH by Paul Evans, 2006,2007 -- leonerd@leonerd.org.uk |
|
5
|
|
|
|
|
|
|
# (C) Casiano Rodriguez-Leon 2007 -- casiano@ull.es |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package GRID::Machine; |
|
8
|
20
|
|
|
20
|
|
666354
|
use strict; |
|
|
20
|
|
|
|
|
49
|
|
|
|
20
|
|
|
|
|
1261
|
|
|
9
|
20
|
|
|
20
|
|
126
|
use Scalar::Util qw(blessed reftype); |
|
|
20
|
|
|
|
|
37
|
|
|
|
20
|
|
|
|
|
3313
|
|
|
10
|
20
|
|
|
20
|
|
122
|
use List::Util qw(first); |
|
|
20
|
|
|
|
|
39
|
|
|
|
20
|
|
|
|
|
2641
|
|
|
11
|
20
|
|
|
20
|
|
22097
|
use Module::Which; |
|
|
20
|
|
|
|
|
2921733
|
|
|
|
20
|
|
|
|
|
1246
|
|
|
12
|
20
|
|
|
20
|
|
21276
|
use IPC::Open2(); |
|
|
20
|
|
|
|
|
107214
|
|
|
|
20
|
|
|
|
|
511
|
|
|
13
|
20
|
|
|
20
|
|
176
|
use IPC::Open3(); |
|
|
20
|
|
|
|
|
39
|
|
|
|
20
|
|
|
|
|
350
|
|
|
14
|
20
|
|
|
20
|
|
203
|
use Carp; |
|
|
20
|
|
|
|
|
43
|
|
|
|
20
|
|
|
|
|
1525
|
|
|
15
|
20
|
|
|
20
|
|
122
|
use File::Spec; |
|
|
20
|
|
|
|
|
37
|
|
|
|
20
|
|
|
|
|
1501
|
|
|
16
|
20
|
|
|
20
|
|
37181
|
use File::Temp; |
|
|
20
|
|
|
|
|
614422
|
|
|
|
20
|
|
|
|
|
2029
|
|
|
17
|
20
|
|
|
20
|
|
19209
|
use IO::File; |
|
|
20
|
|
|
|
|
29392
|
|
|
|
20
|
|
|
|
|
3703
|
|
|
18
|
20
|
|
|
20
|
|
140
|
use base qw(Exporter); |
|
|
20
|
|
|
|
|
35
|
|
|
|
20
|
|
|
|
|
2320
|
|
|
19
|
20
|
|
|
20
|
|
12529
|
use GRID::Machine::IOHandle; |
|
|
20
|
|
|
|
|
66
|
|
|
|
20
|
|
|
|
|
545
|
|
|
20
|
20
|
|
|
20
|
|
12337
|
use GRID::Machine::Process; |
|
|
20
|
|
|
|
|
57
|
|
|
|
20
|
|
|
|
|
764
|
|
|
21
|
|
|
|
|
|
|
require POSIX; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
require Cwd; |
|
24
|
20
|
|
|
20
|
|
124
|
no Cwd; |
|
|
20
|
|
|
|
|
38
|
|
|
|
20
|
|
|
|
|
954
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT_OK = qw(is_operative read_modules qc slurp_file); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# We need to include the common shared perl library |
|
28
|
20
|
|
|
20
|
|
109
|
use GRID::Machine::MakeAccessors; # Order is important. This must be the first! |
|
|
20
|
|
|
|
|
65
|
|
|
|
20
|
|
|
|
|
443
|
|
|
29
|
20
|
|
|
20
|
|
12411
|
use GRID::Machine::Message; |
|
|
20
|
|
|
|
|
70
|
|
|
|
20
|
|
|
|
|
627
|
|
|
30
|
20
|
|
|
20
|
|
12463
|
use GRID::Machine::Result; |
|
|
20
|
|
|
|
|
61
|
|
|
|
20
|
|
|
|
|
105714
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = '0.127'; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my %_taken_id; |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
|
|
|
|
|
|
my $logic_id = 0; |
|
37
|
|
|
|
|
|
|
sub new_logic_id { |
|
38
|
0
|
|
|
0
|
0
|
|
$logic_id++ while $_taken_id{$logic_id}; |
|
39
|
0
|
|
|
|
|
|
return $logic_id++; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#################################################################### |
|
44
|
|
|
|
|
|
|
# Usage : my $REMOTE_LIBRARY = read_modules(@Remote_modules); |
|
45
|
|
|
|
|
|
|
# Purpose : Concatenates the contents of the files associated with |
|
46
|
|
|
|
|
|
|
# the file descriptors |
|
47
|
|
|
|
|
|
|
# Returns : The string with the contents of all those files |
|
48
|
|
|
|
|
|
|
# Throws : exception if a module can not be found |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub read_modules { |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
0
|
1
|
|
my $m = ""; |
|
53
|
0
|
|
|
|
|
|
for my $descriptor (@_) { |
|
54
|
0
|
|
|
|
|
|
my %modules = %{which($descriptor)}; |
|
|
0
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
for my $module (keys(%modules)) { |
|
57
|
0
|
|
|
|
|
|
my $path = which($module)->{$module}{path}; |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
0
|
0
|
|
|
|
unless (defined($path) and -r $path) { |
|
60
|
0
|
|
|
|
|
|
die "Can't find module $module\n"; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$m .= "# source from: #line 1 \"$path\"\n"; |
|
64
|
0
|
|
|
|
|
|
local $/ = undef; |
|
65
|
0
|
|
|
|
|
|
open my $FILE, "< $path"; |
|
66
|
0
|
|
|
|
|
|
$m .= <$FILE>; |
|
67
|
0
|
|
|
|
|
|
close($FILE); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return $m; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# ssh [-1246AaCfgKkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec] |
|
75
|
|
|
|
|
|
|
# [-D [bind_address:]port] [-e escape_char] |
|
76
|
|
|
|
|
|
|
# [-F configfile] [-i identity_file] [-L [bind_address:]port:host:hostport] |
|
77
|
|
|
|
|
|
|
# [-l login_name] [-m mac_spec] |
|
78
|
|
|
|
|
|
|
# [-O ctl_cmd] [-o option] [-p port] [-R [bind_address:]port:host:hostport] i |
|
79
|
|
|
|
|
|
|
# [-S ctl_path] [-w tunnel:tunnel] |
|
80
|
|
|
|
|
|
|
# [user@]hostname [command] |
|
81
|
|
|
|
|
|
|
# |
|
82
|
|
|
|
|
|
|
sub find_host { |
|
83
|
0
|
|
|
0
|
0
|
|
my $command = shift; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my %option; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
die "Error in GRID::Machine findhost. No command provided\n" unless $command; |
|
88
|
0
|
|
|
|
|
|
$command =~ s{^\s* |
|
89
|
|
|
|
|
|
|
(\S+ # ssh |
|
90
|
|
|
|
|
|
|
(?:\s+-[1246AaCfgKkMNnqsTtVvXxYy])* # -6 -A -f ... options without arg |
|
91
|
|
|
|
|
|
|
) |
|
92
|
|
|
|
|
|
|
\s* |
|
93
|
|
|
|
|
|
|
}{}x; |
|
94
|
0
|
|
|
|
|
|
$option{ssh} = $1; |
|
95
|
0
|
|
|
|
|
|
while ($command =~ s{^\s*(-\w)\s+(\S*)}{}g) { |
|
96
|
0
|
|
|
|
|
|
$option{$1} = $2; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
0
|
|
|
|
|
|
$command =~ s{^\s*([\w+.\@]+)}{}; |
|
99
|
0
|
|
|
|
|
|
$option{host} = $1; |
|
100
|
0
|
|
|
|
|
|
return \%option; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Inheritance: not considered |
|
104
|
|
|
|
|
|
|
{ # closure for attributes |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my @legal = qw( |
|
107
|
|
|
|
|
|
|
cleanup |
|
108
|
|
|
|
|
|
|
command |
|
109
|
|
|
|
|
|
|
debug |
|
110
|
|
|
|
|
|
|
err |
|
111
|
|
|
|
|
|
|
host |
|
112
|
|
|
|
|
|
|
includes |
|
113
|
|
|
|
|
|
|
log |
|
114
|
|
|
|
|
|
|
logic_id |
|
115
|
|
|
|
|
|
|
perl |
|
116
|
|
|
|
|
|
|
perloptions |
|
117
|
|
|
|
|
|
|
prefix |
|
118
|
|
|
|
|
|
|
pushinc unshiftinc |
|
119
|
|
|
|
|
|
|
readfunc |
|
120
|
|
|
|
|
|
|
readpipe |
|
121
|
|
|
|
|
|
|
remotelibs |
|
122
|
|
|
|
|
|
|
report |
|
123
|
|
|
|
|
|
|
scp |
|
124
|
|
|
|
|
|
|
sendstdout |
|
125
|
|
|
|
|
|
|
ssh |
|
126
|
|
|
|
|
|
|
sshpipe |
|
127
|
|
|
|
|
|
|
sshoptions |
|
128
|
|
|
|
|
|
|
startdir startenv |
|
129
|
|
|
|
|
|
|
survive |
|
130
|
|
|
|
|
|
|
tmpdir |
|
131
|
|
|
|
|
|
|
uses |
|
132
|
|
|
|
|
|
|
wait |
|
133
|
|
|
|
|
|
|
writefunc |
|
134
|
|
|
|
|
|
|
writepipe |
|
135
|
|
|
|
|
|
|
); |
|
136
|
|
|
|
|
|
|
my %legal = map { $_ => 1 } @legal; |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
GRID::Machine::MakeAccessors::make_accessors(@legal); |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
######################################################## |
|
141
|
|
|
|
|
|
|
sub RemoteProgram { |
|
142
|
0
|
|
|
0
|
0
|
|
my ($USES, |
|
143
|
|
|
|
|
|
|
$REMOTE_LIBRARY, |
|
144
|
|
|
|
|
|
|
$class, |
|
145
|
|
|
|
|
|
|
$host, |
|
146
|
|
|
|
|
|
|
$log, |
|
147
|
|
|
|
|
|
|
$err, |
|
148
|
|
|
|
|
|
|
$logic_id, |
|
149
|
|
|
|
|
|
|
$startdir, |
|
150
|
|
|
|
|
|
|
$startenv, |
|
151
|
|
|
|
|
|
|
$pushinc, |
|
152
|
|
|
|
|
|
|
$unshiftinc, |
|
153
|
|
|
|
|
|
|
$sendstdout, |
|
154
|
|
|
|
|
|
|
$cleanup, |
|
155
|
|
|
|
|
|
|
$prefix, |
|
156
|
|
|
|
|
|
|
$portdebug, |
|
157
|
|
|
|
|
|
|
$report, |
|
158
|
|
|
|
|
|
|
$tmpdir, |
|
159
|
|
|
|
|
|
|
) |
|
160
|
|
|
|
|
|
|
= @_; |
|
161
|
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
return << "EOREMOTE"; |
|
163
|
|
|
|
|
|
|
#line 1 "$prefix/REMOTE.pm" |
|
164
|
|
|
|
|
|
|
package GRID::Machine; |
|
165
|
|
|
|
|
|
|
use strict; |
|
166
|
|
|
|
|
|
|
use warnings; |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$USES |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
$REMOTE_LIBRARY |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
my \$rperl = $class->new( |
|
173
|
|
|
|
|
|
|
host => '$host', |
|
174
|
|
|
|
|
|
|
log => '$log', |
|
175
|
|
|
|
|
|
|
err => '$err', |
|
176
|
|
|
|
|
|
|
logic_id => '$logic_id', |
|
177
|
|
|
|
|
|
|
clientpid => $$, |
|
178
|
|
|
|
|
|
|
startdir => '$startdir', |
|
179
|
|
|
|
|
|
|
startenv => $startenv, |
|
180
|
|
|
|
|
|
|
pushinc => [ qw{ @$pushinc } ], |
|
181
|
|
|
|
|
|
|
unshiftinc => [ qw{ @$unshiftinc } ], |
|
182
|
|
|
|
|
|
|
sendstdout => $sendstdout, |
|
183
|
|
|
|
|
|
|
cleanup => $cleanup, |
|
184
|
|
|
|
|
|
|
prefix => '$prefix', # Where to install modules |
|
185
|
|
|
|
|
|
|
debug => $portdebug, |
|
186
|
|
|
|
|
|
|
report => q{$report}, |
|
187
|
|
|
|
|
|
|
tmpdir => q{$tmpdir}, |
|
188
|
|
|
|
|
|
|
); |
|
189
|
|
|
|
|
|
|
\$rperl->main(); |
|
190
|
|
|
|
|
|
|
__END__ |