line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Virtualization::LibVirt::start; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
14
|
use v5.12.5; |
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.2'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use Rex::Logger; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
13
|
1
|
|
|
1
|
|
20
|
use Rex::Helper::Run; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
272
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub execute { |
16
|
0
|
|
|
0
|
0
|
|
my ( $class, $arg1, %opt ) = @_; |
17
|
0
|
|
|
|
|
|
my $virt_settings = Rex::Config->get("virtualization"); |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
Rex::Logger::debug("Starting vm: $arg1"); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
chomp( my $uri = |
22
|
0
|
0
|
|
|
|
|
ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" ); |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
unless ($arg1) { |
25
|
0
|
|
|
|
|
|
die("You have to define the vm name!"); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $dom = $arg1; |
29
|
0
|
|
|
|
|
|
Rex::Logger::debug("starting domain: $dom"); |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
unless ($dom) { |
32
|
0
|
|
|
|
|
|
die("VM $dom not found."); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $output = i_run "virsh -c $uri start '$dom' 2>&1", fail_ok => 1; |
36
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
37
|
0
|
|
|
|
|
|
die("Error starting vm $dom\nError: $output"); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |