line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Virtualization::LibVirt::dumpxml; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
14
|
use v5.12.5; |
|
1
|
|
|
|
|
6
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
56
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.2'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
7
|
use Rex::Logger; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
13
|
1
|
|
|
1
|
|
25
|
use Rex::Helper::Run; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
71
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
8
|
use XML::Simple; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
58
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
249
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub execute { |
20
|
0
|
|
|
0
|
0
|
|
my ( $class, $vmname ) = @_; |
21
|
0
|
|
|
|
|
|
my $virt_settings = Rex::Config->get("virtualization"); |
22
|
|
|
|
|
|
|
chomp( my $uri = |
23
|
0
|
0
|
|
|
|
|
ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" ); |
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
unless ($vmname) { |
26
|
0
|
|
|
|
|
|
die("You have to define the vm name!"); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
Rex::Logger::debug("Getting dumpxml of domain: $vmname"); |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $xml; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $dumpxml = i_run "virsh -c $uri dumpxml '$vmname'", fail_ok => 1; |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
36
|
0
|
|
|
|
|
|
die("Error running virsh dumpxml '$vmname'"); |
37
|
|
|
|
|
|
|
} |
38
|
0
|
|
|
|
|
|
return XMLin($dumpxml); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |