HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/cloud.cpython-310.pyc
o

�N�g�%�@sFdZddlZddlZddlZddlZddlmZzddlZdZ	Wne
y+dZ	Ynwe�e�Z
ddiZdd	�Zd
d�Zd;d
d�Zd;dd�Zd;dd�Zd<dd�Zd=dd�Zd>dd�Zd?dd�Zd?dd�Zd@d d�Zd?d!d"�Zd#d$�ZdAd%d&�Zd?d'd(�Zd)d*�Zd+d,�Zd-d.�Z d/d0�Z!d1d2�Z"d3d4�Z#d5d6�Z$d7d8�Z%d9d:�Z&dS)Bz9
Salt-specific interface for calling Salt Cloud directly
�N)�SaltCloudConfigErrorTF�profile_�profilecCstrdSdS)z)
    Only work on POSIX-like systems
    T)FzSThe cloud execution module cannot be loaded: only available on non-Windows systems.)�
HAS_SALTCLOUD�rr�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/cloud.py�__virtual__srcCs8tjjtj�tj�td�d�t�	t
�di��d�}|S)z
    Return a cloud client
    Z	conf_file�cloud)Zpillars)�saltr	ZCloudClient�os�path�join�dirnameZ__opts__�copy�deepcopyZ
__pillar__�get)�clientrrr�_get_client&s
�r�allcC�t�}|�|�}|S)z�
    List cloud provider sizes for the given providers

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.list_sizes my-gce-config
    )r�
list_sizes)�providerrZsizesrrrr1�

rcCr)z�
    List cloud provider images for the given providers

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.list_images my-gce-config
    )r�list_images)rrZimagesrrrr@rrcCr)z�
    List cloud provider locations for the given providers

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.list_locations my-gce-config
    )r�list_locations)rrZ	locationsrrrrOrr�
list_nodescCr)z�
    List cloud provider data for all providers

    CLI Examples:

    .. code-block:: bash

        salt minionname cloud.query
        salt minionname cloud.query list_nodes_full
        salt minionname cloud.query list_nodes_select
    )r�query)�
query_typer�inforrrr^s
r�list_nodes_fullcC�
t|d�S)z�
    List all available cloud provider data

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.full_query
    �r�rr!rrr�
full_queryo�

r#�list_nodes_selectcCr )zu
    List selected nodes

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.select_query
    r!r"r!rrr�select_query|r$r&cCst||�}|durdSdS)z�
    Return true if the instance is found on a provider

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.has_instance myinstance
    NFT)�get_instance)�namer�datarrr�has_instance�s

r*cCsbtd|g|d�}tjj�|�}ztttttt|������������}W|Sty0YdSw)aY
    Return details on an instance.

    Similar to the cloud action show_instance
    but returns only the instance details.

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.get_instance myinstance

    SLS Example:

    .. code-block:: bash

        {{ salt['cloud.get_instance']('myinstance')['mac_address'] }}

    Z
show_instance)�fun�namesrN)	�actionr
�utilsr)Zsimple_types_filter�next�iter�values�AttributeError)r(rr)rrrrr'�s*��r'cKs8t�}t|t�r|j�|�|j||fd|i|��}|S)z�
    Spin up an instance using Salt Cloud

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.profile my-gce-config myinstance
    �vm_overrides)r�
isinstance�dict�opts�updater)rr,r3r6�kwargsrrrrrr�s


cKst�}|j|fi|��}|S)aR
    Execute a salt cloud map file

    Cloud Map data can be retrieved from several sources:

    - a local file (provide the path to the file to the 'path' argument)
    - a JSON-formatted map directly (provide the appropriately formatted to using the 'map_data' argument)
    - the Salt Pillar (provide the map name of under 'pillar:cloud:maps' to the 'map_pillar' argument)

    .. note::
        Only one of these sources can be read at a time. The options are listed
        in their order of precedence.

    CLI Examples:

    .. code-block:: bash

        salt minionname cloud.map_run /path/to/cloud.map
        salt minionname cloud.map_run path=/path/to/cloud.map
        salt minionname cloud.map_run map_pillar='<map_pillar>'
          .. versionchanged:: 2018.3.1
        salt minionname cloud.map_run map_data='<actual map data>'
    )r�map_run)rr8rrrrrr9�sr9cCr)z
    Destroy the named VM(s)

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.destroy myinstance
    )r�destroy)r,rrrrrr:�rr:c	
KsRt�}z
|�||||||�}W|Sty(}zt�|�WYd}~dSd}~ww)aD
    Execute a single action on the given provider/instance

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.action start instance=myinstance
        salt minionname cloud.action stop instance=myinstance
        salt minionname cloud.action show_image provider=my-ec2-config image=ami-1624987f
    N)rr-r�log�error)	r+Zcloudmapr,r�instancer8rr�errrrrr-�s�
��r-cKs4t�}t|t�r|j�|�|j||fi|��}|S)z�
    Create an instance using Salt Cloud

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.create my-ec2-config myinstance image=ami-1624987f size='t1.micro' ssh_username=ec2-user securitygroup=default delvol_on_destroy=True
    )rr4r5r6r7�create)rr,r6r8rrrrrr?
s


r?cCst�}|jd|dd�}|dS)z�
    List block storage volumes

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.volume_list my-nova

    �volume_listr(�r-rr,�rZextra_action)rrrrrrr@sr@cK�"t�}|jd||dd�|��}|S)z�
    Delete volume

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.volume_delete my-nova myblock

    �
volume_delete�rr,r-NrrB�rr,r8rrrrrrD+���rDcKs"t�}|jdd||d�|��}|S)z�
    Create volume

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.volume_create my-nova myblock size=100 voltype=SSD

    �
volume_create)r-r,rNrrBrFrrrrH=rGrHcKrC)z�
    Attach volume to a server

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.volume_attach my-nova myblock server_name=myserver device='/dev/xvdf'

    �
volume_attachrENrrBrFrrrrIOrGrIcKrC)z�
    Detach volume from a server

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.volume_detach my-nova myblock server_name=myserver

    �
volume_detachrENrrBrFrrrrJarGrJcCst�}|jd|dd�S)z�
    List private networks

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.network_list my-nova

    �network_listr,rArB)rrrrrrKssrKcK�t�}|jd||dd�|��S)z�
    Create private network

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.network_create my-nova names=['salt'] cidr='192.168.100.0/24'

    �network_createrENrrB�rr,r8rrrrrM����rMcKrL)z�
    List virtual interfaces on a server

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.virtual_interface_list my-nova names=['salt-master']

    �virtual_interface_listrENrrBrNrrrrP�rOrPcKrL)z�
    Attach private interfaces to a server

    CLI Example:

    .. code-block:: bash

        salt minionname cloud.virtual_interface_create my-nova names=['salt-master'] net_name='salt'

    �virtual_interface_createrENrrBrNrrrrQ�rOrQ)r)r)r)r%)N)NN)NNNNN)'�__doc__r�loggingrZsalt.utils.datar
Zsalt.exceptionsrZ
salt.cloudr�ImportError�	getLogger�__name__r;Z__func_alias__rrrrrrr#r&r*r'rr9r:r-r?r@rDrHrIrJrKrMrPrQrrrr�<module>sL�