File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/nova.cpython-310.pyc
o
�N�gbN �
@ s� d Z ddlZe�e�ZddiZzddlm m m Z
dZW n ey3 Z
zdZW Y dZ
[
ndZ
[
ww dZdd � ZdId
d�ZdJd
d�ZdKdd�ZdIdd�ZdLdd�ZdIdd�ZdMdd�ZdNdd�ZdIdd�ZdIdd �ZdId!d"�ZdId#d$�ZdId%d&�Z ' dOd(d)�ZdId*d+�ZdId,d-�ZdPd.d/�Z dId0d1�Z!dKd2d3�Z" dPd4d5�Z# dQd6d7�Z$dId8d�Z%dId9d:�Z&dId;d<�Z'dId=d>�Z(dId?d@�Z)dIdAdB�Z*dIdCdD�Z+dIdEdF�Z,dIdGdH�Z-dS )Ra
Module for handling OpenStack Nova calls
:depends: - novaclient Python module
:configuration: This module is not usable until the user, password, tenant, and
auth URL are specified either in a pillar or in the minion's config file.
For example:
.. code-block:: yaml
keystone.user: admin
keystone.password: verybadpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
# Optional
keystone.region_name: 'RegionOne'
If configuration for multiple OpenStack accounts is required, they can be
set up as different configuration profiles:
For example:
.. code-block:: yaml
openstack1:
keystone.user: admin
keystone.password: verybadpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
openstack2:
keystone.user: admin
keystone.password: verybadpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.2:5000/v2.0/'
With this configuration in place, any of the nova functions can make use of
a configuration profile by declaring it explicitly.
For example:
.. code-block:: bash
salt '*' nova.flavor_list profile=openstack1
To use keystoneauth1 instead of keystoneclient, include the `use_keystoneauth`
option in the pillar or minion config.
.. note::
This is required to use keystone v3 as for authentication.
.. code-block:: yaml
keystone.user: admin
keystone.password: verybadpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.1:5000/v3/'
keystone.use_keystoneauth: true
keystone.verify: '/path/to/custom/certs/ca-bundle.crt'
.. note::
By default the nova module will attempt to verify its connection
utilizing the system certificates. If you need to verify against
another bundle of CA certificates or want to skip verification
altogether you will need to specify the `verify` option. You can
specify True or False to verify (or not) against system certificates, a
path to a bundle or CA certs to check against, or None to allow
keystoneauth to search for the certificates on its own. (defaults to
True)
� N�list_�listTF�novac C s t S )zH
Only load this module if nova
is installed on this minion.
)�HAS_NOVA� r r �E/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/nova.py�__virtual__Z s r c
C s0 | r7t d | �}|d }|d }|d }|d }|�dd�}|�dd�}|�d d�}|�d
d�} |�dd�}
n6t d d�}t d d�}t d d�}t d d�}t d d�}t d d�}t d d �}t d d
�} t d d�}
| d
u r�|d }|d }|||||| |
||d� }
n
|||||||d�}
tjdi |
��S )z!
Set up nova credentials
z
config.optionz
keystone.userzkeystone.passwordzkeystone.tenantzkeystone.auth_urlzkeystone.region_nameNzkeystone.api_keyzkeystone.os_auth_systemzkeystone.use_keystoneauthFzkeystone.verifyTzkeystone.project_domain_namezkeystone.user_domain_name) �username�password�
project_id�auth_url�region_name�use_keystoneauth�verify�project_domain_name�user_domain_name)r r
�api_keyr r r
Zos_auth_pluginr )Z__salt__�get�suonZSaltNova)�profileZcredentials�userr
Ztenantr r
r Zos_auth_systemr r r r �kwargsr r r �_authb sT �
�
r �, c C � t |�}|�| |||�S )a�
Boot (create) a new instance
name
Name of the new instance (must be first)
flavor_id
Unique integer ID for the flavor
image_id
Unique integer ID for the image
timeout
How long to wait, after creating the instance, for the provider to
return information about it (default 300 seconds).
.. versionadded:: 2014.1.0
CLI Example:
.. code-block:: bash
salt '*' nova.boot myinstance flavor_id=4596 image_id=2
The flavor_id and image_id are obtained from nova.flavor_list and
nova.image_list
.. code-block:: bash
salt '*' nova.flavor_list
salt '*' nova.image_list
)r �boot)�name� flavor_id�image_idr �timeout�connr r r r � s !r c C s t |�}|j| d�S )a
List storage volumes
search_opts
Dictionary of search options
profile
Profile to use
CLI Example:
.. code-block:: bash
salt '*' nova.volume_list search_opts='{"display_name": "myblock"}' profile=openstack
)�search_opts)r �volume_list)r! r r r r r r"