| 1 | # | ||||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||||
| 3 | # | ||||||||||||
| 4 | |||||||||||||
| 5 | package Rex::Virtualization::VBox::import; | ||||||||||||
| 6 | |||||||||||||
| 7 | 1 | ▶ | use v5.14.4; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 1 | our $VERSION = '1.16.1'; # VERSION | |||||||||||
| 11 | |||||||||||||
| 12 | 1 | ▶ | use Rex::Logger; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | 1 | ▶ | use Rex::Helper::Run; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | 0 | ▶ | sub execute { | ||||||||||
|
Subroutine
execute: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||
| 16 | 0 | my ( $class, $arg1, %opt ) = @_; | |||||||||||
| 17 | |||||||||||||
| 18 | 0 | ▶ | unless ($arg1) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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 | ▶ | $opt{cpus} ||= 1; | ||||||||||
|
Condition0%0/2
$opt{"cpus"} ||= 1
MC/DC0%0/1
$opt{"cpus"} ||= 1
$opt{"cpus"}
Truth table0%0/2
A
A= $opt{"cpus"}
| |||||||||||||
| 26 | 0 | ▶ | $opt{memory} ||= 512; | ||||||||||
|
Condition0%0/2
$opt{"memory"} ||= 512
MC/DC0%0/1
$opt{"memory"} ||= 512
$opt{"memory"}
Truth table0%0/2
A
A= $opt{"memory"}
| |||||||||||||
| 27 | |||||||||||||
| 28 | 0 | my $add_cmd = ""; | |||||||||||
| 29 | |||||||||||||
| 30 | 0 | ▶ | if ( exists $opt{cpus} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 31 | 0 | $add_cmd .= " --cpus $opt{cpus} "; | |||||||||||
| 32 | } | ||||||||||||
| 33 | |||||||||||||
| 34 | 0 | ▶ | if ( exists $opt{memory} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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 | ▶ | if ( $? != 0 ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 45 | 0 | die("Error importing VM $opt{file}"); | |||||||||||
| 46 | } | ||||||||||||
| 47 | } | ||||||||||||
| 48 | |||||||||||||
| 49 | 1 | 1; | |||||||||||