lib/Rex/Virtualization/LibVirt/option.pm

filter: Statementstmt 46.6% 14 / 30 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 40.9% 18 / 44 CC 6 SCAR 32.4
CC
6
Cov
37%
execute
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 25.6
« lib/Rex/Virtualization/LibVirt/destroy.pm ↑ Summary lib/Rex/SCM/Subversion.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Virtualization::LibVirt::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 => "setmaxmem",
17 memory => "setmem",
18 };
19  
20 0 ▶sub execute {
Subroutine execute: not called CC=6 SCAR=37.4
Pod undocumented
21 0 my ( $class, $arg1, %opt ) = @_;
22 0 my $virt_settings = Rex::Config->get("virtualization");
23 chomp( my $uri =
24 0 ▶ ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
Branch: 1 branch
BranchTrueFalseTotal
ref $virt_settings ? : 0 0 0
25  
26 0 ▶ unless ($arg1) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($arg1) 0 0 0
27 0 die("You have to define the vm name!");
28 }
29  
30 0 my $dom = $arg1;
31 0 Rex::Logger::debug("setting some options for: $dom");
32  
33 0 for my $opt ( keys %opt ) {
34 0 my $val = $opt{$opt};
35  
36 0 ▶ unless ( exists $FUNC_MAP->{$opt} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $FUNC_MAP->{$opt}) 0 0 0
37 0 Rex::Logger::info("$opt can't be set right now.");
38 0 next;
39 }
40  
41 0 my $func = $FUNC_MAP->{$opt};
42 0 i_run "virsh -c $uri $func '$dom' '$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/destroy.pm ↑ Summary lib/Rex/SCM/Subversion.pm »