line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Rex::Virtualization::LibVirt - LibVirt Virtualization Module |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
With this module you can manage LibVirt. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Rex::Commands::Virtualization; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
set virtualization => "LibVirt"; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
print Dumper vm list => "all"; |
20
|
|
|
|
|
|
|
print Dumper vm list => "running"; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
vm destroy => "vm01"; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
vm delete => "vm01"; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
vm start => "vm01"; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
vm shutdown => "vm01"; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
vm reboot => "vm01"; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
vm option => "vm01", |
33
|
|
|
|
|
|
|
max_memory => 1024*1024, |
34
|
|
|
|
|
|
|
memory => 512*1024; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
print Dumper vm info => "vm01"; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# creating a vm on a kvm host |
39
|
|
|
|
|
|
|
vm create => "vm01", |
40
|
|
|
|
|
|
|
storage => [ |
41
|
|
|
|
|
|
|
{ |
42
|
|
|
|
|
|
|
file => "/mnt/data/libvirt/images/vm01.img", |
43
|
|
|
|
|
|
|
dev => "vda", |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
]; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
print Dumper vm hypervisor => "capabilities"; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
package Rex::Virtualization::LibVirt; |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
3
|
|
42
|
use v5.12.5; |
|
3
|
|
|
|
|
12
|
|
54
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
121
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
our $VERSION = '1.14.3'; # VERSION |
57
|
|
|
|
|
|
|
|
58
|
3
|
|
|
3
|
|
30
|
use Rex::Virtualization::Base; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
69
|
|
59
|
3
|
|
|
3
|
|
94
|
use base qw(Rex::Virtualization::Base); |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
437
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub new { |
62
|
2
|
|
|
2
|
0
|
5
|
my $that = shift; |
63
|
2
|
|
33
|
|
|
11
|
my $proto = ref($that) || $that; |
64
|
2
|
|
|
|
|
4
|
my $self = {@_}; |
65
|
|
|
|
|
|
|
|
66
|
2
|
|
|
|
|
4
|
bless( $self, $proto ); |
67
|
|
|
|
|
|
|
|
68
|
2
|
|
|
|
|
4
|
return $self; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |