diff --git a/apps/microsoft/hyperv/2012/local/mode/scvmmdiscovery.pm b/apps/microsoft/hyperv/2012/local/mode/scvmmdiscovery.pm index 2cb55cf3e..79cef68ec 100644 --- a/apps/microsoft/hyperv/2012/local/mode/scvmmdiscovery.pm +++ b/apps/microsoft/hyperv/2012/local/mode/scvmmdiscovery.pm @@ -146,8 +146,8 @@ sub run { my $disco_stats; foreach my $entry (@$decoded) { my $item = {}; - $item->{type} = $entry->{type}; + $item->{type} = $entry->{type}; if ($self->{option_results}->{resource_type} eq 'vm' && $entry->{type} eq 'vm') { $item->{id} = $entry->{vmId}; $item->{name} = $entry->{name}; @@ -158,9 +158,12 @@ sub run { $item->{enabled} = ($entry->{enabled} =~ /True|1/i) ? 'yes' : 'no'; $item->{computer_name} = $entry->{computerName}; $item->{tag} = $entry->{tag}; + $entry->{ipv4Addresses} = [$entry->{ipv4Addresses}] if (ref($entry->{ipv4Addresses}) ne 'ARRAY'); $item->{ipv4_addresses} = $entry->{ipv4Addresses}; + $item->{ipv4_address} = defined($entry->{ipv4Addresses}->[0]) ? $entry->{ipv4Addresses}->[0] : ''; $item->{vmhost_name} = $hosts->{ $entry->{vmHostId} }->{name}; $item->{cluster_name} = $hosts->{ $entry->{vmHostId} }->{cluster_name}; + push @$disco_data, $item; } elsif ($self->{option_results}->{resource_type} eq 'host' && $entry->{type} eq 'host') { $item->{id} = $entry->{id}; $item->{name} = $entry->{name}; @@ -168,9 +171,8 @@ sub run { $item->{fqdn} = $entry->{FQDN}; $item->{cluster_name} = $entry->{clusterName}; $item->{operating_system} = $entry->{operatingSystem}; + push @$disco_data, $item; } - - push @$disco_data, $item; } $disco_stats->{end_time} = time(); diff --git a/centreon/common/powershell/hyperv/2012/scvmmdiscovery.pm b/centreon/common/powershell/hyperv/2012/scvmmdiscovery.pm index 79040171d..48d6dee8b 100644 --- a/centreon/common/powershell/hyperv/2012/scvmmdiscovery.pm +++ b/centreon/common/powershell/hyperv/2012/scvmmdiscovery.pm @@ -68,7 +68,7 @@ Try { $item.enabled = $vm.enabled $item.computerName = $vm.ComputerName $item.tag = $vm.Tag - $item.vmHostId = $vm.VMHost.ID + $item.vmHostId = $vm.VMHost.ID.Guid $ipv4Addresses = @() if ($vm.Status -eq "Running") { @@ -81,18 +81,18 @@ Try { $items.Add($item) } - $hosts = Get-SCVmHost -VMMServer $connection - Foreach ($host in $hosts) { + $vmhosts = Get-SCVmHost -VMMServer $connection + Foreach ($vmhost in $vmhosts) { $item = @{} $item.type = "host" - $item.id = $host.ID - $item.name = $host.Name + $item.id = $vmhost.ID.Guid + $item.name = $vmhost.Name $desc = $host.Description -replace "\r","" $item.description = $desc - $item.FQDN = $host.FQDN - $item.clusterName = $host.HostCluster.Name - $item.operatingSystem = $host.OperatingSystem.Name + $item.FQDN = $vmhost.FQDN + $item.clusterName = $vmhost.HostCluster.Name + $item.operatingSystem = $vmhost.OperatingSystem.Name $items.Add($item) }