CBSD/binfo.pm

filter: Statementstmt 51.5% 17 / 33 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 47.8% 22 / 46 CC 5 SCAR 27.4
CC
5
Cov
44%
execute
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 15.5
« CBSD/freejname.pm ↑ Summary CBSD/p9shares_rm.pm »
1 #
2 # (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
3 #
4  
5 package Rex::Virtualization::CBSD::binfo;
6  
7 1 ▶use strict;
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 = '0.0.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 1 ▶use Term::ANSIColor qw(colorstrip);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶sub execute {
Subroutine execute: not called CC=5 SCAR=34.0
Pod undocumented
17 0 my ( $class, $name ) = @_;
18  
19 0 ▶ if ( !defined($name) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 0 0 0
20 0 die('No VM name defined');
21 }
22  
23 0 Rex::Logger::debug( "CBSD VM info via cbsd bget jname=" . $name );
24  
25 #
26 0 my $returned = i_run( 'cbsd bget jname=' . $name, fail_ok => 1 );
27  
28 # the output is colorized, if there is an error
29 0 $returned = colorstrip($returned);
30 0 ▶ if ( $returned =~ /^No\ such/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($returned =~ /^No\ such/) 0 0 0
31 0 die( '"' . $name . '" does not exist' );
32 }
33  
34 # check for this second as no VM will also exit non-zero
35 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
36 0 die( "Error running 'cbsd bget jname=" . $name . "'" );
37 }
38  
39 0 my %info;
40 0 my @lines = split( /\n/, $returned );
41 0 foreach my $line (@lines) {
42 0 my ( $vname, $vval ) = split( /\:\ /, $line );
43 0 $info{$vname} = $vval;
44 }
45  
46 0 return \%info;
47 }
48  
49 1 1;
« CBSD/freejname.pm ↑ Summary CBSD/p9shares_rm.pm »