| 1 | # | ||||||||||
| 2 | # (c) Zane C. Bowers-Hadley <vvelox@vvelox.net> | ||||||||||
| 3 | # | ||||||||||
| 4 | |||||||||||
| 5 | package Rex::Virtualization::CBSD::bnic_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=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 17 | 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 | ▶ | if ( $? != 0 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 1; | |||||||||