line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Rex::Virtualization::Docker - Docker Virtualization Module |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
With this module you can manage Docker. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Rex::Commands::Virtualization; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
set virtualization => "Docker"; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Data::Dumper; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
print Dumper vm list => "all"; |
22
|
|
|
|
|
|
|
print Dumper vm list => "running"; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
print Dumper vm info => "vm01"; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
vm destroy => "vm01"; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
vm delete => "vm01"; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
vm start => "vm01"; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
vm shutdown => "vm01"; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
vm reboot => "vm01"; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# creating a vm |
37
|
|
|
|
|
|
|
my $id = vm create => "vm01", |
38
|
|
|
|
|
|
|
image => "ubuntu", |
39
|
|
|
|
|
|
|
command => 'echo hello world', |
40
|
|
|
|
|
|
|
memory => 512, |
41
|
|
|
|
|
|
|
cpus => 1, |
42
|
|
|
|
|
|
|
links => ['mysql:db'], |
43
|
|
|
|
|
|
|
forward_port => [8080 => 80], |
44
|
|
|
|
|
|
|
share_folder => ["hostdir" => "vmdir"], |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
package Rex::Virtualization::Docker; |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
25
|
use v5.12.5; |
|
1
|
|
|
|
|
13
|
|
51
|
1
|
|
|
1
|
|
16
|
use warnings; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
62
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
our $VERSION = '1.14.2.3'; # TRIAL VERSION |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
1
|
|
20
|
use Rex::Virtualization::Base; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
20
|
|
56
|
1
|
|
|
1
|
|
40
|
use base qw(Rex::Virtualization::Base); |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
145
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub new { |
59
|
0
|
|
|
0
|
0
|
|
my $that = shift; |
60
|
0
|
|
0
|
|
|
|
my $proto = ref($that) || $that; |
61
|
0
|
|
|
|
|
|
my $self = {@_}; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
bless( $self, $proto ); |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $self; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |