fix(primera-restapi): retry authentication when the token is invalid/expired (#5267)
Co-authored-by: Roman Morandell <46994680+rmorandell-pgum@users.noreply.github.com> Refs: CTOR-1032
This commit is contained in:
parent
fe581afd0b
commit
790c96d3ac
|
@ -175,6 +175,21 @@ sub request_api {
|
||||||
critical_status => ''
|
critical_status => ''
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Maybe token is invalid. so we retry
|
||||||
|
if (!defined($token) || $self->{http}->get_code() >= 400) {
|
||||||
|
$self->clean_token();
|
||||||
|
$token = $self->get_token();
|
||||||
|
|
||||||
|
$content = $self->{http}->request(
|
||||||
|
url_path => $options{endpoint},
|
||||||
|
get_param => $get_param,
|
||||||
|
header => [ 'X-HP3PAR-WSAPI-SessionKey: ' . $token ],
|
||||||
|
unknown_status => $self->{unknown_http_status},
|
||||||
|
warning_status => $self->{warning_http_status},
|
||||||
|
critical_status => $self->{critical_http_status}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!defined($content) || $content eq '') {
|
if (!defined($content) || $content eq '') {
|
||||||
$self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");
|
$self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
|
|
Loading…
Reference in New Issue