This commit is contained in:
Quentin Garnier 2013-12-06 12:36:02 +01:00
parent 68271b1d35
commit ad11cdd3b8
4 changed files with 12 additions and 19 deletions

View File

@ -6,7 +6,7 @@ use IO::Socket;
use Getopt::Long; use Getopt::Long;
my $PROGNAME = $0; my $PROGNAME = $0;
my $VERSION = "1.5.2"; my $VERSION = "1.5.3";
my %ERRORS = (OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3, DEPENDENT => 4); my %ERRORS = (OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3, DEPENDENT => 4);
my $socket; my $socket;
my $separatorin = '~'; my $separatorin = '~';
@ -66,7 +66,6 @@ GetOptions(
"nic=s" => \$OPTION{nic}, "nic=s" => \$OPTION{nic},
"older=i" => \$OPTION{older},
"warn" => \$OPTION{warn}, "warn" => \$OPTION{warn},
"crit" => \$OPTION{crit}, "crit" => \$OPTION{crit},
@ -772,30 +771,36 @@ sub listhost_get_str {
} }
sub listdatastore_check_arg { sub listdatastore_check_arg {
if (defined($OPTION{show_attributes})) {
print "<data><element>name</element></data>\n";
}
$OPTION{xml} = (defined($OPTION{xml}) ? 1 : 0); $OPTION{xml} = (defined($OPTION{xml}) ? 1 : 0);
$OPTION{show_attributes} = (defined($OPTION{show_attributes}) ? 1 : 0);
return 0; return 0;
} }
sub listdatastore_get_str { sub listdatastore_get_str {
return join($separatorin, return join($separatorin,
('listdatastore', $OPTION{vsphere}, $OPTION{xml}, $OPTION{show_attributes})); ('listdatastore', $OPTION{vsphere}, $OPTION{xml}));
} }
sub listnichost_check_arg { sub listnichost_check_arg {
if (defined($OPTION{show_attributes})) {
print "<data><element>name</element></data>\n";
exit(0);
}
if (!defined($OPTION{'esx-host'})) { if (!defined($OPTION{'esx-host'})) {
print "Option --esx-host is required\n"; print "Option --esx-host is required\n";
print_usage(); print_usage();
exit $ERRORS{UNKNOWN}; exit $ERRORS{UNKNOWN};
} }
$OPTION{xml} = (defined($OPTION{xml}) ? 1 : 0); $OPTION{xml} = (defined($OPTION{xml}) ? 1 : 0);
$OPTION{show_attributes} = (defined($OPTION{show_attributes}) ? 1 : 0);
return 0; return 0;
} }
sub listnichost_get_str { sub listnichost_get_str {
return join($separatorin, return join($separatorin,
('listnichost', $OPTION{vsphere}, $OPTION{'esx-host'}, $OPTION{xml}, $OPTION{show_attributes})); ('listnichost', $OPTION{vsphere}, $OPTION{'esx-host'}, $OPTION{xml}));
} }
sub getmap_check_arg { sub getmap_check_arg {

View File

@ -20,7 +20,7 @@ BEGIN {
use base qw(centreon::script); use base qw(centreon::script);
use vars qw(%centreonesxd_config); use vars qw(%centreonesxd_config);
my $VERSION = "1.5.2"; my $VERSION = "1.5.3";
my %handlers = (TERM => {}, HUP => {}, CHLD => {}); my %handlers = (TERM => {}, HUP => {}, CHLD => {});
my @load_modules = ('centreon::esxd::cmdcountvmhost', my @load_modules = ('centreon::esxd::cmdcountvmhost',
'centreon::esxd::cmdcpuhost', 'centreon::esxd::cmdcpuhost',

View File

@ -29,17 +29,11 @@ sub checkArgs {
sub initArgs { sub initArgs {
my $self = shift; my $self = shift;
$self->{xml} = (defined($_[0]) && $_[0] == 1) ? 1 : 0; $self->{xml} = (defined($_[0]) && $_[0] == 1) ? 1 : 0;
$self->{show_attributes} = (defined($_[1]) && $_[1] == 1) ? 1 : 0;
} }
sub run { sub run {
my $self = shift; my $self = shift;
if ($self->{show_attributes} == 1) {
$self->{obj_esxd}->print_response(centreon::esxd::common::get_status(0) . "|<data><element>name</element></data>\n");
return ;
}
my %filters = (); my %filters = ();
my @properties = ('summary'); my @properties = ('summary');

View File

@ -36,17 +36,11 @@ sub initArgs {
my $self = shift; my $self = shift;
$self->{lhost} = $_[0]; $self->{lhost} = $_[0];
$self->{xml} = (defined($_[1]) && $_[1] == 1) ? 1 : 0; $self->{xml} = (defined($_[1]) && $_[1] == 1) ? 1 : 0;
$self->{show_attributes} = (defined($_[2]) && $_[2] == 1) ? 1 : 0;
} }
sub run { sub run {
my $self = shift; my $self = shift;
my %nic_in_vswitch = (); my %nic_in_vswitch = ();
if ($self->{show_attributes} == 1) {
$self->{obj_esxd}->print_response(centreon::esxd::common::get_status(0) . "|<data><element>name</element></data>\n");
return ;
}
my %filters = ('name' => $self->{lhost}); my %filters = ('name' => $self->{lhost});
my @properties = ('config.network.pnic', 'config.network.vswitch', 'config.network.proxySwitch'); my @properties = ('config.network.pnic', 'config.network.vswitch', 'config.network.proxySwitch');