diff --git a/lib/GLPI/Agent/SOAP/VMware/Host.pm b/lib/GLPI/Agent/SOAP/VMware/Host.pm index 25859d70c..2938ee183 100644 --- a/lib/GLPI/Agent/SOAP/VMware/Host.pm +++ b/lib/GLPI/Agent/SOAP/VMware/Host.pm @@ -5,6 +5,7 @@ use warnings; use GLPI::Agent::Tools; use GLPI::Agent::Tools::Virtualization; +use GLPI::Agent::Tools::UUID; sub new { my ($class, %params) = @_; @@ -392,21 +393,23 @@ sub getVirtualMachines { } # Compute serialnumber set in bios by ESX - my @uuid_parts = unpack("A2A2A2A2xA2A2xA2A2xA2A2xA2A2A2A2A2A2", $machine->{summary}{config}{uuid}); - my $serial = "VMware-".join(' ', @uuid_parts[0..7]).'-'.join(' ', @uuid_parts[8..15]); - - push @virtualMachines, - { + my $uuid = $machine->{summary}{config}{uuid}; + my $vmInventory = { NAME => $machine->{name}, STATUS => $status, - UUID => $machine->{summary}{config}{uuid}, - SERIAL => $serial, + UUID => $uuid, MEMORY => $machine->{summary}{config}{memorySizeMB}, VMTYPE => 'VMware', VCPU => $machine->{summary}{config}{numCpu}, MAC => join( '/', @mac ), COMMENT => $comment - }; + }; + if (is_uuid_string($uuid)) { + my @uuid_parts = unpack("A2A2A2A2xA2A2xA2A2xA2A2xA2A2A2A2A2A2", $uuid); + $vmInventory->{SERIAL} = "VMware-".join(' ', @uuid_parts[0..7]).'-'.join(' ', @uuid_parts[8..15]); + } + + push @virtualMachines, $vmInventory; } return @virtualMachines;