lib/Rex/Virtualization/Lxc/stop.pm

filter: Statementstmt 57.1% 16 / 28 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 43.7% 21 / 48 CC 6 SCAR 31.5
CC
6
Cov
41%
execute
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 23.4
« lib/Rex/Virtualization/VBox/list.pm ↑ Summary lib/Rex/Helper/Path.pm »
1 #
2 # (c) Oleg Hardt <litwol@litwol.com>
3 #
4  
5 package Rex::Virtualization::Lxc::stop;
6  
7 1 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '1.16.1'; # VERSION
11  
12 1 ▶use Rex::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Rex::Helper::Run;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Scalar::Util qw(looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶sub execute {
Subroutine execute: not called CC=6 SCAR=37.4
Pod undocumented
17 0 my ( $class, $arg1, %opt ) = @_;
18  
19 0 ▶ unless ($arg1) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($arg1) 0 0 0
20 0 die("You have to define the container name!");
21 }
22  
23 0 my $container_name = $arg1;
24 0 Rex::Logger::debug("stopping container $container_name");
25  
26 0 ▶ unless ($container_name) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($container_name) 0 0 0
27 0 die("VM $container_name not found.");
28 }
29  
30 0 my $opts = \%opt;
31 my $timeout =
32 ( exists $opts->{timeout} and looks_like_number( $opts->{timeout} ) )
33 ? $opts->{timeout}
34 0 ▶ : 30;
Branch: 1 branch
BranchTrueFalseTotal
exists $opts->{'timeout'} && &looks_like_number($opts->{'timeout'}) ? : 0 0 0
Condition0%0/3
exists $opts->{"timeout"} and &looks_like_number($opts->{"timeout"})
!ll&&!rl&&r
000
MC/DC0%0/2
exists $opts->{"timeout"} and &looks_like_number($opts->{"timeout"})
exists $opts->{"timeout"} &looks_like_number($opts->{"timeout"})
Truth table0%0/3
A and B
A= exists $opts->{"timeout"}B= &looks_like_number($opts->{"timeout"})
ABresult
0X0
100
111
35  
36 0 i_run "lxc-stop -t $timeout -n \"$container_name\"", fail_ok => 1;
37 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
38 0 die("Error stopping container $container_name");
39 }
40  
41 }
42  
43 1 1;
« lib/Rex/Virtualization/VBox/list.pm ↑ Summary lib/Rex/Helper/Path.pm »