File Coverage

lib/Rex/Virtualization/VBox/option.pm
Criterion Covered Total %
statement 11 26 42.3
branch 0 6 0.0
condition n/a
subroutine 4 5 80.0
pod 0 1 0.0
total 15 38 39.4


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Virtualization::VBox::option;
6              
7 1     1   15 use v5.12.5;
  1         4  
8 1     1   7 use warnings;
  1         4  
  1         42  
9              
10             our $VERSION = '1.14.2.3'; # TRIAL VERSION
11              
12 1     1   6 use Rex::Logger;
  1         1  
  1         7  
13 1     1   27 use Rex::Helper::Run;
  1         6  
  1         322  
14              
15             my $FUNC_MAP = {
16             max_memory => "memory",
17             memory => "memory",
18             };
19              
20             sub execute {
21 0     0 0   my ( $class, $arg1, %opt ) = @_;
22              
23 0 0         unless ($arg1) {
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 0         unless ( exists $FUNC_MAP->{$opt} ) {
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 0         if ( $? != 0 ) {
44 0           Rex::Logger::info( "Error setting $opt to $val on $dom ($@)", "warn" );
45             }
46              
47             }
48              
49             }
50              
51             1;