lib/Rex/Virtualization/LibVirt/start.pm

filter: Statementstmt 50.0% 13 / 26 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 42.5% 17 / 40 CC 5 SCAR 28.4
CC
5
Cov
38%
execute
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 17.1
« lib/Rex/Commands.pm ↑ Summary lib/Rex/Virtualization/LibVirt/delete.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Virtualization::LibVirt::start;
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=5 SCAR=34.0
Pod undocumented
16 0 my ( $class, $arg1, %opt ) = @_;
17 0 my $virt_settings = Rex::Config->get("virtualization");
18  
19 0 Rex::Logger::debug("Starting vm: $arg1");
20  
21 chomp( my $uri =
22 0 ▶ ref($virt_settings) ? $virt_settings->{connect} : i_run "virsh uri" );
Branch: 1 branch
BranchTrueFalseTotal
ref $virt_settings ? : 0 0 0
23  
24 0 ▶ unless ($arg1) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($arg1) 0 0 0
25 0 die("You have to define the vm name!");
26 }
27  
28 0 my $dom = $arg1;
29 0 Rex::Logger::debug("starting domain: $dom");
30  
31 0 ▶ unless ($dom) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dom) 0 0 0
32 0 die("VM $dom not found.");
33 }
34  
35 0 my $output = i_run "virsh -c $uri start '$dom' 2>&1", fail_ok => 1;
36 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
37 0 die("Error starting vm $dom\nError: $output");
38 }
39  
40 }
41  
42 1 1;
« lib/Rex/Commands.pm ↑ Summary lib/Rex/Virtualization/LibVirt/delete.pm »