python-compute/compute/exceptions.py

81 lines
2.4 KiB
Python
Raw Permalink Normal View History

2023-11-23 02:34:02 +03:00
# This file is part of Compute
#
# Compute is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
2023-11-09 01:17:50 +03:00
"""Exceptions."""
2023-11-06 12:52:19 +03:00
2023-11-23 02:34:02 +03:00
class ComputeError(Exception):
"""Basic exception class."""
2023-11-06 12:52:19 +03:00
2023-11-23 02:34:02 +03:00
class ConfigLoaderError(ComputeError):
2023-11-06 12:52:19 +03:00
"""Something went wrong when loading configuration."""
2023-11-23 02:34:02 +03:00
class SessionError(ComputeError):
2023-11-06 12:52:19 +03:00
"""Something went wrong while connecting to libvirtd."""
2023-11-23 02:34:02 +03:00
class GuestAgentError(ComputeError):
2023-11-06 12:52:19 +03:00
"""Something went wring when QEMU Guest Agent call."""
class GuestAgentUnavailableError(GuestAgentError):
"""Guest agent is not connected or is unavailable."""
class GuestAgentTimeoutExceededError(GuestAgentError):
"""QEMU timeout exceeded."""
def __init__(self, msg: int):
"""Initialise GuestAgentTimeoutExceededError."""
super().__init__(f'QEMU timeout ({msg} sec) exceeded')
class GuestAgentCommandNotSupportedError(GuestAgentError):
"""Guest agent command is not supported or blacklisted on guest."""
2023-11-23 02:34:02 +03:00
class StoragePoolError(ComputeError):
2023-11-06 12:52:19 +03:00
"""Something went wrong when operating with storage pool."""
2023-11-11 02:28:46 +03:00
class StoragePoolNotFoundError(StoragePoolError):
"""Storage pool not found."""
def __init__(self, msg: str):
"""Initialise StoragePoolNotFoundError."""
super().__init__(f"storage pool named '{msg}' not found")
class VolumeNotFoundError(StoragePoolError):
"""Storage volume not found."""
def __init__(self, msg: str):
"""Initialise VolumeNotFoundError."""
super().__init__(f"storage volume '{msg}' not found")
2023-11-23 02:34:02 +03:00
class InstanceError(ComputeError):
2023-11-06 12:52:19 +03:00
"""Something went wrong while interacting with the domain."""
class InstanceNotFoundError(InstanceError):
"""Virtual machine or container not found on compute node."""
def __init__(self, msg: str):
"""Initialise InstanceNotFoundError."""
super().__init__(f"compute instance '{msg}' not found")