line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Rex::Virtualization::VBox - VirtualBox Virtualization Module |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
With this module you can manage VirtualBox. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Rex::Commands::Virtualization; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
set virtualization => "VBox"; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Data::Dumper; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
print Dumper vm list => "all"; |
22
|
|
|
|
|
|
|
print Dumper vm list => "running"; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
vm destroy => "vm01"; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
vm delete => "vm01"; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
vm start => "vm01"; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
vm shutdown => "vm01"; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
vm reboot => "vm01"; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
vm option => "vm01", |
35
|
|
|
|
|
|
|
memory => 512; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
print Dumper vm info => "vm01"; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# creating a vm |
40
|
|
|
|
|
|
|
vm create => "vm01", |
41
|
|
|
|
|
|
|
storage => [ |
42
|
|
|
|
|
|
|
{ |
43
|
|
|
|
|
|
|
file => "/mnt/data/vbox/vm01.img", |
44
|
|
|
|
|
|
|
size => "10G", |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
file => "/mnt/iso/debian6.iso", |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
], |
50
|
|
|
|
|
|
|
memory => 512, |
51
|
|
|
|
|
|
|
type => "Linux26", |
52
|
|
|
|
|
|
|
cpus => 1, |
53
|
|
|
|
|
|
|
boot => "dvd"; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
vm forward_port => "vm01", add => { http => [8080, 80] }; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
vm forward_port => "vm01", remove => "http"; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
print Dumper vm guestinfo => "vm01"; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
vm share_folder => "vm01", add => { sharename => "/path/to/share" }; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
vm share_folder => "vm01", remove => "sharename"; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
For VirtualBox memory declaration is always in megabyte. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
package Rex::Virtualization::VBox; |
70
|
|
|
|
|
|
|
|
71
|
2
|
|
|
2
|
|
38
|
use v5.12.5; |
|
2
|
|
|
|
|
9
|
|
72
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
103
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
our $VERSION = '1.14.2.2'; # TRIAL VERSION |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
2
|
|
397
|
use Rex::Virtualization::Base; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
34
|
|
77
|
2
|
|
|
2
|
|
59
|
use base qw(Rex::Virtualization::Base); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
328
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub new { |
80
|
1
|
|
|
1
|
0
|
2
|
my $that = shift; |
81
|
1
|
|
33
|
|
|
7
|
my $proto = ref($that) || $that; |
82
|
1
|
|
|
|
|
2
|
my $self = {@_}; |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
3
|
bless( $self, $proto ); |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
3
|
return $self; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |