Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def str_def(self):
"""
:term:`string`: The exception as a string in a Python definition-style
format, e.g. for parsing by scripts:
.. code-block:: text
classname={}; operation_timeout={}; message={};
"""
return "classname={!r}; operation_timeout={!r}; message={!r};". \
format(self.__class__.__name__, self.operation_timeout,
self.args[0])
class StatusTimeout(Error):
"""
This exception indicates that the waiting for reaching a desired LPAR
or Partition status has timed out.
The possible status values for an LPAR are:
* ``"not-activated"`` - The LPAR is not active.
* ``"not-operating"`` - The LPAR is active but no operating system is
running in the LPAR.
* ``"operating"`` - The LPAR is active and an operating system is
running in the LPAR.
* ``"exceptions"`` - The LPAR or its CPC has one or more unusual
conditions.
The possible status values for a Partition are described in the
'status' property of the data model for the partition resource in the
self.connect_retries)
def str_def(self):
"""
:term:`string`: The exception as a string in a Python definition-style
format, e.g. for parsing by scripts:
.. code-block:: text
classname={}; connect_retries={}; message={};
"""
return "classname={!r}; connect_retries={!r}; message={!r};". \
format(self.__class__.__name__, self.connect_retries, self.args[0])
class AuthError(Error):
"""
This exception indicates erors related to authentication.
Exceptions of this class are not raised; only derived exceptions are
raised.
Derived from :exc:`~zhmcclient.Error`.
"""
def __init__(self, *args):
# Parameters:
# *args:
# A list of input arguments for the exception object.
# The derived classes define more specific parameters.
# These input arguments will be available as tuple items in the
# ``args`` instance variable of the exception object.
def str_def(self):
"""
:term:`string`: The exception as a string in a Python definition-style
format, e.g. for parsing by scripts:
.. code-block:: text
classname={}; line={}; column={}; message={};
"""
return "classname={!r}; line={!r}; column={!r}; message={!r};". \
format(self.__class__.__name__, self.line, self.column,
self.args[0])
class VersionError(Error):
"""
This exception indicates that a function of the client requires a minimum
HMC API version which is not supported by the HMC.
Derived from :exc:`~zhmcclient.Error`.
"""
def __init__(self, msg, min_api_version, api_version):
"""
Parameters:
msg (:term:`string`):
A human readable message describing the problem.
min_api_version (:term:`HMC API version`):
The minimum HMC API version required to perform the function that
def str_def(self):
"""
Interface definition for the corresponding method derived exception
classes.
:term:`string`: The exception as a string in a Python definition-style
format, e.g. for parsing by scripts.
For the exact format returned by derived exception classes, see the
same-named methods there.
"""
raise NotImplementedError
class ConnectionError(Error):
"""
This exception indicates a problem with the connection to the HMC, below
the HTTP level. HTTP errors are indicated via :exc:`~zhmcclient.HTTPError`.
A retry by the user code is not likely to be successful, unless connect or
read retries had been disabled when creating the session (see
:class:`~zhmcclient.Session`).
Even though this class has exceptions derived from it, exceptions of this
class may also be raised (if no other derived class matches the
circumstances).
Derived from :exc:`~zhmcclient.Error`.
"""
def __init__(self, msg, details):
"""
:term:`string`: The exception as a string in a Python definition-style
format, e.g. for parsing by scripts:
.. code-block:: text
classname={}; request_method={}; request_uri={}; http_status={}; reason={}; message={};
""" # noqa: E501
return "classname={!r}; request_method={!r}; request_uri={!r}; " \
"http_status={!r}; reason={!r}; message={!r};". \
format(self.__class__.__name__, self.details.request_method,
self.details.request_uri, self.details.http_status,
self.details.reason, self.args[0])
class ParseError(Error):
"""
This exception indicates a parsing error while processing the JSON payload
in a response from the HMC.
Derived from :exc:`~zhmcclient.Error`.
The error location within the payload is automatically determined by
parsing the error message for the pattern:
.. code-block:: text
: line {line} column {column}
"""
def __init__(self, msg):
"""
classname={}; resource_classname={}; filter_args={}; parent_classname={}; manager_name={}; message={}; resource_uris={}
""" # noqa: E501
parent = self.manager.parent
return "classname={!r}; resource_classname={!r}; filter_args={!r}; " \
"parent_classname={!r}; parent_name={!r}; message={!r}; " \
"resource_uris={!r}". \
format(self.__class__.__name__,
self.manager.resource_class.__name__,
self.filter_args,
parent.__class__.__name__ if parent else None,
parent.name if parent else None,
self.args[0],
self.resource_uris)
class NotFound(Error):
"""
This exception indicates that a resource was not found.
Derived from :exc:`~zhmcclient.Error`.
"""
def __init__(self, filter_args, manager):
"""
Parameters:
filter_args (dict):
Dictionary of filter arguments by which the resource was attempted
to be found. Keys are the resource property names, values are
the match values for that property.
manager (:class:`~zhmcclient.BaseManager`):
def __init__(self, *args):
# Parameters:
# *args:
# A list of input arguments for the exception object.
# The derived classes define more specific parameters.
# These input arguments will be available as tuple items in the
# ``args`` instance variable of the exception object.
super(Error, self).__init__(*args)
"""
:term:`string`: The exception as a string in a Python definition-style
format, e.g. for parsing by scripts:
.. code-block:: text
classname={}; request_method={}; request_uri={}; http_status={}; reason={}; message={};
""" # noqa: E501
return "classname={!r}; request_method={!r}; request_uri={!r}; " \
"http_status={!r}; reason={!r}; message={!r};". \
format(self.__class__.__name__, self.request_method,
self.request_uri, self.http_status, self.reason,
self.args[0])
class OperationTimeout(Error):
"""
This exception indicates that the waiting for completion of an asynchronous
HMC operation has timed out.
Derived from :exc:`~zhmcclient.Error`.
"""
def __init__(self, msg, operation_timeout):
"""
Parameters:
msg (:term:`string`):
A human readable message describing the problem.
operation_timeout (:term:`integer`):
The operation timeout in seconds.
def str_def(self):
"""
:term:`string`: The exception as a string in a Python definition-style
format, e.g. for parsing by scripts:
.. code-block:: text
classname={}; actual_status={}; desired_statuses={}; status_timeout={}; message={};
""" # noqa: E501
return "classname={!r}; actual_status={!r}; desired_statuses={!r}; " \
"status_timeout={!r}; message={!r};". \
format(self.__class__.__name__, self.actual_status,
self.desired_statuses, self.status_timeout, self.args[0])
class NoUniqueMatch(Error):
"""
This exception indicates that more than one resource matched the filter
arguments.
Derived from :exc:`~zhmcclient.Error`.
"""
def __init__(self, filter_args, manager, resources):
"""
Parameters:
filter_args (dict):
Dictionary of filter arguments by which the resource was attempted
to be found. Keys are the resource property names, values are
the match values for that property.
is raised.
Raises:
:exc:`~zhmcclient.OperationTimeout`: The timeout expired while
waiting for the Console to become available.
"""
if operation_timeout is None:
operation_timeout = \
self.session.retry_timeout_config.operation_timeout
if operation_timeout > 0:
start_time = time.time()
while True:
try:
self.query_api_version()
except Error:
pass
except Exception:
raise
else:
break
if operation_timeout > 0:
current_time = time.time()
if current_time > start_time + operation_timeout:
raise OperationTimeout(
"Waiting for Console at {} to become available timed "
"out (operation timeout: {} s)".
format(self.session.host, operation_timeout),
operation_timeout)
time.sleep(10) # Avoid hot spin loop