From 1f3a3465aac53d389bacfd28235cca8e9d9961d1 Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Thu, 28 Nov 2013 09:58:41 +0000 Subject: [PATCH] Fix #6269 #6270 git-svn-id: http://svn.merethis.net/centreon-esxd/trunk@89 a5eaa968-4c79-4d68-970d-af6011b5b055 --- connectors/vmware/centreon_esxd-init | 2 +- connectors/vmware/lib/cmdlistnichost.pm | 22 +++++++++++++++++----- connectors/vmware/lib/cmdnethost.pm | 22 +++++++++++++++++----- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/connectors/vmware/centreon_esxd-init b/connectors/vmware/centreon_esxd-init index 501485599..1f36789de 100644 --- a/connectors/vmware/centreon_esxd-init +++ b/connectors/vmware/centreon_esxd-init @@ -19,7 +19,7 @@ timeout=60 pidfile=/var/run/centreon_esxd.pid -[ -e /etc/sysconfig/$servicename ] && . /etc/sysconfig/$servicename +[ -e /etc/sysconfig/centreon_esxd ] && . /etc/sysconfig/centreon_esxd # Check if we can find the binary. if [ ! -x $binary ]; then diff --git a/connectors/vmware/lib/cmdlistnichost.pm b/connectors/vmware/lib/cmdlistnichost.pm index 7c0e94192..e129b188f 100644 --- a/connectors/vmware/lib/cmdlistnichost.pm +++ b/connectors/vmware/lib/cmdlistnichost.pm @@ -49,23 +49,35 @@ sub run { } my %filters = ('name' => $self->{lhost}); - my @properties = ('config.network.pnic', 'config.network.vswitch'); + my @properties = ('config.network.pnic', 'config.network.vswitch', 'config.network.proxySwitch'); my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'HostSystem', \%filters, \@properties); if (!defined($result)) { return ; } # Get Name from vswitch - foreach (@{$$result[0]->{'config.network.vswitch'}}) { - foreach my $keynic (@{$_->pnic}) { - $nic_in_vswitch{$keynic} = 1; + if (defined($$result[0]->{'config.network.vswitch'})) { + foreach (@{$$result[0]->{'config.network.vswitch'}}) { + next if (!defined($_->{pnic})); + foreach my $keynic (@{$_->{pnic}}) { + $nic_in_vswitch{$keynic} = 1; + } + } + } + # Get Name from proxySwitch + if (defined($$result[0]->{'config.network.proxySwitch'})) { + foreach (@{$$result[0]->{'config.network.proxySwitch'}}) { + next if (!defined($_->{pnic})); + foreach my $keynic (@{$_->{pnic}}) { + $nic_in_vswitch{$keynic} = 1; + } } } my $status = 0; # OK my $output_up = 'Nic Up List: '; my $output_down = 'Nic Down List: '; - my $output_down_no_vswitch = 'Nic Down List (not in vswitch): '; + my $output_down_no_vswitch = 'Nic Down List (not in vswitch, dvswitch): '; my $output_up_append = ""; my $output_down_append = ""; my $output_down_no_vswitch_append = ""; diff --git a/connectors/vmware/lib/cmdnethost.pm b/connectors/vmware/lib/cmdnethost.pm index fc4343e90..6d1271e4e 100644 --- a/connectors/vmware/lib/cmdnethost.pm +++ b/connectors/vmware/lib/cmdnethost.pm @@ -68,7 +68,7 @@ sub run { } my %filters = ('name' => $self->{lhost}); - my @properties = ('config.network.pnic', 'runtime.connectionState', 'config.network.vswitch'); + my @properties = ('config.network.pnic', 'runtime.connectionState', 'config.network.vswitch', 'config.network.proxySwitch'); my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'HostSystem', \%filters, \@properties); if (!defined($result)) { return ; @@ -84,9 +84,21 @@ sub run { my $filter_ok = 0; # Get Name from vswitch - foreach (@{$$result[0]->{'config.network.vswitch'}}) { - foreach my $keynic (@{$_->pnic}) { - $nic_in_vswitch{$keynic} = 1; + if (defined($$result[0]->{'config.network.vswitch'})) { + foreach (@{$$result[0]->{'config.network.vswitch'}}) { + next if (!defined($_->{pnic})); + foreach my $keynic (@{$_->{pnic}}) { + $nic_in_vswitch{$keynic} = 1; + } + } + } + # Get Name from proxySwitch + if (defined($$result[0]->{'config.network.proxySwitch'})) { + foreach (@{$$result[0]->{'config.network.proxySwitch'}}) { + next if (!defined($_->{pnic})); + foreach my $keynic (@{$_->{pnic}}) { + $nic_in_vswitch{$keynic} = 1; + } } } @@ -111,7 +123,7 @@ sub run { if ($filter_ok == 0) { my $status = centreon::esxd::common::errors_mask(0, 'UNKNOWN'); - $self->{obj_esxd}->print_response(centreon::esxd::common::get_status($status) . "|Can't get physical nic with filter '$self->{pnic}'. (or physical nic not in a vswitch)\n"); + $self->{obj_esxd}->print_response(centreon::esxd::common::get_status($status) . "|Can't get physical nic with filter '$self->{pnic}'. (or physical nic not in a 'vswitch' or 'dvswitch')\n"); return ; } if ($#${instances} == -1) {