line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Zane C. Bowers-Hadley |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Virtualization::CBSD::binfo; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
68689
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.0.1'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
474
|
use Rex::Logger; |
|
1
|
|
|
|
|
11532
|
|
|
1
|
|
|
|
|
46
|
|
13
|
1
|
|
|
1
|
|
611
|
use Rex::Helper::Run; |
|
1
|
|
|
|
|
79510
|
|
|
1
|
|
|
|
|
72
|
|
14
|
1
|
|
|
1
|
|
10
|
use Term::ANSIColor qw(colorstrip); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1160
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub execute { |
17
|
0
|
|
|
0
|
0
|
|
my ( $class, $name ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
if ( !defined($name) ) { |
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
|
0
|
|
|
|
|
if ( $returned =~ /^No\ such/ ) { |
31
|
0
|
|
|
|
|
|
die( '"' . $name . '" does not exist' ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# check for this second as no VM will also exit non-zero |
35
|
0
|
0
|
|
|
|
|
if ( $? != 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; |