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