Skip to content

Commit

Permalink
fix: Avoid an error when a vm includes more than one dns config
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bougard committed Dec 5, 2024
1 parent 640c232 commit 88d464e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/GLPI/Agent/SOAP/VMware/Host.pm
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,12 @@ sub getVirtualMachines {
unless (empty($machine->{guest}{hostName})) {
$vmInventory->{OPERATINGSYSTEM}->{FQDN} = $machine->{guest}{hostName};
}
unless (empty($machine->{guest}{net}{dnsConfig}{domainName})) {
$vmInventory->{OPERATINGSYSTEM}->{DNS_DOMAIN} = $machine->{guest}{net}{dnsConfig}{domainName};
if (ref($machine->{guest}{net}{dnsConfig})) {
my $dnsConfig = ref($machine->{guest}{net}{dnsConfig}) eq 'HASH' ?
$machine->{guest}{net}{dnsConfig} : $machine->{guest}{net}{dnsConfig}->[0];
if (ref($dnsConfig) eq 'HASH' && !empty($dnsConfig->{domainName})) {
$vmInventory->{OPERATINGSYSTEM}->{DNS_DOMAIN} = $dnsConfig->{domainName};
}
}
unless (empty($machine->{summary}{runtime}{bootTime})) {
$vmInventory->{OPERATINGSYSTEM}->{BOOT_TIME} = $machine->{summary}{runtime}{bootTime};
Expand Down

0 comments on commit 88d464e

Please sign in to comment.