lib/Rex/Group/Entry/Server.pm

filter: Statementstmt 74.0% 151 / 204 Branchbran 63.8% 46 / 72 Conditioncond 63.4% 33 / 52 MC/DCmcdc 20.6% 6 / 29 Subroutinesub 86.3% 38 / 44 Podpod 0.0% 0 / 26 totaltotal 64.1% 274 / 427 CC 57 SCAR 21.5
CC
57
Cov
70%
get_auth_type
24.1
new
17.6
AUTOLOAD
14.6
CRAP 8.6
« lib/Rex/Virtualization/LibVirt/vncdisplay.pm ↑ Summary lib/Rex/Pkg/VoidLinux.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Group::Entry::Server;
6  
7 87 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 87 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 87 our $VERSION = '1.16.1'; # VERSION
11  
12 87 ▶use Rex::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 87 ▶use Rex::Helper::System;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 87 ▶use Rex::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 87 ▶use Rex::Interface::Exec;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 87 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 87 ▶use Sort::Naturally;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 87 ▶use Symbol;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 87 ▶use List::Util 1.45 qw(uniq);
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 use overload
23 723 ▶ 'eq' => sub { shift->is_eq(@_); },
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
24 246 ▶ 'ne' => sub { shift->is_ne(@_); },
Subroutine __ANON__: called CC=1 SCAR=0.0
25 668 ▶ '""' => sub { shift->to_s(@_); },
Subroutine __ANON__: called CC=1 SCAR=0.0
26 0 ▶ 'cmp' => sub { shift->compare(@_); };
Subroutine __ANON__: not called CC=1 SCAR=0.2
27  
28 87 ▶use attributes;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 1 ▶sub function {
Subroutine function: called CC=1 SCAR=0.0
Pod undocumented
31 1 my ( $class, $name, $code ) = @_;
32  
33 1 my $ref_to_function = qualify_to_ref( $name, $class );
34 1 *{$ref_to_function} = $code;
35 }
36  
37 600 ▶sub new {
Subroutine new: called CC=12 SCAR=28.7
Pod undocumented
38 600 my $that = shift;
39 600 ▶ my $proto = ref($that) || $that;
Condition33%1/3
ref $that || $that
l!l&&r!l&&!r
06000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table33%1/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
40 600 my $self = {@_};
41  
42 600 bless( $self, $proto );
43  
44 # be save check if name is already a server ref
45 600 ▶ if ( ref $self->{name} eq __PACKAGE__ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"name"} eq __PACKAGE__) 0 600 600
46 0 return $self->{name};
47 }
48  
49 # rewrite auth info
50 600 ▶ if ( $self->{user} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"user"}) 1 599 600
51 1 $self->{auth}->{user} = $self->{user};
52 1 delete $self->{user};
53 }
54  
55 600 ▶ if ( $self->{password} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"password"}) 1 599 600
56 1 $self->{auth}->{password} = $self->{password};
57 1 delete $self->{password};
58 }
59  
60 600 ▶ if ( $self->{port} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"port"}) 0 600 600
61 0 $self->{auth}->{port} = $self->{port};
62 0 delete $self->{port};
63 }
64  
65 600 ▶ if ( $self->{public_key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"public_key"}) 0 600 600
66 0 $self->{auth}->{public_key} = $self->{public_key};
67 0 delete $self->{public_key};
68 }
69  
70 600 ▶ if ( $self->{private_key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"private_key"}) 0 600 600
71 0 $self->{auth}->{private_key} = $self->{private_key};
72 0 delete $self->{private_key};
73 }
74  
75 600 ▶ if ( $self->{sudo} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"sudo"}) 1 599 600
76 1 $self->{auth}->{sudo} = $self->{sudo};
77 1 delete $self->{sudo};
78 }
79  
80 600 ▶ if ( $self->{sudo_password} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"sudo_password"}) 0 600 600
81 0 $self->{auth}->{sudo_password} = $self->{sudo_password};
82 0 delete $self->{sudo_password};
83 }
84  
85 600 ▶ if ( $self->{auth_type} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"auth_type"}) 0 600 600
86 0 $self->{auth}->{auth_type} = $self->{auth_type};
87 0 delete $self->{auth_type};
88 }
89  
90 600 ▶ if ( !ref $self->{__group__} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self->{"__group__"}) 517 83 600
91 517 $self->{__group__} = [];
92 }
93  
94 600 return $self;
95 }
96  
97 31 ▶sub get_servers {
Subroutine get_servers: called CC=3 SCAR=12.7
Pod undocumented
98 31 my ($self) = @_;
99 return uniq map {
100 31 ▶ if ( ref $_ && $_->isa("Rex::Group::Entry::Server") ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ and $_->isa('Rex::Group::Entry::Server')) { } 83 0 83
Condition33%1/3
ref $_ and $_->isa("Rex::Group::Entry::Server")
!ll&&!rl&&r
0083
MC/DC0%0/2
ref $_ and $_->isa("Rex::Group::Entry::Server")
ref $_ $_->isa("Rex::Group::Entry::Server")
Truth table33%1/3
A and B
A= ref $_B= $_->isa("Rex::Group::Entry::Server")
ABresult
0X0
100
111
101 83 $_;
102 }
103 else {
104 0 Rex::Group::Entry::Server->new( name => $_, auth => $self->{auth} );
105 }
106 } $self->evaluate_hostname;
107 }
108  
109 2173 ▶sub to_s {
Subroutine to_s: called CC=1 SCAR=0.0
Pod undocumented
110 2173 my ($self) = @_;
111 2173 return $self->{name};
112 }
113  
114 723 ▶sub is_eq {
Subroutine is_eq: called CC=2 SCAR=6.9
Pod undocumented
115 723 my ( $self, $comp ) = @_;
116 723 ▶ if ( $comp eq $self->to_s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($comp eq $self->to_s) 62 661 723
117 62 return 1;
118 }
119 }
120  
121 246 ▶sub is_ne {
Subroutine is_ne: called CC=2 SCAR=6.9
Pod undocumented
122 246 my ( $self, $comp ) = @_;
123 246 ▶ if ( $comp ne $self->to_s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($comp ne $self->to_s) 78 168 246
124 78 return 1;
125 }
126 }
127  
128 0 ▶sub compare {
Subroutine compare: not called CC=1 SCAR=6.9
Pod undocumented
129 0 my ( $self, $comp ) = @_;
130 0 return ncmp( $self->to_s, $comp->to_s );
131 }
132  
133 0 ▶sub has_auth {
Subroutine has_auth: not called CC=1 SCAR=6.9
Pod undocumented
134 0 my ($self) = @_;
135 0 return exists $self->{auth};
136 }
137  
138 3 ▶sub set_auth {
Subroutine set_auth: called CC=1 SCAR=0.0
Pod undocumented
139 3 my ( $self, %auth ) = @_;
140 3 $self->{auth} = \%auth;
141 }
142  
143 0 ▶sub get_auth {
Subroutine get_auth: not called CC=1 SCAR=6.9
Pod undocumented
144 0 my ($self) = @_;
145 0 return $self->{auth};
146 }
147  
148 88 ▶sub get_user {
Subroutine get_user: called CC=4 SCAR=14.8
Pod undocumented
149 88 my ($self) = @_;
150  
151 88 ▶ if ( exists $self->{auth}->{user} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"auth"}{"user"}) 18 70 88
152 18 return $self->{auth}->{user};
153 }
154  
155 70 ▶ if (!Rex::Config->has_user
Branch: 1 branch
BranchTrueFalseTotal
if (not "Rex::Config"->has_user and "Rex::Config"->get_ssh_config_username("server", $self->to_s)) 0 70 70
Condition66%2/3
not "Rex::Config"->has_user and "Rex::Config"->get_ssh_config_username("server", $self->to_s)
!ll&&!rl&&r
34360
MC/DC0%0/2
not "Rex::Config"->has_user and "Rex::Config"->get_ssh_config_username("server", $self->to_s)
not "Rex::Config"->has_user "Rex::Config"->get_ssh_config_username("server", $self->to_s)
Truth table66%2/3
not(A) and B
A= not "Rex::Config"->has_userB= "Rex::Config"->get_ssh_config_username("server", $self->to_s)
ABresult
0X0
100
111
156 && Rex::Config->get_ssh_config_username( server => $self->to_s ) )
157 {
158 0 Rex::Logger::debug("Checking for a user in .ssh/config");
159 0 return Rex::Config->get_ssh_config_username( server => $self->to_s );
160 }
161  
162 70 return Rex::Config->get_user;
163 }
164  
165 88 ▶sub get_password {
Subroutine get_password: called CC=2 SCAR=6.9
Pod undocumented
166 88 my ($self) = @_;
167  
168 88 ▶ if ( exists $self->{auth}->{password} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"auth"}{"password"}) 18 70 88
169 18 return $self->{auth}->{password};
170 }
171  
172 70 return Rex::Config->get_password;
173 }
174  
175 88 ▶sub get_port {
Subroutine get_port: called CC=2 SCAR=7.6
Pod undocumented
176 88 my ($self) = @_;
177  
178 88 ▶ if ( exists $self->{auth}->{port} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"auth"}{"port"}) 0 88 88
179 0 return $self->{auth}->{port};
180 }
181  
182 88 return Rex::Config->get_port;
183 }
184  
185 88 ▶sub get_public_key {
Subroutine get_public_key: called CC=6 SCAR=21.9
Pod undocumented
186 88 my ($self) = @_;
187  
188 88 ▶ if ( exists $self->{auth}->{public_key} && -f $self->{auth}->{public_key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"auth"}{"public_key"} and -f $self->{"auth"}{"public_key"}) 0 88 88
Condition66%2/3
exists $self->{"auth"}{"public_key"} and -f $self->{"auth"}{"public_key"}
!ll&&!rl&&r
8620
MC/DC0%0/2
exists $self->{"auth"}{"public_key"} and -f $self->{"auth"}{"public_key"}
exists $self->{"auth"}{"public_key"} -f $self->{"auth"}{"public_key"}
Truth table66%2/3
A and B
A= exists $self->{"auth"}{"public_key"}B= -f $self->{"auth"}{"public_key"}
ABresult
0X0
100
111
189 0 Rex::Logger::debug(
190 "Rex::Group::Entry::Server (public_key): returning $self->{auth}->{public_key}"
191 );
192 0 return $self->{auth}->{public_key};
193 }
194  
195 88 ▶ if (!Rex::Config->has_public_key
Branch: 1 branch
BranchTrueFalseTotal
if (not "Rex::Config"->has_public_key and "Rex::Config"->get_ssh_config_public_key("server", $self->to_s)) 0 88 88
Condition66%2/3
not "Rex::Config"->has_public_key and "Rex::Config"->get_ssh_config_public_key("server", $self->to_s)
!ll&&!rl&&r
49390
MC/DC0%0/2
not "Rex::Config"->has_public_key and "Rex::Config"->get_ssh_config_public_key("server", $self->to_s)
not "Rex::Config"->has_public_key "Rex::Config"->get_ssh_config_public_key("server", $self->to_s)
Truth table66%2/3
not(A) and B
A= not "Rex::Config"->has_public_keyB= "Rex::Config"->get_ssh_config_public_key("server", $self->to_s)
ABresult
0X0
100
111
196 && Rex::Config->get_ssh_config_public_key( server => $self->to_s ) )
197 {
198 0 Rex::Logger::debug("Checking for a public key in .ssh/config");
199 0 my $key = Rex::Config->get_ssh_config_public_key( server => $self->to_s );
200 0 Rex::Logger::debug(
201 "Rex::Group::Entry::Server (public_key): returning $key");
202 0 return $key;
203 }
204  
205 88 ▶ Rex::Logger::debug( "Rex::Group::Entry::Server (public_key): returning "
Condition100%2/2
'Rex::Config'->get_public_key || ''
l!l
4939
MC/DC100%1/1
'Rex::Config'->get_public_key || ''
'Rex::Config'->get_public_key
Truth table100%2/2
A
A= 'Rex::Config'->get_public_key
Aresult
11
00
206 . ( Rex::Config->get_public_key || "" ) );
207 88 return Rex::Config->get_public_key;
208 }
209  
210 88 ▶sub get_private_key {
Subroutine get_private_key: called CC=6 SCAR=21.9
Pod undocumented
211 88 my ($self) = @_;
212  
213 88 ▶ if ( exists $self->{auth}->{private_key} && -f $self->{auth}->{private_key} )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"auth"}{"private_key"} and -f $self->{"auth"}{"private_key"}) 0 88 88
Condition66%2/3
exists $self->{"auth"}{"private_key"} and -f $self->{"auth"}{"private_key"}
!ll&&!rl&&r
8620
MC/DC0%0/2
exists $self->{"auth"}{"private_key"} and -f $self->{"auth"}{"private_key"}
exists $self->{"auth"}{"private_key"} -f $self->{"auth"}{"private_key"}
Truth table66%2/3
A and B
A= exists $self->{"auth"}{"private_key"}B= -f $self->{"auth"}{"private_key"}
ABresult
0X0
100
111
214 {
215 Rex::Logger::debug( "Rex::Group::Entry::Server (private_key): returning "
216 0 . $self->{auth}->{private_key} );
217 0 return $self->{auth}->{private_key};
218 }
219  
220 88 ▶ if (!Rex::Config->has_private_key
Branch: 1 branch
BranchTrueFalseTotal
if (not "Rex::Config"->has_private_key and "Rex::Config"->get_ssh_config_private_key("server", $self->to_s)) 0 88 88
Condition66%2/3
not "Rex::Config"->has_private_key and "Rex::Config"->get_ssh_config_private_key("server", $self->to_s)
!ll&&!rl&&r
49390
MC/DC0%0/2
not "Rex::Config"->has_private_key and "Rex::Config"->get_ssh_config_private_key("server", $self->to_s)
not "Rex::Config"->has_private_key "Rex::Config"->get_ssh_config_private_key("server", $self->to_s)
Truth table66%2/3
not(A) and B
A= not "Rex::Config"->has_private_keyB= "Rex::Config"->get_ssh_config_private_key("server", $self->to_s)
ABresult
0X0
100
111
221 && Rex::Config->get_ssh_config_private_key( server => $self->to_s ) )
222 {
223 0 Rex::Logger::debug("Checking for a private key in .ssh/config");
224 0 my $key = Rex::Config->get_ssh_config_private_key( server => $self->to_s );
225 0 Rex::Logger::debug(
226 "Rex::Group::Entry::Server (private_key): returning " . $key );
227 0 return $key;
228 }
229  
230 88 ▶ Rex::Logger::debug( "Rex::Group::Entry::Server (private_key): returning "
Condition100%2/2
'Rex::Config'->get_private_key || ''
l!l
4939
MC/DC100%1/1
'Rex::Config'->get_private_key || ''
'Rex::Config'->get_private_key
Truth table100%2/2
A
A= 'Rex::Config'->get_private_key
Aresult
11
00
231 . ( Rex::Config->get_private_key || "" ) );
232 88 return Rex::Config->get_private_key;
233 }
234  
235 88 ▶sub get_auth_type {
Subroutine get_auth_type: called CC=14 SCAR=31.8
Pod undocumented
236 88 my ($self) = @_;
237  
238 88 ▶ if ( exists $self->{auth}->{auth_type} && $self->{auth}->{auth_type} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"auth"}{"auth_type"} and $self->{"auth"}{"auth_type"}) 0 88 88
Condition33%1/3
exists $self->{"auth"}{"auth_type"} and $self->{"auth"}{"auth_type"}
!ll&&!rl&&r
8800
MC/DC0%0/2
exists $self->{"auth"}{"auth_type"} and $self->{"auth"}{"auth_type"}
exists $self->{"auth"}{"auth_type"} $self->{"auth"}{"auth_type"}
Truth table33%1/3
A and B
A= exists $self->{"auth"}{"auth_type"}B= $self->{"auth"}{"auth_type"}
ABresult
0X0
100
111
239 0 return $self->{auth}->{auth_type};
240 }
241  
242 88 ▶ if ( exists $self->{auth}->{public_key}
Branch: 5 branches
BranchTrueFalseTotal
if (exists $self->{'auth'}{'public_key'} and -f $self->{'auth'}{'public_key'} and exists $self->{'auth'}{'private_key'} and -f $self->{'auth'}{'private_key'}) { } 0 88 88
elsif (exists $self->{'auth'}{'user'} and $self->{'auth'}{'user'} and exists $self->{'auth'}{'password'} and $self->{'auth'}{'password'} ne '') { } 18 70 88
elsif ('Rex::Config'->get_krb5_auth) { } 0 70 70
elsif ('Rex::Config'->get_password_auth) { } 7 63 70
elsif ('Rex::Config'->get_key_auth) { } 1 62 63
Condition44%4/9
exists $self->{"auth"}{"public_key"} and -f $self->{"auth"}{"public_key"} and exists $self->{"auth"}{"private_key"} and -f $self->{"auth"}{"private_key"}
!ll&&!rl&&r
8800
exists $self->{"auth"}{"public_key"} and -f $self->{"auth"}{"public_key"} and exists $self->{"auth"}{"private_key"}
!ll&&!rl&&r
8800
exists $self->{"auth"}{"public_key"} and -f $self->{"auth"}{"public_key"}
!ll&&!rl&&r
8620
MC/DC0%0/4
exists $self->{"auth"}{"public_key"} and -f $self->{"auth"}{"public_key"} and exists $self->{"auth"}{"private_key"} and -f $self->{"auth"}{"private_key"}
exists $self->{"auth"}{"public_key"} -f $self->{"auth"}{"public_key"} exists $self->{"auth"}{"private_key"} -f $self->{"auth"}{"private_key"}
Truth table40%2/5
A and B and C and D
A= exists $self->{"auth"}{"public_key"}B= -f $self->{"auth"}{"public_key"}C= exists $self->{"auth"}{"private_key"}D= -f $self->{"auth"}{"private_key"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
243 && -f $self->{auth}->{public_key}
244 && exists $self->{auth}->{private_key}
245 && -f $self->{auth}->{private_key} )
246 {
247 0 return "try";
248 }
249 ▶ elsif ( exists $self->{auth}->{user}
Condition66%6/9
exists $self->{"auth"}{"user"} and $self->{"auth"}{"user"} and exists $self->{"auth"}{"password"} and $self->{"auth"}{"password"} ne ""
!ll&&!rl&&r
70018
exists $self->{"auth"}{"user"} and $self->{"auth"}{"user"} and exists $self->{"auth"}{"password"}
!ll&&!rl&&r
70018
exists $self->{"auth"}{"user"} and $self->{"auth"}{"user"}
!ll&&!rl&&r
70018
MC/DC25%1/4
exists $self->{"auth"}{"user"} and $self->{"auth"}{"user"} and exists $self->{"auth"}{"password"} and $self->{"auth"}{"password"} ne ""
exists $self->{"auth"}{"user"} $self->{"auth"}{"user"} exists $self->{"auth"}{"password"} $self->{"auth"}{"password"} ne ""
Truth table40%2/5
A and B and C and D
A= exists $self->{"auth"}{"user"}B= $self->{"auth"}{"user"}C= exists $self->{"auth"}{"password"}D= $self->{"auth"}{"password"} ne ""
ABCDresult
0XXX0
10XX0
110X0
11100
11111
250 && $self->{auth}->{user}
251 && exists $self->{auth}->{password}
252 && $self->{auth}->{password} ne "" )
253 {
254 18 return "try";
255 }
256 elsif ( Rex::Config->get_krb5_auth ) {
257 0 return "krb5";
258 }
259 elsif ( Rex::Config->get_password_auth ) {
260 7 return "pass";
261 }
262 elsif ( Rex::Config->get_key_auth ) {
263 1 return "key";
264 }
265  
266 62 return "try";
267 }
268  
269 88 ▶sub get_sudo {
Subroutine get_sudo: called CC=2 SCAR=6.9
Pod undocumented
270 88 my ($self) = @_;
271 88 ▶ if ( exists $self->{auth}->{sudo} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"auth"}{"sudo"}) 3 85 88
272 3 return $self->{auth}->{sudo};
273 }
274  
275 85 return 0;
276 }
277  
278 88 ▶sub get_sudo_password {
Subroutine get_sudo_password: called CC=2 SCAR=7.6
Pod undocumented
279 88 my ($self) = @_;
280 88 ▶ if ( exists $self->{auth}->{sudo_password} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"auth"}{"sudo_password"}) 0 88 88
281 0 return $self->{auth}->{sudo_password};
282 }
283  
284 88 Rex::Config->get_sudo_password;
285 }
286  
287 88 ▶sub merge_auth {
Subroutine merge_auth: called CC=6 SCAR=18.0
Pod undocumented
288 88 my ( $self, $other_auth ) = @_;
289  
290 88 my %new_auth;
291 88 my @keys =
292 qw/user password port private_key public_key auth_type sudo sudo_password/;
293  
294 88 for my $key (@keys) {
295 704 my $call = "get_$key";
296 704 ▶ if ( ref($self)->can($call) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($self)->can($call)) { } 704 0 704
297 704 $new_auth{$key} = $self->$call();
298 }
299 else {
300 0 $new_auth{$key} = $other_auth->{$key};
301 }
302  
303 # other_auth has presedence
304 704 ▶ if ( exists $other_auth->{$key}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $other_auth->{$key} and defined $other_auth->{$key} and "Rex::Config"->get_use_server_auth == 0) 101 603 704
Condition100%6/6
exists $other_auth->{$key} and defined $other_auth->{$key} and "Rex::Config"->get_use_server_auth == 0
!ll&&!rl&&r
5994101
exists $other_auth->{$key} and defined $other_auth->{$key}
!ll&&!rl&&r
448151105
MC/DC100%3/3
exists $other_auth->{$key} and defined $other_auth->{$key} and "Rex::Config"->get_use_server_auth == 0
exists $other_auth->{$key} defined $other_auth->{$key} "Rex::Config"->get_use_server_auth == 0
Truth table100%4/4
A and B and C
A= exists $other_auth->{$key}B= defined $other_auth->{$key}C= "Rex::Config"->get_use_server_auth == 0
ABCresult
0XX0
10X0
1100
1111
305 && defined $other_auth->{$key}
306 && Rex::Config->get_use_server_auth() == 0 )
307 {
308 101 $new_auth{$key} = $other_auth->{$key};
309 }
310 }
311  
312 88 return %new_auth;
313 }
314  
315 64 ▶sub append_to_group {
Subroutine append_to_group: called CC=1 SCAR=0.0
Pod undocumented
316 64 my ( $self, $group ) = @_;
317 64 push @{ $self->{__group__} }, $group;
318 }
319  
320 0 ▶sub group {
Subroutine group: not called CC=1 SCAR=6.9
Pod undocumented
321 0 my ($self) = @_;
322 0 return $self->groups;
323 }
324  
325 4 ▶sub groups {
Subroutine groups: called CC=1 SCAR=0.0
Pod undocumented
326 4 my ($self) = @_;
327 4 return @{ $self->{__group__} };
328 }
329  
330 2 ▶sub option {
Subroutine option: called CC=2 SCAR=7.1
Pod undocumented
331 2 my ( $self, $option ) = @_;
332 2 ▶ if ( exists $self->{$option} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{$option}) 2 0 2
333 2 return $self->{$option};
334 }
335 }
336  
337 0 ▶sub gather_information {
Subroutine gather_information: not called CC=1 SCAR=6.9
Pod undocumented
338 0 my ($self) = @_;
339 0 my %info = Rex::Helper::System::info();
340 0 $self->{__hardware_info__} = \%info;
341 }
342  
343 371 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=5 SCAR=26.8
344 87 ▶ use vars qw($AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
345 371 my $self = shift;
346  
347 371 ▶ return $self if ( $AUTOLOAD =~ m/DESTROY/ );
Branch: 1 branch
BranchTrueFalseTotal
if $Rex::Group::Entry::Server::AUTOLOAD =~ /DESTROY/u 371 0 371
348  
349 0 my ($wanted_data) = ( $AUTOLOAD =~ m/::([a-z0-9A-Z_]+)$/ );
350  
351 0 ▶ if ( scalar( keys %{ $self->{__hardware_info__} } ) == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %{$$self{"__hardware_info__"};} == 0) 0 0 0
352 0 $self->gather_information;
353 }
354  
355 0 ▶ if ( exists $self->{__hardware_info__}->{$wanted_data} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"__hardware_info__"}{$wanted_data}) 0 0 0
356 0 return $self->{__hardware_info__}->{$wanted_data};
357 }
358  
359 0 ▶ if ( exists $self->{$wanted_data} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{$wanted_data}) 0 0 0
360 0 return $self->{$wanted_data};
361 }
362  
363 0 return;
364 }
365  
366 31 ▶sub evaluate_hostname {
Subroutine evaluate_hostname: called CC=2 SCAR=6.9
Pod undocumented
367 31 my ($self) = @_;
368  
369 31 my @servers = Rex::Commands::evaluate_hostname( $self->to_s );
370 31 my @multiple_me;
371  
372 31 for (@servers) {
373 83 push @multiple_me, ref($self)->new( %{$self} );
374 83 $multiple_me[-1]->{name} = $_;
375 }
376  
377 31 return @multiple_me;
378 }
379  
380 36 ▶sub test_perl {
Subroutine test_perl: called CC=1 SCAR=0.0
Pod undocumented
381 36 my ($self) = @_;
382 36 my $exec = Rex::Interface::Exec->create;
383 36 return $exec->can_run( ["perl"] ); # use a new anon ref, so that we don't have drawbacks if some lower layers will manipulate things.
384 }
385  
386 87 1;
« lib/Rex/Virtualization/LibVirt/vncdisplay.pm ↑ Summary lib/Rex/Pkg/VoidLinux.pm »