add docs
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
			
		||||
{% if versions %}
 | 
			
		||||
<h3>{{ _('Versions') }}</h3>
 | 
			
		||||
<h3>{{ _('Версии') }}</h3>
 | 
			
		||||
<ul>
 | 
			
		||||
  {%- for item in versions %}
 | 
			
		||||
  <li><a href="{{ item.url }}">{{ item.name }}</a></li>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,35 +1,32 @@
 | 
			
		||||
# Configuration file for the Sphinx documentation builder.
 | 
			
		||||
#
 | 
			
		||||
# For the full list of built-in configuration values, see the documentation:
 | 
			
		||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
 | 
			
		||||
 | 
			
		||||
# -- Project information -----------------------------------------------------
 | 
			
		||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
 | 
			
		||||
import os
 | 
			
		||||
import sys
 | 
			
		||||
sys.path.insert(0, os.path.abspath('../../compute'))
 | 
			
		||||
 | 
			
		||||
# Project information
 | 
			
		||||
project = 'Compute'
 | 
			
		||||
copyright = '2023, Compute Authors'
 | 
			
		||||
author = 'Compute Authors'
 | 
			
		||||
release = '0.1.0'
 | 
			
		||||
 | 
			
		||||
# -- General configuration ---------------------------------------------------
 | 
			
		||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
 | 
			
		||||
 | 
			
		||||
extensions = []
 | 
			
		||||
 | 
			
		||||
# Sphinx general settings
 | 
			
		||||
extensions = [
 | 
			
		||||
    'sphinx.ext.autodoc',
 | 
			
		||||
    'sphinx_multiversion',
 | 
			
		||||
]
 | 
			
		||||
templates_path = ['_templates']
 | 
			
		||||
exclude_patterns = []
 | 
			
		||||
 | 
			
		||||
language = 'ru'
 | 
			
		||||
 | 
			
		||||
extensions = [
 | 
			
		||||
    "sphinx_multiversion",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
# -- Options for HTML output -------------------------------------------------
 | 
			
		||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
 | 
			
		||||
 | 
			
		||||
# HTML output settings
 | 
			
		||||
html_theme = 'alabaster'
 | 
			
		||||
html_static_path = ['_static']
 | 
			
		||||
html_sidebars = [
 | 
			
		||||
    "versioning.html",
 | 
			
		||||
]
 | 
			
		||||
html_sidebars = {
 | 
			
		||||
    '**': [
 | 
			
		||||
        'about.html',
 | 
			
		||||
        'navigation.html',
 | 
			
		||||
        'relations.html',
 | 
			
		||||
        'searchbox.html',
 | 
			
		||||
        'donate.html',
 | 
			
		||||
        'versioning.html',
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,9 @@ Compute Service
 | 
			
		||||
Документация библиотеки для управления Compute-инстансами.
 | 
			
		||||
 | 
			
		||||
.. toctree::
 | 
			
		||||
   :maxdepth: 2
 | 
			
		||||
   :caption: Contents:
 | 
			
		||||
    :maxdepth: 1
 | 
			
		||||
 | 
			
		||||
    python-api/index
 | 
			
		||||
 | 
			
		||||
Индексы и таблицы
 | 
			
		||||
-----------------
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										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