From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

#
# (c) Jan Gehring <jan.gehring@gmail.com>
#
use v5.12.5;
our $VERSION = '1.15.0.2'; # TRIAL VERSION
sub execute {
shift;
my $vmname = shift;
my %options = @_;
unless ($vmname) {
die("You have to define the vm name!");
}
my $ref = Rex::Virtualization::LibVirt::dumpxml->execute($vmname);
my $interfaces = $ref->{devices}->{interface};
if ( ref $interfaces ne "ARRAY" ) {
$interfaces = [$interfaces];
}
my %ret = ();
my $iface_num = 0;
for my $iface ( @{$interfaces} ) {
$ret{"vnet$iface_num"} = {
type => $iface->{model}->{type},
source => $iface->{source}->{network},
model => $iface->{model}->{type},
mac => $iface->{mac}->{address},
};
$iface_num++;
}
return \%ret;
}
1;