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/cloud/__pycache__/cli.cpython-310.pyc
o

�N�g�>�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlZddlZddl
ZddlmZmZddlmZmZe�e�ZGdd�dejjj�ZdS)z.
Primary interfaces for the salt-cloud system
�N)�SaltCloudException�SaltCloudSystemExit)�
check_user�
verify_envc@s$eZdZdd�Zdd�Zdd�ZdS)�	SaltCloudc"
CsJ|��|j�d�}|durtjj��}t|�s"|�d�	|t
j��z|jdr:tt
j�|jd�g||jdd�WntyY}zt�d|�t�|j�WYd}~nd}~ww|jjrztjj�|j�}tjj||jj|jd	�|�tjjj�t�d
�z	tj�|j�}Wn2ty�}z
|� |j!|�WYd}~nd}~wt"y�}zd}|� ||�WYd}~nd}~ww|j�dd�}|dur�i}|j#D]}	i}
|j#|	D]}||vr�|j#|	||
|<q�|
r�|
||	<q�||_#i}|j$du�r�|j$d
k�r z|�%�}W�nt&�y}zd}|� ||�WYd}~�n�d}~ww|j$dk�rO|jj'}z|�(|�}W�n�t&�yN}zd}|� ||�WYd}~�n�d}~ww|j�dd��r�t�d|jd�z
|j)|j$d�}W�n�t&�y�}zd}|� ||�WYd}~�n�d}~wwz
|j*|j$d�}W�n}t&�y�}zd}|� ||�WYd}~�nfd}~ww|jj+du�r�z
|�,|jj+�}W�nOt&�y�}zd}|� ||�WYd}~�n8d}~ww|jj-du�r
z
|�.|jj-�}W�n!t&�y	}zd}|� ||�WYd}~�n
d}~ww|jj/du�r8z
|�0|jj/�}W�n�t&�y7}zd}|� ||�WYd}~�n�d}~ww|jj1�r�|j�dd��sM|j�dd��r�|j�dd�}
|j�dd�}|
du�r~|dk�rqd�	|
|�}|� |t�t�d|
�|j2dd�}n	|j3||jj4d�}|�s�t5d�|�tjjj�d}t6�}|�7�D]2\}}|d|�d �7}|�7�D] \}}|d!|�d �7}|D]}|d"|�d#�7}|�8|��q��q��q�z|�9|��r�|j1|d$d%�}W�n,t&�y�}zd&}|� ||�WYd}~�nd}~ww|jj:�r�|j�dd��s|j�dd��r�|j�dd��rJt�d|jd�z	|�;|jj:�}Wn"t"�yI}zd'}|� ||�WYd}~nd}~ww|j�dd�}i}g}d(�	|jj:�}|D]#}d)|v�rs|�<d)d*�\}}|||<�q^|d|�d#�7}|�=|��q^|}z|�9|��r�|�>||�}W�n{t&�y�}zd+}|� ||�WYd}~�ndd}~ww|jj?�ri}|j!dd�}|dd�D]}d)|v�r�|�<d)d*�\}}|||<|�@|��q�|�r�|�d,�	|��z|�A|jB|jC|�}W�nt&�y}zd-}|� ||�WYd}~�nd}~ww|jj4�rK|j�dd.��rKz|�D|jj4|j�d��}W�n�t&�yJ}zd/}|� ||�WYd}~�n�d}~ww|jjE�rc|jF}d0|jG��}tjj�H||��n�|j�dd��r�|j$du�r�|j#�s�tjI�Jd1�|�tjjjK�z�i}d$}t�d|jd�|�L�}d2}d3|v�r�|d47}|d3�7�D]\}}|d|�d5|�d#�7}�q�tjI�J|�tjI�M�d2}d6|v�r�|d77}|d6D]}|d|�d#�7}�q�|d8�r�|d97}|d8D]}|d|�d#�7}�q�d:|v�r|d7}|d:D]}|d|�d#�7}�q|d8�s.|�d:d��s.|�d6d��s,t5|�|�d*�nd.}|�rK|�9|��r<|�N|�}|j�d;d.�d.u�rKt�d<�|�d6d��rp|d6D]}d=|d6|d>v�rfd?}nd@}dA|i||<�qVWn�t&�y�}zdB}|� ||�WYd}~n�d}~ww|jjO�r
|jjO}|j!�r�d)|j!dCv�r�|j!�PdC�} n|} d2|| dD�}!|j!dd�}|dd�D]}d)|v�r�|�<d)d*�\}}||!|<|�@|��q�|�r�|�dE�	|��ztjj�O|!|j�}Wn t&�y	}zdF}|� ||�WYd}~n
d}~ww|�dG�tjj||jj|jd	�|�tjjj�dS)Hz5
        Execute the salt-cloud command line
        �userNa#If salt-cloud is running on a master machine, salt-cloud needs to run as the same user as the salt-master, '{0}'. If salt-cloud is not running on a salt-master, the appropriate write permissions must be granted to '{1}'. Please run salt-cloud as root, '{0}', or change permissions for '{1}'.rZ	conf_file�root_dir)rz)Error while verifying the environment: %s)�optszsalt-cloud startingz)There was an error generating the mapper.�namesZlist_providersz)There was an error listing providers: {0}�
list_profilesz(There was an error listing profiles: {0}�mapzApplying map from '%s'.)�queryz)There was an error with a custom map: {0}z"There was an error with a map: {0}z)There was an error listing locations: {0}z&There was an error listing images: {0}z%There was an error listing sizes: {0}�z�Supplying a mapfile, '{}', in addition to instance names {} with the '--destroy' or '-d' function is not supported. Please choose to delete either the entire map file or individual instances.Z
list_nodes)�profilez&No machines were found to be destroyedz8The following virtual machines are set to be destroyed:
z  z:
z    z      �
T)�cachedz+There was an error destroying machines: {0}z.There was an error actioning virtual machines.zAThe following virtual machines are set to be actioned with "{}":
�=�z*There was an error actioning machines: {0}zoAny arguments passed to --function need to be passed as kwargs. Ex: image=ami-54cf5c3d. Remaining arguments: {}z,There was an error running the function: {0}FzThere was a profile error: {0}zsalt.cloud.provider.zNo nodes defined in this map��errorszFound the following errors:
z: �existingz.The following virtual machines already exist:
�createz6The following virtual machines are set to be created:
�destroyZparallelZCompleteZec2�providerz@Instance already exists, or is terminated and has the same name.zAlready running.�MessagezThere was a query error: {0}r)�driverZssh_host�namezpAny arguments passed to --bootstrap need to be passed as kwargs. Ex: ssh_username=larry. Remaining arguments: {}z0There was an error bootstrapping the minion: {0}z-Nothing was done. Using the proper arguments?)Q�
parse_argsZconfig�get�salt�utilsrZget_userr�error�format�syspathsZ
CONFIG_DIRr�os�path�dirname�OSError�log�sys�exit�errno�optionsZupdate_bootstrapZcloud�outputZdisplay_output�defaults�	exitcodes�EX_OK�infoZMapr�handle_exception�argsrZrendered_mapZselected_query_optionZ
provider_list�	ExceptionrZprofile_listZinterpolated_mapZmap_providers_parallelZlist_locationsZ
location_listZlist_imagesZ
image_listZ
list_sizesZ	size_listrZ
delete_mapZget_running_by_namesr�print�set�items�add�
print_confirm�actionZget_vmnames_by_action�split�appendZ	do_action�function�removeZdo_functionZfunction_providerZ
function_nameZrun_profileZset_passwordZcredential_usernameZcredential_providerZstore_password_in_keyring�stderr�write�
EX_GENERICZmap_data�flush�run_map�	bootstrap�pop)"�selfZsalt_master_user�err�retZmapper�exc�msgr
Zfiltered_rendered_mapZmap_profileZfiltered_map_profilerrZmap_fileZmatching�aliasZdriversrZvms�kwargsZmachines�key�valuer3�arg�usernameZ
provider_namerCZdmapZprofile_namer!�hostZ	minion_idZvm_rr�B/opt/saltstack/salt/lib/python3.10/site-packages/salt/cloud/cli.py�run"sl
�	
����
���
������������������
��

�������
����
�
���


��

�����







����
�

�����
z
SaltCloud.runcCs:|jjrdSt|�td�}|���d�sdStd�dS)NTzProceed? [N/y] �yFz... proceeding)r,Z
assume_yesr5�input�lower�
startswith)rFrJ�resrrrRr9qszSaltCloud.print_confirmcCs~t|t�r*t|t�r"|jdkrd|��}|�|j|�|���d�|�|�|��tj|�|�t	j
d�|�tjj
j�dS)NrzError: r)Zexc_info_on_loglevel)�
isinstancerrZ	exit_coder*r"�rstripr!r(�logging�DEBUGrr.r/rA)rFrJrIrrrRr2{s



�zSaltCloud.handle_exceptionN)�__name__�
__module__�__qualname__rSr9r2rrrrRr!sQ
r)�__doc__r[r$r)Z
salt.cloudrZsalt.configZsalt.defaults.exitcodesZsalt.outputZ
salt.syspathsr#Zsalt.utils.cloudZsalt.utils.parsersZsalt.utils.userZsalt.exceptionsrrZsalt.utils.verifyrr�	getLoggerr]r(r �parsersZSaltCloudParserrrrrrR�<module>s