line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Zane C. Bowers-Hadley |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Virtualization::CBSD::bnic_list; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
67012
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.0.1'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
423
|
use Rex::Logger; |
|
1
|
|
|
|
|
10487
|
|
|
1
|
|
|
|
|
38
|
|
13
|
1
|
|
|
1
|
|
402
|
use Rex::Helper::Run; |
|
1
|
|
|
|
|
76047
|
|
|
1
|
|
|
|
|
75
|
|
14
|
1
|
|
|
1
|
|
9
|
use Term::ANSIColor qw(colorstrip); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2169
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub execute { |
17
|
0
|
|
|
0
|
0
|
|
my ($class) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
Rex::Logger::debug("Getting CBSD NIC list"); |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my @nics; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $command='cbsd bhyve-nic-list display=nodename,jname,nic_driver,nic_parent,nic_hwaddr,nic_address,nic_mtu,nic_persistent,nic_ratelimit header=0'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# header=0 is needed to avoid including code to exclude it |
26
|
|
|
|
|
|
|
# if display= is changed, the parsing order needs updated |
27
|
0
|
|
|
|
|
|
my $found = i_run( $command, fail_ok => 1 ); |
28
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
29
|
0
|
|
|
|
|
|
die( "Error running '", $command . "'" ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# remove it here so the data can be safely used else where |
33
|
0
|
|
|
|
|
|
$found = colorstrip($found); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my @found_lines = split( /\n/, $found ); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
foreach my $line (@found_lines) { |
38
|
0
|
|
|
|
|
|
my %nic; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# needs to be updated if display= is ever changed |
41
|
|
|
|
|
|
|
( |
42
|
|
|
|
|
|
|
$nic{node}, $nic{'vm'}, $nic{'driver'}, $nic{'parent'}, $nic{'hwaddr'}, |
43
|
0
|
|
|
|
|
|
$nic{'address'}, $nic{'mtu'}, $nic{'persistent'}, $nic{'ratelimit'} |
44
|
|
|
|
|
|
|
) = split( /[\ \t]+/, $line ); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
push( @nics, \%nic ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return \@nics; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |