How to use the zhmcclient.ConnectionError 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 / tests / unit / zhmcclient / test_exceptions.py View on Github external
def test_connectionerror_str_def(self, msg, details):
        """All tests for ConnectionError.str_def()."""

        exc = ConnectionError(msg, details)

        classname = exc.__class__.__name__

        # Execute the code to be tested
        str_def = exc.str_def()

        str_def = ' ' + str_def
        assert str_def.find(' classname={!r};'.format(classname)) >= 0
        assert str_def.find(' message={!r};'.format(msg)) >= 0
github zhmcclient / python-zhmcclient / tests / end2end / test_hmc_credentials_file.py View on Github external
cpc_item = cpc_items[cpc_name]

            hmc_host = cpc_item['hmc_host']

            info(capsys, "Checking HMC %r for CPC %r", (hmc_host, cpc_name))

            session = zhmcclient.Session(
                hmc_host, cpc_item['hmc_userid'], cpc_item['hmc_password'],
                retry_timeout_config=rt_config)

            client = zhmcclient.Client(session)

            try:
                session.logon()
            except zhmcclient.ConnectionError as exc:
                info(capsys, "Skipping HMC %r for CPC %r: %s",
                     (hmc_host, cpc_name, exc))
                continue

            cpcs = client.cpcs.list()
            cpc_names = [cpc.name for cpc in cpcs]
            if cpc_name not in cpc_names:
                raise AssertionError(
                    "CPC {!r} not found in HMC {!r}.\n"
                    "Existing CPCs: {!r}".
                    format(cpc_name, hmc_host, cpc_names))

            session.logoff()
github zhmcclient / python-zhmcclient / tests / unit / zhmcclient / test_exceptions.py View on Github external
def test_readtimeout_initial_attrs(self, arg_names, args):
        """Test initial attributes of ReadTimeout."""

        msg, details, read_timeout, read_retries = args
        posargs, kwargs = func_args(args, arg_names)

        # Execute the code to be tested
        exc = ReadTimeout(*posargs, **kwargs)

        assert isinstance(exc, ConnectionError)
        assert len(exc.args) == 1
        assert exc.args[0] == msg
        assert exc.details == details
        assert exc.read_timeout == read_timeout
        assert exc.read_retries == read_retries
github zhmcclient / python-zhmcclient / tests / unit / zhmcclient / test_exceptions.py View on Github external
def test_connectionerror_str(self, msg, details):
        """All tests for ConnectionError.__str__()."""

        exc = ConnectionError(msg, details)

        exp_str = str(exc.args[0])

        # Execute the code to be tested
        str_str = str(exc)

        assert str_str == exp_str
github zhmcclient / python-zhmcclient / tests / unit / zhmcclient / test_exceptions.py View on Github external
def test_connectionerror_repr(self, msg, details):
        """All tests for ConnectionError.__repr__()."""

        exc = ConnectionError(msg, details)

        classname = exc.__class__.__name__

        # Execute the code to be tested
        repr_str = repr(exc)

        # We check the one-lined string just roughly
        repr_str = repr_str.replace('\n', '\\n')
        assert re.match(r'^{}\s*\(.*\)$'.format(classname), repr_str)
github zhmcclient / python-zhmcclient / tests / unit / zhmcclient / test_exceptions.py View on Github external
def test_connectionerror_initial_attrs(self, arg_names, args):
        """Test initial attributes of ConnectionError."""

        msg, details = args
        posargs, kwargs = func_args(args, arg_names)

        # Execute the code to be tested
        exc = ConnectionError(*posargs, **kwargs)

        assert isinstance(exc, Error)
        assert len(exc.args) == 1
        assert exc.args[0] == msg
        assert exc.details == details
github zhmcclient / python-zhmcclient / zhmcclient_mock / _session.py View on Github external
description of the members of the returned JSON objects.

        Raises:

          :exc:`~zhmcclient.HTTPError`
          :exc:`~zhmcclient.ParseError` (not implemented)
          :exc:`~zhmcclient.AuthError` (not implemented)
          :exc:`~zhmcclient.ConnectionError`
        """
        try:
            return self._urihandler.post(self._hmc, uri, body, logon_required,
                                         wait_for_completion)
        except HTTPError as exc:
            raise zhmcclient.HTTPError(exc.response())
        except ConnectionError as exc:
            raise zhmcclient.ConnectionError(exc.message, None)
github zhmcclient / python-zhmcclient / zhmcclient_mock / _session.py View on Github external
Because this is a faked HMC, this does not perform a real logon,
            but it is still used to update the state in the faked HMC.

        Raises:

          :exc:`~zhmcclient.HTTPError`
          :exc:`~zhmcclient.ParseError` (not implemented)
          :exc:`~zhmcclient.AuthError` (not implemented)
          :exc:`~zhmcclient.ConnectionError`
        """
        try:
            self._urihandler.delete(self._hmc, uri, logon_required)
        except HTTPError as exc:
            raise zhmcclient.HTTPError(exc.response())
        except ConnectionError as exc:
            raise zhmcclient.ConnectionError(exc.message, None)
github zhmcclient / python-zhmcclient / zhmcclient_mock / _session.py View on Github external
:term:`json object` with the operation result.

        Raises:

          :exc:`~zhmcclient.HTTPError`
          :exc:`~zhmcclient.ParseError` (not implemented)
          :exc:`~zhmcclient.AuthError` (not implemented)
          :exc:`~zhmcclient.ConnectionError`
        """
        try:
            return self._urihandler.get(self._hmc, uri, logon_required)
        except HTTPError as exc:
            raise zhmcclient.HTTPError(exc.response())
        except ConnectionError as exc:
            raise zhmcclient.ConnectionError(exc.message, None)