line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Oleg Hardt |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Virtualization::Lxc::stop; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
15
|
use v5.12.5; |
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
41
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.3'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use Rex::Logger; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
13
|
1
|
|
|
1
|
|
34
|
use Rex::Helper::Run; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
71
|
|
14
|
1
|
|
|
1
|
|
7
|
use Scalar::Util qw(looks_like_number); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
250
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub execute { |
17
|
0
|
|
|
0
|
0
|
|
my ( $class, $arg1, %opt ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
unless ($arg1) { |
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
|
0
|
|
|
|
|
unless ($container_name) { |
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
|
0
|
0
|
|
|
|
: 30; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
i_run "lxc-stop -t $timeout -n \"$container_name\"", fail_ok => 1; |
37
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
38
|
0
|
|
|
|
|
|
die("Error stopping container $container_name"); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |