(plugin) hardware::server::hp::ilo::restapi - mode hardware ignore som… (#4349)

This commit is contained in:
qgarnier 2023-04-18 14:10:11 +02:00 committed by GitHub
parent 43e63fb4ac
commit 9665ea68c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 6 deletions

View File

@ -84,7 +84,12 @@ sub get_devices {
$self->get_chassis() if (!defined($self->{chassis}));
foreach my $chassis (@{$self->{chassis}}) {
$chassis->{Devices} = [];
my $result = $self->{custom}->request_api(url_path => $chassis->{'@odata.id'} . 'Devices/');
my $result = $self->{custom}->request_api(
url_path => $chassis->{'@odata.id'} . 'Devices/',
ignore_codes => { 404 => 1 }
);
next if (!defined($result));
foreach (@{$result->{Members}}) {
my $device_detailed = $self->{custom}->request_api(url_path => $_->{'@odata.id'});
push @{$chassis->{Devices}}, $device_detailed;
@ -135,7 +140,12 @@ sub get_storages {
$self->{storages} = [];
my $systems = $self->{custom}->request_api(url_path => '/redfish/v1/Systems');
foreach my $system (@{$systems->{Members}}) {
my $storages = $self->{custom}->request_api(url_path => $system->{'@odata.id'} . '/Storage/');
my $storages = $self->{custom}->request_api(
url_path => $system->{'@odata.id'} . '/Storage/',
ignore_codes => { 400 => 1, 404 => 1 }
);
next if (!defined($storages));
foreach my $storage (@{$storages->{Members}}) {
my $storage_detailed = $self->{custom}->request_api(url_path => $storage->{'@odata.id'});
push @{$self->{storages}}, $storage_detailed;

View File

@ -191,26 +191,34 @@ sub request_api {
$self->authenticate(statefile => $self->{cache});
}
my $content = $self->{http}->request(%options,
my $content = $self->{http}->request(
%options,
warning_status => '', unknown_status => '', critical_status => ''
);
my $code = $self->{http}->get_code();
return undef if (defined($options{ignore_codes}) && defined($options{ignore_codes}->{$code}));
# Maybe there is an issue with the token. So we retry.
if ($self->{http}->get_code() < 200 || $self->{http}->get_code() >= 300) {
if ($code < 200 || $code >= 300) {
$self->clean_token(statefile => $self->{cache});
$self->authenticate(statefile => $self->{cache});
$content = $self->{http}->request(%options,
$content = $self->{http}->request(
%options,
warning_status => '', unknown_status => '', critical_status => ''
);
$code = $self->{http}->get_code();
}
return undef if (defined($options{ignore_codes}) && defined($options{ignore_codes}->{$code}));
my $decoded = $self->json_decode(content => $content);
if (!defined($decoded)) {
$self->{output}->add_option_msg(short_msg => "Error while retrieving data (add --debug option for detailed message)");
$self->{output}->option_exit();
}
if ($self->{http}->get_code() < 200 || $self->{http}->get_code() >= 300) {
if ($code < 200 || $code >= 300) {
$self->{output}->add_option_msg(short_msg => 'api request error: ' . (defined($decoded->{type}) ? $decoded->{type} : 'unknown'));
$self->{output}->option_exit();
}