Skip to content

Commit

Permalink
Added automatic handling of 403.4 (no session ID provided)
Browse files Browse the repository at this point in the history
Details:

* In addition to 403.5 (session ID invalid), 403.4 (no session ID provided) is
  now also automatically handled by the zhmcclient in the same way, i.e. by
  performing a logon to the HMC and a retry of the HMC operation.

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed May 26, 2023
1 parent d8746d6 commit dca8d5b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ Released: not yet
Improved and fixed the descriptions of Session.logon(), logoff(), is_logon()
and session_id.

* In addition to 403.5 (session ID invalid), 403.4 (no session ID provided) is
now also automatically handled by the zhmcclient in the same way, i.e. by
performing a logon to the HMC and a retry of the HMC operation.

**Enhancements:**

**Cleanup:**
Expand Down
18 changes: 12 additions & 6 deletions zhmcclient/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,10 @@ def get(self, uri, logon_required=True, renew_session=True):
if result.status_code == 403:
result_object = _result_object(result)
reason = result_object.get('reason', None)
if reason == 5:
# API session token expired: re-logon and retry

if reason in (4, 5):
# 403.4: No session ID was provided
# 403.5: Session ID was invalid
if renew_session:
self._do_logon()
return self.get(
Expand Down Expand Up @@ -1239,8 +1241,10 @@ def post(self, uri, body=None, logon_required=True,
if result.status_code == 403:
result_object = _result_object(result)
reason = result_object.get('reason', None)
if reason == 5:
# API session token expired: re-logon and retry

if reason in (4, 5):
# 403.4: No session ID was provided
# 403.5: Session ID was invalid
if renew_session:
self._do_logon()
return self.post(
Expand Down Expand Up @@ -1334,8 +1338,10 @@ def delete(self, uri, logon_required=True, renew_session=True):
if result.status_code == 403:
result_object = _result_object(result)
reason = result_object.get('reason', None)
if reason == 5:
# API session token expired: re-logon and retry

if reason in (4, 5):
# 403.4: No session ID was provided
# 403.5: Session ID was invalid
if renew_session:
self._do_logon()
self.delete(uri, logon_required=False, renew_session=False)
Expand Down

0 comments on commit dca8d5b

Please sign in to comment.