How to use the zhmcclient._exceptions.ServerAuthError function in zhmcclient

To help you get started, we’ve selected a few zhmcclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zhmcclient / python-zhmcclient / zhmcclient / _exceptions.py View on Github external
def __init__(self, msg, details):
        """
        Parameters:

          msg (:term:`string`):
            A human readable message describing the problem.

          details (Exception):
            The :exc:`~zhmcclient.HTTPError` exception describing the
            error returned by the HMC.

        ``args[0]`` will be set to the ``msg`` parameter.
        """
        super(ServerAuthError, self).__init__(msg)
        assert isinstance(details, HTTPError)
        self._details = details
github zhmcclient / python-zhmcclient / zhmcclient / _session.py View on Github external
else:
                        return job
            elif 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
                    self._do_logon()
                    return self.post(uri, body, logon_required)
                elif reason == 1:
                    # Login user's authentication is fine; this is an
                    # authorization issue, so we don't raise ServerAuthError.
                    raise HTTPError(result_object)
                else:
                    msg = result_object.get('message', None)
                    raise ServerAuthError("HTTP authentication failed: {}".
                                          format(msg),
                                          HTTPError(result_object))
            else:
                result_object = _result_object(result)
                raise HTTPError(result_object)
        finally:
            if wait_for_completion:
                stats_total.end()
github zhmcclient / python-zhmcclient / zhmcclient / _session.py View on Github external
By default, this method checks whether there is a session-id set
        and considers that sufficient for determining that the session is
        logged on. The `verify` parameter can be used to verify the validity
        of a session-id that is already set, by issuing a dummy operation
        ("Get Console Properties") to the HMC.

        Parameters:

          verify (bool): If a session-id is already set, verify its validity.
        """
        if self._session_id is None:
            return False
        if verify:
            try:
                self.get('/api/console', logon_required=True)
            except ServerAuthError:
                return False
        return True
github zhmcclient / python-zhmcclient / zhmcclient / _session.py View on Github external
return
        elif 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
                self._do_logon()
                self.delete(uri, logon_required)
                return
            elif reason == 1:
                # Login user's authentication is fine; this is an authorization
                # issue, so we don't raise ServerAuthError.
                raise HTTPError(result_object)
            else:
                msg = result_object.get('message', None)
                raise ServerAuthError("HTTP authentication failed: {}".
                                      format(msg), HTTPError(result_object))
        else:
            result_object = _result_object(result)
            raise HTTPError(result_object)
github zhmcclient / python-zhmcclient / zhmcclient / _session.py View on Github external
if result.status_code == 200:
            return _result_object(result)
        elif 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
                self._do_logon()
                return self.get(uri, logon_required)
            elif reason == 1:
                # Login user's authentication is fine; this is an authorization
                # issue, so we don't raise ServerAuthError.
                raise HTTPError(result_object)
            else:
                msg = result_object.get('message', None)
                raise ServerAuthError("HTTP authentication failed: {}".
                                      format(msg), HTTPError(result_object))
        else:
            result_object = _result_object(result)
            raise HTTPError(result_object)