From d335a5577442ffb7a81f398b214633e8224d50db Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 25 Sep 2019 16:22:06 +0200 Subject: [PATCH] fix hp oneview + vmware vcsa --- apps/vmware/vcsa/restapi/custom/api.pm | 2 +- hardware/server/hp/oneview/restapi/custom/api.pm | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/vmware/vcsa/restapi/custom/api.pm b/apps/vmware/vcsa/restapi/custom/api.pm index dd931bb13..7d5a91349 100644 --- a/apps/vmware/vcsa/restapi/custom/api.pm +++ b/apps/vmware/vcsa/restapi/custom/api.pm @@ -208,7 +208,7 @@ sub request_api { # Maybe there is an issue with the session_id. So we retry. if ($self->{http}->get_code() != 200) { - $self->clean_session_id(); + $self->clean_session_id(statefile => $self->{cache}); $self->authenticate(statefile => $self->{cache}); $content = $self->{http}->request(%options, warning_status => '', unknown_status => '', critical_status => '' diff --git a/hardware/server/hp/oneview/restapi/custom/api.pm b/hardware/server/hp/oneview/restapi/custom/api.pm index 9568c7cdc..456049b09 100644 --- a/hardware/server/hp/oneview/restapi/custom/api.pm +++ b/hardware/server/hp/oneview/restapi/custom/api.pm @@ -154,15 +154,15 @@ sub clean_session_id { my ($self, %options) = @_; my $datas = { last_timestamp => time() }; - $options{statefile}->write(data => $datas); + $self->{cache}->write(data => $datas); $self->{session_id} = undef; } sub authenticate { my ($self, %options) = @_; - my $has_cache_file = $options{statefile}->read(statefile => 'hp_oneview_' . md5_hex($self->{option_results}->{hostname}) . '_' . md5_hex($self->{option_results}->{api_username})); - my $session_id = $options{statefile}->get(name => 'session_id'); + my $has_cache_file = $self->{cache}->read(statefile => 'hp_oneview_' . md5_hex($self->{option_results}->{hostname}) . '_' . md5_hex($self->{option_results}->{api_username})); + my $session_id = $self->{cache}->get(name => 'session_id'); if ($has_cache_file == 0 || !defined($session_id)) { my $json_request = { userName => $self->{api_username}, password => $self->{api_password} }; @@ -196,7 +196,7 @@ sub authenticate { } my $datas = { last_timestamp => time(), session_id => $session_id }; - $options{statefile}->write(data => $datas); + $self->{cache}->write(data => $datas); } $self->{session_id} = $session_id; @@ -207,7 +207,7 @@ sub request_api { $self->settings(); if (!defined($self->{session_id})) { - $self->authenticate(statefile => $self->{cache}); + $self->authenticate(); } my $content = $self->{http}->request( %options, @@ -217,7 +217,7 @@ sub request_api { # Maybe there is an issue with the session_id. So we retry. if ($self->{http}->get_code() != 200) { $self->clean_session_id(); - $self->authenticate(statefile => $self->{cache}); + $self->authenticate(); $content = $self->{http}->request(%options, warning_status => '', unknown_status => '', critical_status => '' );