| 1 | # | ||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||
| 3 | # | ||||||||||
| 4 | |||||||||||
| 5 | package Rex::Virtualization::LibVirt::iflist; | ||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use v5.14.4; | ||||||||
|
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 = '1.16.1'; # VERSION | |||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use Rex::Logger; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use Rex::Virtualization::LibVirt::dumpxml; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 0 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 18 | 0 | shift; | |||||||||
| 19 | 0 | my $vmname = shift; | |||||||||
| 20 | 0 | my %options = @_; | |||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | unless ($vmname) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | die("You have to define the vm name!"); | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | my $ref = Rex::Virtualization::LibVirt::dumpxml->execute($vmname); | |||||||||
| 27 | |||||||||||
| 28 | 0 | my $interfaces = $ref->{devices}->{interface}; | |||||||||
| 29 | 0 | ▶ | if ( ref $interfaces ne "ARRAY" ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 0 | $interfaces = [$interfaces]; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 0 | my %ret = (); | |||||||||
| 34 | 0 | my $iface_num = 0; | |||||||||
| 35 | 0 | for my $iface ( @{$interfaces} ) { | |||||||||
| 36 | $ret{"vnet$iface_num"} = { | ||||||||||
| 37 | type => $iface->{model}->{type}, | ||||||||||
| 38 | source => $iface->{source}->{network}, | ||||||||||
| 39 | model => $iface->{model}->{type}, | ||||||||||
| 40 | mac => $iface->{mac}->{address}, | ||||||||||
| 41 | 0 | }; | |||||||||
| 42 | |||||||||||
| 43 | 0 | $iface_num++; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 0 | return \%ret; | |||||||||
| 47 | |||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 1 | 1; | |||||||||