add docs
This commit is contained in:
47
docs/source/python-api/index.rst
Normal file
47
docs/source/python-api/index.rst
Normal file
@ -0,0 +1,47 @@
|
||||
Python API
|
||||
==========
|
||||
|
||||
API позволяет выполнять действия над инстансами программно. Ниже описано пример
|
||||
изменения параметров и запуска инстанса `myinstance`.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import logging
|
||||
|
||||
from compute import Session
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
with Session() as session:
|
||||
instance = session.get_instance('myinstance')
|
||||
instance.set_vcpus(4)
|
||||
instance.start()
|
||||
instance.set_autostart(enabled=True)
|
||||
|
||||
|
||||
Контекстный менеджер :class:`Session` предоставляет абстракцию над :class:`libvirt.virConnect`
|
||||
и возвращает объекты других классов настоящей билиотеки.
|
||||
|
||||
Представление сущностей
|
||||
-----------------------
|
||||
|
||||
Такие сущности как Сompute-инстанс представлены в виде классов. Эти классы напрямую
|
||||
вызывают методы libvirt для выполнения операций на гипервизоре. Пример класса — :data:`Volume`.
|
||||
|
||||
Конфигурационные файлы различных объектов libvirt в compute описаны специальными
|
||||
датаклассами. Датакласс хранит в своих свойствах параметры объекта и может вернуть XML
|
||||
конфиг для libvirt с помощью метода ``to_xml()``. Пример — :py:class:`VolumeConfig`.
|
||||
|
||||
Для валидации входных данных используются модели `Pydantic <https://docs.pydantic.dev/>`_.
|
||||
Пример — :py:class:`VolumeSchema`.
|
||||
|
||||
Документация модулей
|
||||
--------------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
session
|
||||
instance/index
|
||||
storage
|
5
docs/source/python-api/instance/guest_agent.rst
Normal file
5
docs/source/python-api/instance/guest_agent.rst
Normal file
@ -0,0 +1,5 @@
|
||||
``guest_agent``
|
||||
===============
|
||||
|
||||
.. automodule:: compute.instance.guest_agent
|
||||
:members:
|
10
docs/source/python-api/instance/index.rst
Normal file
10
docs/source/python-api/instance/index.rst
Normal file
@ -0,0 +1,10 @@
|
||||
``instance``
|
||||
============
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Содержание:
|
||||
|
||||
instance
|
||||
guest_agent
|
||||
schemas
|
6
docs/source/python-api/instance/instance.rst
Normal file
6
docs/source/python-api/instance/instance.rst
Normal file
@ -0,0 +1,6 @@
|
||||
``instance``
|
||||
============
|
||||
|
||||
.. automodule:: compute.instance.instance
|
||||
:members:
|
||||
:special-members:
|
5
docs/source/python-api/instance/schemas.rst
Normal file
5
docs/source/python-api/instance/schemas.rst
Normal file
@ -0,0 +1,5 @@
|
||||
``schemas``
|
||||
===========
|
||||
|
||||
.. automodule:: compute.instance.schemas
|
||||
:members:
|
9
docs/source/python-api/session.rst
Normal file
9
docs/source/python-api/session.rst
Normal file
@ -0,0 +1,9 @@
|
||||
``session``
|
||||
===========
|
||||
|
||||
.. autoclass:: compute.Session
|
||||
:members:
|
||||
:special-members:
|
||||
|
||||
.. autoclass:: compute.session.Capabilities
|
||||
:members:
|
14
docs/source/python-api/storage.rst
Normal file
14
docs/source/python-api/storage.rst
Normal file
@ -0,0 +1,14 @@
|
||||
``storage``
|
||||
===========
|
||||
|
||||
``compute.storage.pool``
|
||||
------------------------
|
||||
|
||||
.. automodule:: compute.storage.pool
|
||||
:members:
|
||||
|
||||
``compute.storage.volume``
|
||||
--------------------------
|
||||
|
||||
.. automodule:: compute.storage.volume
|
||||
:members:
|
Reference in New Issue
Block a user