CBSD/p9shares_list.pm

filter: Statementstmt 53.1% 17 / 32 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 42.3% 22 / 52 CC 6 SCAR 31.5
CC
6
Cov
40%
execute
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 23.4
« CBSD/p9shares_add.pm ↑ Summary CBSD/bsnapshot_create.pm »
1 #
2 # (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
3 #
4  
5 package Rex::Virtualization::CBSD::p9shares_list;
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=6 SCAR=37.4
Pod undocumented
17 0 my ($class) = @_;
18  
19 0 my $command = 'cbsd bhyve-p9shares mode=list header=0 display=jname,p9device,p9path';
20  
21 0 Rex::Logger::debug( "Getting CBSD p9shares info via... " . $command );
22  
23 0 my $returned = i_run( $command, fail_ok => 1 );
24  
25 # the output is colorized, if there is an error
26 0 $returned = colorstrip($returned);
27  
28 # check for this second as no VM will also exit non-zero
29 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
30 0 die( "Error running '" . $command . "'" );
31 }
32  
33 0 my @shares;
34 0 my @lines = split( /\n/, $returned );
35 0 foreach my $line (@lines) {
36 0 my %share;
37 0 ( $share{vm}, $share{device}, $share{path} ) = split( /\:\ /, $line, 3 );
38  
39 # make sure we did not get a empty line, which it will return if there is none
40 0 ▶ if ( ( $share{vm} !~ /^$/ )
Branch: 1 branch
BranchTrueFalseTotal
unless ($share{"vm"} =~ /^$/ and defined $share{"evice"} and defined $share{"path"}) 0 0 0
Condition0%0/6
$share{"vm"} =~ /^$/ and defined $share{"evice"} and defined $share{"path"}
!ll&&!rl&&r
000
$share{"vm"} =~ /^$/ and defined $share{"evice"}
!ll&&!rl&&r
000
MC/DC0%0/3
$share{"vm"} =~ /^$/ and defined $share{"evice"} and defined $share{"path"}
$share{"vm"} =~ /^$/ defined $share{"evice"} defined $share{"path"}
Truth table0%0/4
A and B and C
A= $share{"vm"} =~ /^$/B= defined $share{"evice"}C= defined $share{"path"}
ABCresult
0XX0
10X0
1100
1111
41 || ( !defined( $share{evice} ) )
42 || ( !defined( $share{path} ) ) )
43 {
44 0 push( @shares, \%share );
45 }
46 }
47  
48 0 return @shares;
49 }
50  
51 1 1;
« CBSD/p9shares_add.pm ↑ Summary CBSD/bsnapshot_create.pm »