From 8bb6cf95e900ac08f297ed670516c65f831646e5 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 27 Mar 2017 13:27:25 +0200 Subject: [PATCH] + Fix hyperv plugin --- apps/hyperv/2012/local/mode/scvmmintegrationservice.pm | 6 ++++-- centreon/common/powershell/hyperv/2012/nodesnapshot.pm | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/hyperv/2012/local/mode/scvmmintegrationservice.pm b/apps/hyperv/2012/local/mode/scvmmintegrationservice.pm index e7c6a78a5..fbaf574c5 100644 --- a/apps/hyperv/2012/local/mode/scvmmintegrationservice.pm +++ b/apps/hyperv/2012/local/mode/scvmmintegrationservice.pm @@ -182,15 +182,17 @@ sub manage_selection { my %values = (vm => $1, description => $2, status => $3, cloud => $4, hostgroup => $5, vmaddition => $6); $values{hostgroup} =~ s/\\/\//g; + my $filtered = 0; foreach (('name', 'description', 'status', 'hostgroup')) { if (defined($self->{option_results}->{'filter_' . $_}) && $self->{option_results}->{'filter_' . $_} ne '' && $values{$_} !~ /$self->{option_results}->{'filter_' . $_}/i) { $self->{output}->output_add(long_msg => "skipping '" . $values{$_} . "': no matching filter.", debug => 1); - next; + $filtered = 1; + last; } } - $self->{vm}->{$id} = { %values }; + $self->{vm}->{$id} = { %values } if ($filtered == 0); $id++; } } diff --git a/centreon/common/powershell/hyperv/2012/nodesnapshot.pm b/centreon/common/powershell/hyperv/2012/nodesnapshot.pm index ac25769a7..805d4a77a 100644 --- a/centreon/common/powershell/hyperv/2012/nodesnapshot.pm +++ b/centreon/common/powershell/hyperv/2012/nodesnapshot.pm @@ -38,8 +38,10 @@ $ProgressPreference = "SilentlyContinue" Try { $ErrorActionPreference = "Stop" $vms = Get-VM - $snapshots = Get-VMSnapshot -VMName * - + if ($vms.Length -gt 0) { + $snapshots = Get-VMSnapshot -VMName * + } + Foreach ($vm in $vms) { $i=0 Foreach ($snap in $snapshots) {