File Coverage

lib/Rex/Virtualization/VBox/bridge.pm
Criterion Covered Total %
statement 14 31 45.1
branch 0 10 0.0
condition n/a
subroutine 5 6 83.3
pod 0 1 0.0
total 19 48 39.5


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Virtualization::VBox::bridge;
6              
7 1     1   15 use v5.12.5;
  1         3  
8 1     1   5 use warnings;
  1         2  
  1         56  
9              
10             our $VERSION = '1.14.2.2'; # TRIAL VERSION
11              
12 1     1   7 use Rex::Logger;
  1         2  
  1         7  
13 1     1   41 use Rex::Helper::Run;
  1         4  
  1         67  
14              
15 1     1   7 use Data::Dumper;
  1         3  
  1         358  
16              
17             sub execute {
18 0     0 0   my $class = shift;
19              
20 0           my $result = i_run "VBoxManage list bridgedifs", fail_ok => 1;
21 0 0         if ( $? != 0 ) {
22 0           die("Error running VBoxManage list bridgedifs");
23             }
24              
25 0           my @ifs;
26 0           my @blocks = split /\n\n/m, $result;
27 0           for my $block (@blocks) {
28              
29 0           my $if = {};
30 0           my @lines = split /\n/, $block;
31 0           for my $line (@lines) {
32 0 0         if ( $line =~ /^Name:\s+(.+?)$/ ) {
    0          
    0          
    0          
33 0           $if->{name} = $1;
34             }
35             elsif ( $line =~ /^IPAddress:\s+(.+?)$/ ) {
36 0           $if->{ip} = $1;
37             }
38             elsif ( $line =~ /^NetworkMask:\s+(.+?)$/ ) {
39 0           $if->{netmask} = $1;
40             }
41             elsif ( $line =~ /^Status:\s+(.+?)$/ ) {
42 0           $if->{status} = $1;
43             }
44             }
45              
46 0           push @ifs, $if;
47             }
48              
49 0           return \@ifs;
50             }
51              
52             1;