various improvements
This commit is contained in:
		
							
								
								
									
										76
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										76
									
								
								README.md
									
									
									
									
									
								
							@@ -1,49 +1,41 @@
 | 
				
			|||||||
# Compute Service
 | 
					# Compute
 | 
				
			||||||
 | 
					
 | 
				
			||||||
В этом репозитории развивается базовая библиотека для взаимодействия с libvirt и выполнения операций с виртуальными машинами. Фокус на QEMU/KVM.
 | 
					Compute-instance management library and tools.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Зависимости (версии из репозитория Debian 12):
 | 
					Currently supports only QEMU/KVM based virtual machines.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- `python3-lxml` 4.9.2
 | 
					## Docs
 | 
				
			||||||
- `python3-docopt` 0.6.2
 | 
					 | 
				
			||||||
- `python3-libvirt` 9.0.0
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Минимальная поддерживаемая версия Python — `3.11`, потому, что можем.
 | 
					Run `make serve-docs`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## API
 | 
					## Roadmap
 | 
				
			||||||
 | 
					
 | 
				
			||||||
В структуре проекта сейчас бардак, многое будет переосмыслено и переделано позже. Основная цель на текущем этапе — получить минимально работающий код, с помощью которого возможно выполнить установку виртуальной машины и как-то управлять ею.
 | 
					- [x] Create instances
 | 
				
			||||||
 | 
					- [ ] CDROM
 | 
				
			||||||
Есть набор классов, предоставляющих собой интерфейсы для взаимодействия с виртуальными машинами, стораджами, дисками и т.п. Датаклассы описывают сущности и имеют метод `to_xml()` для получения XML конфига для `libvirt`. Смысл использования датаклассов в том, чтобы иметь один объект, содержащий в себе нормальные легкочитаемые аттрибуты и XML описание сущности одновременно.
 | 
					- [x] Instance power management
 | 
				
			||||||
 | 
					- [ ] Instance pause and resume
 | 
				
			||||||
## ROADMAP
 | 
					- [x] vCPU hotplug
 | 
				
			||||||
 | 
					- [ ] Memory hotplug
 | 
				
			||||||
- [ ] Установка инстансов
 | 
					- [x] Hot disk resize [not tested]
 | 
				
			||||||
    - [ ] Установка с использованием эталонного образа ОС
 | 
					- [ ] CPU topology customization
 | 
				
			||||||
    - [ ] Установка с пустым диском и загрузкой с ISO
 | 
					- [x] CPU customization (emulation mode, model, vendor, features)
 | 
				
			||||||
    - [ ] Установка с использованием готового волюма
 | 
					- [ ] BIOS/UEFI settings
 | 
				
			||||||
- [x] Базовое управление питанием
 | 
					- [x] Device attaching
 | 
				
			||||||
- [ ] Остановка и возобновление инстансов
 | 
					- [ ] Device detaching
 | 
				
			||||||
- [ ] Изменение числа vCPU на горячую
 | 
					- [ ] GPU passthrough
 | 
				
			||||||
- [ ] Изменение топологии процессора
 | 
					- [ ] CPU guarantied resource percent support
 | 
				
			||||||
- [ ] Выбор типа эмуляции процессора, вендора, модели и инструкций
 | 
					- [x] QEMU Guest Agent management
 | 
				
			||||||
- [ ] Изменение памяти на горячую
 | 
					- [ ] Instance resources usage stats
 | 
				
			||||||
- [ ] Ресайз дисков на горячую
 | 
					- [ ] SSH-keys management
 | 
				
			||||||
- [ ] Выбор между BIOS и UEFI
 | 
					- [x] Setting user passwords in guest [not tested]
 | 
				
			||||||
- [ ] Редактирование параметров загрузки (boot menu, etc)
 | 
					 | 
				
			||||||
- [x] Горячее подключение устройств
 | 
					 | 
				
			||||||
- [ ] Горячее отключение устройств
 | 
					 | 
				
			||||||
- [ ] GPU
 | 
					 | 
				
			||||||
- [ ] Поддержка инстансов с разной гарантированной долей CPU
 | 
					 | 
				
			||||||
- [x] Базовое управление QEMU Guest Agent
 | 
					 | 
				
			||||||
- [ ] Проверка доступности и возможностей QEMU Guest Agent
 | 
					 | 
				
			||||||
- [ ] Статистика потребления ресурсов
 | 
					 | 
				
			||||||
- [ ] Управление SSH-ключами
 | 
					 | 
				
			||||||
- [ ] Изменение пароля root
 | 
					 | 
				
			||||||
- [ ] LXC
 | 
					- [ ] LXC
 | 
				
			||||||
- [ ] Работа с дисками QCOW2,3
 | 
					- [x] QCOW2 disks support
 | 
				
			||||||
- [ ] ZVOL
 | 
					- [ ] ZVOL support
 | 
				
			||||||
- [ ] Сетевые диски
 | 
					- [ ] Network disks support
 | 
				
			||||||
- [ ] Создание Storage Pool на основе TOML/YAML описания
 | 
					- [ ] Images service integration (Images service is not implemented yet)
 | 
				
			||||||
- [ ] Удаление Storage Pool
 | 
					- [ ] Manage storage pools
 | 
				
			||||||
- [ ] Снапшоты
 | 
					- [ ] Instance snapshots
 | 
				
			||||||
 | 
					- [ ] Instance backups
 | 
				
			||||||
 | 
					- [ ] Instance migrations
 | 
				
			||||||
 | 
					- [ ] HTTP API
 | 
				
			||||||
 | 
					- [ ] Full functional CLI [in progress]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -484,10 +484,11 @@ class Instance:
 | 
				
			|||||||
        self, name: str, capacity: int, unit: units.DataUnit
 | 
					        self, name: str, capacity: int, unit: units.DataUnit
 | 
				
			||||||
    ) -> None:
 | 
					    ) -> None:
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        Resize block device.
 | 
					        Resize attached block device.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        :param name: Disk device name e.g. `vda`, `sda`, etc.
 | 
					        :param name: Disk device name e.g. `vda`, `sda`, etc.
 | 
				
			||||||
        :param capacity: Volume capacity in bytes.
 | 
					        :param capacity: New volume capacity.
 | 
				
			||||||
 | 
					        :param unit: Capacity unit.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        self.domain.blockResize(
 | 
					        self.domain.blockResize(
 | 
				
			||||||
            name,
 | 
					            name,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ extensions = [
 | 
				
			|||||||
]
 | 
					]
 | 
				
			||||||
templates_path = ['_templates']
 | 
					templates_path = ['_templates']
 | 
				
			||||||
exclude_patterns = []
 | 
					exclude_patterns = []
 | 
				
			||||||
language = 'ru'
 | 
					language = 'en'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# HTML output settings
 | 
					# HTML output settings
 | 
				
			||||||
html_theme = 'alabaster'
 | 
					html_theme = 'alabaster'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,15 +1,15 @@
 | 
				
			|||||||
Compute Service
 | 
					Compute
 | 
				
			||||||
===============
 | 
					=======
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Документация библиотеки для управления Compute-инстансами.
 | 
					Compute-instance management library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. toctree::
 | 
					.. toctree::
 | 
				
			||||||
    :maxdepth: 1
 | 
					    :maxdepth: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    python-api/index
 | 
					    python-api/index
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Индексы и таблицы
 | 
					Indices and tables
 | 
				
			||||||
-----------------
 | 
					------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* :ref:`genindex`
 | 
					* :ref:`genindex`
 | 
				
			||||||
* :ref:`modindex`
 | 
					* :ref:`modindex`
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
Python API
 | 
					Python API
 | 
				
			||||||
==========
 | 
					==========
 | 
				
			||||||
 | 
					
 | 
				
			||||||
API позволяет выполнять действия над инстансами программно. Ниже описано пример
 | 
					The API allows you to perform actions on instances programmatically. Below is
 | 
				
			||||||
изменения параметров и запуска инстанса `myinstance`.
 | 
					an example of changing parameters and launching the `myinstance` instance.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. code-block:: python
 | 
					.. code-block:: python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -10,7 +10,6 @@ API позволяет выполнять действия над инстанс
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    from compute import Session
 | 
					    from compute import Session
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    logging.basicConfig(level=logging.DEBUG)
 | 
					    logging.basicConfig(level=logging.DEBUG)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with Session() as session:
 | 
					    with Session() as session:
 | 
				
			||||||
@@ -20,28 +19,29 @@ API позволяет выполнять действия над инстанс
 | 
				
			|||||||
        instance.set_autostart(enabled=True)
 | 
					        instance.set_autostart(enabled=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Контекстный менеджер :class:`Session` предоставляет абстракцию над :class:`libvirt.virConnect`
 | 
					:class:`Session` context manager provides an abstraction over :class:`libvirt.virConnect`
 | 
				
			||||||
и возвращает объекты других классов настоящей билиотеки.
 | 
					and returns objects of other classes of the present library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Представление сущностей
 | 
					Entity representation
 | 
				
			||||||
-----------------------
 | 
					---------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Такие сущности как Сompute-инстанс представлены в виде классов. Эти классы напрямую
 | 
					Entities such as a compute-instance are represented as classes. These classes directly
 | 
				
			||||||
вызывают методы libvirt для выполнения операций на гипервизоре. Пример класса — :data:`Volume`.
 | 
					call libvirt methods to perform operations on the hypervisor. An example class is
 | 
				
			||||||
 | 
					:class:`Volume`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Конфигурационные файлы различных объектов libvirt в compute описаны специальными
 | 
					The configuration files of various libvirt objects in `compute` are described by special
 | 
				
			||||||
датаклассами. Датакласс хранит в своих свойствах параметры объекта и может вернуть XML
 | 
					dataclasses. The dataclass stores object parameters in its properties and can return an
 | 
				
			||||||
конфиг для libvirt с помощью метода ``to_xml()``. Пример — :py:class:`VolumeConfig`.
 | 
					XML config for libvirt using the ``to_xml()`` method. For example :class:`VolumeConfig`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Для валидации входных данных используются модели `Pydantic <https://docs.pydantic.dev/>`_.
 | 
					`Pydantic <https://docs.pydantic.dev/>`_ models are used to validate input data.
 | 
				
			||||||
Пример — :py:class:`VolumeSchema`.
 | 
					For example :class:`VolumeSchema`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Документация модулей
 | 
					Modules documentation
 | 
				
			||||||
--------------------
 | 
					---------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. toctree::
 | 
					.. toctree::
 | 
				
			||||||
    :maxdepth: 4
 | 
					    :maxdepth: 4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    session
 | 
					    session
 | 
				
			||||||
    instance/index
 | 
					    instance/index
 | 
				
			||||||
    storage
 | 
					    storage/index
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
.. toctree::
 | 
					.. toctree::
 | 
				
			||||||
    :maxdepth: 1
 | 
					    :maxdepth: 1
 | 
				
			||||||
    :caption: Содержание:
 | 
					    :caption: Contents:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    instance
 | 
					    instance
 | 
				
			||||||
    guest_agent
 | 
					    guest_agent
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +0,0 @@
 | 
				
			|||||||
``storage``
 | 
					 | 
				
			||||||
===========
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
``compute.storage.pool``
 | 
					 | 
				
			||||||
------------------------
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.. automodule:: compute.storage.pool
 | 
					 | 
				
			||||||
   :members:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
``compute.storage.volume``
 | 
					 | 
				
			||||||
--------------------------
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.. automodule:: compute.storage.volume
 | 
					 | 
				
			||||||
   :members:
 | 
					 | 
				
			||||||
							
								
								
									
										9
									
								
								docs/source/python-api/storage/index.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								docs/source/python-api/storage/index.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					``storage``
 | 
				
			||||||
 | 
					============
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.. toctree::
 | 
				
			||||||
 | 
					    :maxdepth: 1
 | 
				
			||||||
 | 
					    :caption: Contents:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pool
 | 
				
			||||||
 | 
					    volume
 | 
				
			||||||
							
								
								
									
										5
									
								
								docs/source/python-api/storage/pool.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								docs/source/python-api/storage/pool.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					``pool``
 | 
				
			||||||
 | 
					========
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.. automodule:: compute.storage.pool
 | 
				
			||||||
 | 
					   :members:
 | 
				
			||||||
							
								
								
									
										5
									
								
								docs/source/python-api/storage/volume.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								docs/source/python-api/storage/volume.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					``volume``
 | 
				
			||||||
 | 
					==========
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.. automodule:: compute.storage.volume
 | 
				
			||||||
 | 
					   :members:
 | 
				
			||||||
		Reference in New Issue
	
	Block a user