How to use the zhmcclient._exceptions.HTTPError 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 / _session.py View on Github external
job = Job(self, job_uri, 'POST', uri)
                    if wait_for_completion:
                        return job.wait_for_completion(operation_timeout)
                    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
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
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)
github zhmcclient / python-zhmcclient / zhmcclient / _session.py View on Github external
content=result.content)

        if result.status_code in (200, 204):
            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
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
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
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)
github zhmcclient / python-zhmcclient / zhmcclient / _session.py View on Github external
if not error_result_obj:
                    message = None
                elif 'message' in error_result_obj:
                    message = error_result_obj['message']
                elif 'error' in error_result_obj:
                    message = error_result_obj['error']
                else:
                    message = None
                error_obj = {
                    'http-status': op_status_code,
                    'reason': job_result_obj['job-reason-code'],
                    'message': message,
                    'request-method': self.op_method,
                    'request-uri': self.op_uri,
                }
                raise HTTPError(error_obj)
        else:
            op_result_obj = None
        return job_status, op_result_obj
github zhmcclient / python-zhmcclient / zhmcclient / _session.py View on Github external
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)