line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Zane C. Bowers-Hadley |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Virtualization::CBSD::p9shares_list; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
69137
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.0.1'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
439
|
use Rex::Logger; |
|
1
|
|
|
|
|
10589
|
|
|
1
|
|
|
|
|
37
|
|
13
|
1
|
|
|
1
|
|
422
|
use Rex::Helper::Run; |
|
1
|
|
|
|
|
77009
|
|
|
1
|
|
|
|
|
71
|
|
14
|
1
|
|
|
1
|
|
8
|
use Term::ANSIColor qw(colorstrip); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2072
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub execute { |
17
|
0
|
|
|
0
|
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
|
0
|
|
|
|
|
if ( $? != 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
|
0
|
0
|
|
|
|
if ( ( $share{vm} !~ /^$/ ) |
|
|
|
0
|
|
|
|
|
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; |