lib/Rex/Virtualization/VBox/option.pm

filter: Statementstmt 48.2% 14 / 29 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 43.9% 18 / 41 CC 5 SCAR 28.4
CC
5
Cov
40%
execute
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 17.1
« lib/Rex/Virtualization/LibVirt/shutdown.pm ↑ Summary lib/Rex/Box/Base.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Virtualization::VBox::option;
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 1 my $FUNC_MAP = {
16 max_memory => "memory",
17 memory => "memory",
18 };
19  
20 0 ▶sub execute {
Subroutine execute: not called CC=5 SCAR=34.0
Pod undocumented
21 0 my ( $class, $arg1, %opt ) = @_;
22  
23 0 ▶ unless ($arg1) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($arg1) 0 0 0
24 0 die("You have to define the vm name!");
25 }
26  
27 0 my $dom = $arg1;
28 0 Rex::Logger::debug("setting some options for: $dom");
29  
30 0 for my $opt ( keys %opt ) {
31 0 my $val = $opt{$opt};
32  
33 0 my $func;
34 0 ▶ unless ( exists $FUNC_MAP->{$opt} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FUNC_MAP->{$opt}) { } 0 0 0
35 0 Rex::Logger::debug("$opt unknown. using as option for VBoxManage.");
36 0 $func = $opt;
37 }
38 else {
39 0 $func = $FUNC_MAP->{$opt};
40 }
41  
42 0 i_run "VBoxManage modifyvm \"$dom\" --$func \"$val\"", fail_ok => 1;
43 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
44 0 Rex::Logger::info( "Error setting $opt to $val on $dom ($@)", "warn" );
45 }
46  
47 }
48  
49 }
50  
51 1 1;
« lib/Rex/Virtualization/LibVirt/shutdown.pm ↑ Summary lib/Rex/Box/Base.pm »