| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Parallel::Workers::Backend::SSH; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3497
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
37
|
|
|
4
|
1
|
|
|
1
|
|
15
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
5
|
1
|
|
|
1
|
|
63
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
71
|
|
|
6
|
1
|
|
|
1
|
|
991
|
use Net::SSH::Perl; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Data::Dumper; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our (@ISA, @EXPORT, @EXPORT_OK); |
|
10
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
@EXPORT = (); |
|
13
|
|
|
|
|
|
|
@EXPORT_OK = (); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# |
|
16
|
|
|
|
|
|
|
sub new { |
|
17
|
|
|
|
|
|
|
my $class = shift; |
|
18
|
|
|
|
|
|
|
my %parms = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $self = {user => $parms{user},password=>$parms{pass}, ssh => undef}; |
|
21
|
|
|
|
|
|
|
bless $self, $class; |
|
22
|
|
|
|
|
|
|
return $self; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _open{ |
|
26
|
|
|
|
|
|
|
my ($user,$password,$host) = @_; |
|
27
|
|
|
|
|
|
|
my $ssh = Net::SSH::Perl->new($host, {protocol=>'2,1',privileged => 0,compression=>1, options => [ |
|
28
|
|
|
|
|
|
|
"BatchMode yes", "RhostsAuthentication no" ]}); |
|
29
|
|
|
|
|
|
|
$ssh->login("$user", "$password"); |
|
30
|
|
|
|
|
|
|
return $ssh; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub pre { |
|
34
|
|
|
|
|
|
|
my ($this, $id, $host, $cmd ,$params)=@_; |
|
35
|
|
|
|
|
|
|
my $ssh=_open($this->{user},$this->{password},$host); |
|
36
|
|
|
|
|
|
|
my($stdout, $stderr, $exit) = $ssh->cmd($cmd); |
|
37
|
|
|
|
|
|
|
return $stdout; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub do { |
|
41
|
|
|
|
|
|
|
my ($this, $id, $host, $cmd ,$params)=@_; |
|
42
|
|
|
|
|
|
|
print "ssh command ($cmd) open\n" if $Parallel::Workers::WARN; |
|
43
|
|
|
|
|
|
|
my $ssh=_open($this->{user},$this->{password},$host); |
|
44
|
|
|
|
|
|
|
print "ssh command ($cmd) start\n" if $Parallel::Workers::WARN; |
|
45
|
|
|
|
|
|
|
my($stdout, $stderr, $exit) = $ssh->cmd($cmd); |
|
46
|
|
|
|
|
|
|
print "ssh command ($cmd) done\n" if $Parallel::Workers::WARN; |
|
47
|
|
|
|
|
|
|
return $stdout; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub post { |
|
51
|
|
|
|
|
|
|
my ($this, $id, $host, $cmd ,$params)=@_; |
|
52
|
|
|
|
|
|
|
my $ssh=_open( $this->{user},$this->{password},$host); |
|
53
|
|
|
|
|
|
|
my($stdout, $stderr, $exit) = $ssh->cmd($cmd); |
|
54
|
|
|
|
|
|
|
return $stdout; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
|
58
|
|
|
|
|
|
|
__END__ |