lib/Rex/Virtualization/VBox/import.pm

filter: Statementstmt 46.4% 13 / 28 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 35.4% 17 / 48 CC 7 SCAR 35.8
CC
7
Cov
32%
execute
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 36.0
« lib/Rex/Pkg/Debian.pm ↑ Summary lib/Rex/Pkg/SunOS.pm »
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
BranchTrueFalseTotal
unless ($arg1) 0 0 0
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
l!l
00
MC/DC0%0/1
$opt{"cpus"} ||= 1
$opt{"cpus"}
Truth table0%0/2
A
A= $opt{"cpus"}
Aresult
11
00
26 0 ▶ $opt{memory} ||= 512;
Condition0%0/2
$opt{"memory"} ||= 512
l!l
00
MC/DC0%0/1
$opt{"memory"} ||= 512
$opt{"memory"}
Truth table0%0/2
A
A= $opt{"memory"}
Aresult
11
00
27  
28 0 my $add_cmd = "";
29  
30 0 ▶ if ( exists $opt{cpus} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt{"cpus"}) 0 0 0
31 0 $add_cmd .= " --cpus $opt{cpus} ";
32 }
33  
34 0 ▶ if ( exists $opt{memory} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt{"memory"}) 0 0 0
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
BranchTrueFalseTotal
if ($? != 0) 0 0 0
45 0 die("Error importing VM $opt{file}");
46 }
47 }
48  
49 1 1;
« lib/Rex/Pkg/Debian.pm ↑ Summary lib/Rex/Pkg/SunOS.pm »