diff --git a/Makefile b/Makefile index 2444722..2e55cae 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,10 @@ lint: docs: poetry run sphinx-build $(DOCS_SRC) $(DOCS_BUILD) -serve-docs: +docs-versions: + poetry run sphinx-multiversion $(DOCS_SRC) $(DOCS_BUILD) + +serve-docs: docs-versions poetry run sphinx-autobuild $(DOCS_SRC) $(DOCS_BUILD) clean: diff --git a/compute/instance/instance.py b/compute/instance/instance.py index f5bfe75..21e8d22 100644 --- a/compute/instance/instance.py +++ b/compute/instance/instance.py @@ -162,16 +162,16 @@ class DeviceConfig: class Instance: - """Class for manipulating compute instance.""" + """Manage compute instances.""" def __init__(self, domain: libvirt.virDomain): """ Initialise Instance. - :prop domain libvirt.virDomain: - :prop connection libvirt.virConnect: - :prop name str: - :prop guest_agent GuestAgent: + :ivar libvirt.virDomain domain: domain object + :ivar libvirt.virConnect connection: connection object + :ivar str name: domain name + :ivar GuestAgent guest_agent: :class:`GuestAgent` object :param domain: libvirt domain object """ diff --git a/compute/instance/schemas.py b/compute/instance/schemas.py index f19853f..5fa9aad 100644 --- a/compute/instance/schemas.py +++ b/compute/instance/schemas.py @@ -44,27 +44,27 @@ class CPUSchema(BaseModel): features: CPUFeaturesSchema -class StorageVolumeType(StrEnum): +class VolumeType(StrEnum): """Storage volume types enumeration.""" FILE = 'file' NETWORK = 'network' -class StorageVolumeCapacitySchema(BaseModel): +class VolumeCapacitySchema(BaseModel): """Storage volume capacity field model.""" value: int unit: DataUnit -class StorageVolumeSchema(BaseModel): +class VolumeSchema(BaseModel): """Storage volume model.""" - type: StorageVolumeType # noqa: A003 + type: VolumeType # noqa: A003 source: Path target: str - capacity: StorageVolumeCapacitySchema + capacity: VolumeCapacitySchema readonly: bool = False is_system: bool = False @@ -98,7 +98,7 @@ class InstanceSchema(BaseModel): arch: str image: str boot: BootOptionsSchema - volumes: list[StorageVolumeSchema] + volumes: list[VolumeSchema] network_interfaces: list[NetworkInterfaceSchema] @validator('name') diff --git a/compute/session.py b/compute/session.py index 7e2945a..0de990e 100644 --- a/compute/session.py +++ b/compute/session.py @@ -29,16 +29,25 @@ class Capabilities(NamedTuple): class Session(AbstractContextManager): - """Hypervisor session manager.""" + """ + Hypervisor session context manager. + + :cvar IMAGES_POOL: images storage pool name taken from env + :cvar VOLUMES_POOL: volumes storage pool name taken from env + """ + + IMAGES_POOL = os.getenv('CMP_IMAGES_POOL') + VOLUMES_POOL = os.getenv('CMP_VOLUMES_POOL') def __init__(self, uri: str | None = None): """ Initialise session with hypervisor. + :ivar str uri: libvirt connection URI. + :ivar libvirt.virConnect connection: libvirt connection object. + :param uri: libvirt connection URI. """ - self.IMAGES_POOL = os.getenv('CMP_IMAGES_POOL') - self.VOLUMES_POOL = os.getenv('CMP_VOLUMES_POOL') self.uri = uri or 'qemu:///system' self.connection = libvirt.open(self.uri) @@ -74,11 +83,16 @@ class Session(AbstractContextManager): """ Create and return new compute instance. - :param name str: Instance name. - :param title str: Instance title for humans. - :param description str: Some information about instance - :param memory int: Memory in MiB. - :param max_memory int: Maximum memory in MiB. + :param name: Instance name. + :type name: str + :param title: Instance title for humans. + :type title: str + :param description: Some information about instance + :type description: str + :param memory: Memory in MiB. + :type memory: int + :param max_memory: Maximum memory in MiB. + :type max_memory: int """ # TODO @ge: create instances in transaction data = InstanceSchema(**kwargs) diff --git a/compute/utils/units.py b/compute/utils/units.py index 6146a59..7e4b632 100644 --- a/compute/utils/units.py +++ b/compute/utils/units.py @@ -24,7 +24,7 @@ class InvalidDataUnitError(ValueError): def to_bytes(value: int, unit: DataUnit = DataUnit.BYTES) -> int: - """Convert value to bytes. See `DataUnit`.""" + """Convert value to bytes. See :class:`DataUnit`.""" try: _ = DataUnit(unit) except ValueError as e: diff --git a/docs/source/_templates/versioning.html b/docs/source/_templates/versioning.html index 7c5ab14..318bd87 100644 --- a/docs/source/_templates/versioning.html +++ b/docs/source/_templates/versioning.html @@ -1,5 +1,5 @@ {% if versions %} -

{{ _('Versions') }}

+

{{ _('Версии') }}