line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Virtualization::VBox::import; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
14
|
use v5.12.5; |
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.3'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use Rex::Logger; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
13
|
1
|
|
|
1
|
|
20
|
use Rex::Helper::Run; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
295
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub execute { |
16
|
0
|
|
|
0
|
0
|
|
my ( $class, $arg1, %opt ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
unless ($arg1) { |
19
|
0
|
|
|
|
|
|
die("You have to define the vm name!"); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my $dom = $arg1; |
23
|
0
|
|
|
|
|
|
Rex::Logger::debug( "importing: $dom -> " . $opt{file} ); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
0
|
|
|
|
$opt{cpus} ||= 1; |
26
|
0
|
|
0
|
|
|
|
$opt{memory} ||= 512; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $add_cmd = ""; |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
if ( exists $opt{cpus} ) { |
31
|
0
|
|
|
|
|
|
$add_cmd .= " --cpus $opt{cpus} "; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
if ( exists $opt{memory} ) { |
35
|
0
|
|
|
|
|
|
$add_cmd .= " --memory $opt{memory} "; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
i_run "VBoxManage import \"" |
39
|
|
|
|
|
|
|
. $opt{file} |
40
|
0
|
|
|
|
|
|
. "\" --vsys 0 --vmname \"" |
41
|
|
|
|
|
|
|
. $dom |
42
|
|
|
|
|
|
|
. "\" $add_cmd 2>&1", fail_ok => 1; |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
45
|
0
|
|
|
|
|
|
die("Error importing VM $opt{file}"); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |