How to use the zhmcclient._exceptions.ClientAuthError 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
Raises:

          :exc:`~zhmcclient.ClientAuthError`
          :exc:`~zhmcclient.ServerAuthError`
          :exc:`~zhmcclient.ConnectionError`
          :exc:`~zhmcclient.ParseError`
          :exc:`~zhmcclient.HTTPError`
        """
        if self._userid is None:
            raise ClientAuthError("Userid is not provided.")
        if self._password is None:
            if self._get_password:
                self._password = self._get_password(self._host, self._userid)
            else:
                raise ClientAuthError("Password is not provided.")
        logon_uri = '/api/sessions'
        logon_body = {
            'userid': self._userid,
            'password': self._password
        }
        self._headers.pop('X-API-Session', None)  # Just in case
        self._session = self._new_session(self.retry_timeout_config)
        logon_res = self.post(logon_uri, logon_body, logon_required=False)
        self._session_id = logon_res['api-session']
        self._headers['X-API-Session'] = self._session_id
github zhmcclient / python-zhmcclient / zhmcclient / _exceptions.py View on Github external
def __init__(self, msg):
        """
        Parameters:

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

        ``args[0]`` will be set to the ``msg`` parameter.
        """
        super(ClientAuthError, self).__init__(msg)
github zhmcclient / python-zhmcclient / zhmcclient / _session.py View on Github external
def _do_logon(self):
        """
        Log on, unconditionally. This can be used to re-logon.
        This requires credentials to be provided.

        Raises:

          :exc:`~zhmcclient.ClientAuthError`
          :exc:`~zhmcclient.ServerAuthError`
          :exc:`~zhmcclient.ConnectionError`
          :exc:`~zhmcclient.ParseError`
          :exc:`~zhmcclient.HTTPError`
        """
        if self._userid is None:
            raise ClientAuthError("Userid is not provided.")
        if self._password is None:
            if self._get_password:
                self._password = self._get_password(self._host, self._userid)
            else:
                raise ClientAuthError("Password is not provided.")
        logon_uri = '/api/sessions'
        logon_body = {
            'userid': self._userid,
            'password': self._password
        }
        self._headers.pop('X-API-Session', None)  # Just in case
        self._session = self._new_session(self.retry_timeout_config)
        logon_res = self.post(logon_uri, logon_body, logon_required=False)
        self._session_id = logon_res['api-session']
        self._headers['X-API-Session'] = self._session_id