HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/__pycache__/manage.cpython-310.pyc
o

�N�g�g�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZ	ddl
Z
ddlZddl
ZddlZddlZddlZddlZddlZddlZddlZddlZddlmZmZe�d�Ze�e�Zdd�Z	d:d
d�Zdd
�Z 	d;dd�Z!	d<dd�Z"d=dd�Z#d=dd�Z$d=dd�Z%d=dd�Z&d=dd�Z'd=dd�Z(d=dd �Z)d=d!d"�Z*d=d#d$�Z+d=d%d&�Z,d=d'd(�Z-d=d)d*�Z.d>d+d,�Z/d-d.�Z0	/	0	1	1	2				3	4d?d5d6�Z1	1			7			d@d8d9�Z2dS)Azd
General management functions for salt, tools like seeing what hosts are up
and what hosts are down
�N)�SaltClientError�SaltSystemExitz!^([a-f0-9]{2}:){15}([a-f0-9]{2})$cCs�tj�td��m}|j|dd|d|ddd�}|s!|Wd�St�dd�t|d	���t	�}|j
|d
|d	|�|�|||d�D]}|r[|��D]\}}	t�d|�|�
|�qKqCtt	|d	�|�}
t|�}||
fWd�S1sxwYdS)
N�	conf_filez	test.ping��T)�listenz3manage runner will ping the following minion(s): %sz, �minionsZjid)�gather_job_timeoutzminion '%s' returned from ping)�salt�client�get_local_client�__opts__Zrun_job�log�debug�join�sorted�setZget_cli_event_returnsZ_get_timeout�items�add)�tgt�tgt_type�timeoutr	rZpub_dataZreturnedZfn_retZmid�_Znot_returnedrr�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/manage.py�_ping!s:���
�	�$�rT�*�globcCsJi}|std}|std}t||||�}|sggfn|\|d<|d<|S)a�
    .. versionchanged:: 2017.7.0

        The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
        releases must use ``expr_form``.

    Print the status of all known salt minions

    CLI Example:

    .. code-block:: bash

        salt-run manage.status
        salt-run manage.status tgt="webservers" tgt_type="nodegroup"
        salt-run manage.status timeout=5 gather_job_timeout=10
    rr	�up�down)r
r)�outputrrrr	�ret�resrrr�statusDsr"c
Cs�tj�td�}z|�dd�Wnty'}zt|�WYd}~dSd}~wwtjj�	td�D]!\}}}|D]}t
j�||�}zt
�|�Wq8t
yQYq8wq1d}|S)a�
    This routine is used to regenerate all keys in an environment. This is
    invasive! ALL KEYS IN THE SALT ENVIRONMENT WILL BE REGENERATED!!

    The key_regen routine sends a command out to minions to revoke the master
    key and remove all minion keys, it then removes all keys from the master
    and prompts the user to restart the master. The minions will all reconnect
    and keys will be placed in pending.

    After the master is restarted and minion keys are in the pending directory
    execute a salt-key -A command to accept the regenerated minion keys.

    The master *must* be restarted within 60 seconds of running this command or
    the minions will think there is something wrong with the keys and abort.

    Only Execute this runner after upgrading minions and master to 0.15.1 or
    higher!

    CLI Example:

    .. code-block:: bash

        salt-run manage.key_regen
    rrzsaltutil.regen_keysNFZpki_dira�The minion and master keys have been deleted.  Restart the Salt
Master within the next 60 seconds!!!

Wait for the minions to reconnect.  Once the minions reconnect
the new keys will appear in pending and will need to be re-
accepted by running:
    salt-key -A

Be advised that minions not currently connected to the master
will not be able to reconnect and may require manual
regeneration via a local call to
    salt-call saltutil.regen_keys)r
rrr
�cmdr�print�utils�pathZos_walk�osr�remove�OSError)r�client_error�rootr�filesZfn_r&�msgrrr�	key_regencs(�����r.FcCsFtd||||d��dg�}|D]}|r tj�t�}|jd|d�q|S)a�
    .. versionchanged:: 2017.7.0

        The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
        releases must use ``expr_form``.

    Print a list of all the down or unresponsive salt minions
    Optionally remove keys of down minions

    CLI Example:

    .. code-block:: bash

        salt-run manage.down
        salt-run manage.down removekeys=True
        salt-run manage.down tgt="webservers" tgt_type="nodegroup"
    F�rrrrr	rz
key.delete)�match)r"�getr
�wheelZWheelr
Z	call_func)Z
removekeysrrrr	r �minionr2rrrr�s���rcCstd||||d��dg�}|S)a�
    .. versionchanged:: 2017.7.0

        The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
        releases must use ``expr_form``.

    Print a list of all of the minions that are up

    CLI Example:

    .. code-block:: bash

        salt-run manage.up
        salt-run manage.up tgt="webservers" tgt_type="nodegroup"
        salt-run manage.up timeout=5 gather_job_timeout=10
    Fr/r)r"r1)rrrr	r rrrr�s��rcCs8tjj�t�}|j||d�}|rt|�}|St|�}|S)a�
    .. versionadded:: 2015.8.0
    .. versionchanged:: 2019.2.0

    Print a list of all minions that are up according to Salt's presence
    detection (no commands will be sent to minions)

    subset : None
        Pass in a list of minion ids.

    show_ip : False
        Also show the IP address each minion is connecting from.

    CLI Example:

    .. code-block:: bash

        salt-run manage.list_state
    )�show_ip�subset)r
r%rZ	CkMinionsr
Z
connected_ids�dictr)r5r4Z	ckminionsr�	connectedrrr�
list_state�s�r8cCs~td|d�}tj�t��)}|��}g}||jD]}||vr+|dus&||vr+|�|�q|Wd�S1s8wYdS)a�
    .. versionadded:: 2015.8.0
    .. versionchanged:: 2019.2.0

    Print a list of all minions that are NOT up according to Salt's presence
    detection (no commands will be sent to minions)

    subset : None
        Pass in a list of minion ids.

    show_ip : False
        Also show the IP address each minion is connecting from.

    CLI Example:

    .. code-block:: bash

        salt-run manage.list_not_state
    N�r5r4)r8r
�key�get_keyr
Z	list_keysZACC�append)r5r4r7r:�keysZ
not_connectedr3rrr�list_not_state�s
�$�r>cC�t||d�S)a�
    .. versionchanged:: 2019.2.0

    Print a list of all minions that are up according to Salt's presence
    detection (no commands will be sent to minions)

    subset : None
        Pass in a list of minion ids.

    show_ip : False
        Also show the IP address each minion is connecting from.

    CLI Example:

    .. code-block:: bash

        salt-run manage.present
    r9�r8r9rrr�presentsrAcCr?)a�
    .. versionadded:: 2015.5.0
    .. versionchanged:: 2019.2.0

    Print a list of all minions that are NOT up according to Salt's presence
    detection (no commands will be sent)

    subset : None
        Pass in a list of minion ids.

    show_ip : False
        Also show the IP address each minion is connecting from.

    CLI Example:

    .. code-block:: bash

        salt-run manage.not_present
    r9�r>r9rrr�not_present-�rCcCr?)a�
    .. versionadded:: 2015.8.0
    .. versionchanged:: 2019.2.0

    Print a list of all minions that are up according to Salt's presence
    detection (no commands will be sent to minions)

    subset : None
        Pass in a list of minion ids.

    show_ip : False
        Also show the IP address each minion is connecting from.

    CLI Example:

    .. code-block:: bash

        salt-run manage.joined
    r9r@r9rrr�joinedDrDrEcCr?)a�
    .. versionadded:: 2015.8.0
    .. versionchanged:: 2019.2.0

    Print a list of all minions that are NOT up according to Salt's presence
    detection (no commands will be sent)

    subset : None
        Pass in a list of minion ids.

    show_ip : False
        Also show the IP address each minion is connecting from.

    CLI Example:

    .. code-block:: bash

        salt-run manage.not_joined
    r9rBr9rrr�
not_joined[rDrFcCr?)a�
    .. versionadded:: 2015.8.0
    .. versionchanged:: 2019.2.0

    Print a list of all minions that are up according to Salt's presence
    detection (no commands will be sent to minions)

    subset : None
        Pass in a list of minion ids.

    show_ip : False
        Also show the IP address each minion is connecting from.

    CLI Example:

    .. code-block:: bash

        salt-run manage.allowed
    r9r@r9rrr�allowedrrDrGcCr?)a�
    .. versionadded:: 2015.8.0
    .. versionchanged:: 2019.2.0

    Print a list of all minions that are NOT up according to Salt's presence
    detection (no commands will be sent)

    subset : None
        Pass in a list of minion ids.

    show_ip : False
        Also show the IP address each minion is connecting from.

    CLI Example:

    .. code-block:: bash

        salt-run manage.not_allowed
    r9rBr9rrr�not_allowed�rDrHcCr?)a�
    .. versionadded:: 2015.8.0
    .. versionchanged:: 2019.2.0

    Print a list of all minions that are up according to Salt's presence
    detection (no commands will be sent to minions)

    subset : None
        Pass in a list of minion ids.

    show_ip : False
        Also show the IP address each minion is connecting from.

    CLI Example:

    .. code-block:: bash

        salt-run manage.alived
    r9r@r9rrr�alived�rDrIcCr?)a�
    .. versionadded:: 2015.8.0
    .. versionchanged:: 2019.2.0

    Print a list of all minions that are NOT up according to Salt's presence
    detection (no commands will be sent)

    subset : None
        Pass in a list of minion ids.

    show_ip : False
        Also show the IP address each minion is connecting from.

    CLI Example:

    .. code-block:: bash

        salt-run manage.not_alived
    r9rBr9rrr�
not_alived�rDrJcCr?)a�
    .. versionadded:: 2015.8.0
    .. versionchanged:: 2019.2.0

    Print a list of all minions that are up according to Salt's presence
    detection (no commands will be sent to minions)

    subset : None
        Pass in a list of minion ids.

    show_ip : False
        Also show the IP address each minion is connecting from.

    CLI Example:

    .. code-block:: bash

        salt-run manage.reaped
    r9r@r9rrr�reaped�rDrKcCr?)a�
    .. versionadded:: 2015.8.0
    .. versionchanged:: 2019.2.0

    Print a list of all minions that are NOT up according to Salt's presence
    detection (no commands will be sent)

    subset : None
        Pass in a list of minion ids.

    show_ip : False
        Also show the IP address each minion is connecting from.

    CLI Example:

    .. code-block:: bash

        salt-run manage.not_reaped
    r9rBr9rrr�
not_reaped�rDrLc	Csltjjj��}|j|d|d�}i}|��D]j\}}t�|�s#|||<nUtj�	t
��
}|�|�}Wd�n1s9wY|�di�}	|�di�}
||	vrR||=q||
vr_d|�d�||<n|
||krpd�
||
|�||<nt�d	d
|g�||vr||=q|r�td�|��D]\}}t|�tdt|��t|�td
�q�t�ddt|�d�d�id�||fS)a�
    .. versionchanged:: 2017.7.0

        The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
        releases must use ``expr_form``.

    Accept a minion's public key after checking the fingerprint over salt-ssh

    CLI Example:

    .. code-block:: bash

        salt-run manage.safe_accept my_minion
        salt-run manage.safe_accept minion1,minion2 tgt_type=list
    z
key.finger)rNrZminions_prezMinion key z not found by salt-keyz4Minion key {} does not match the key in salt-key: {}zsalt-keyz-qyaz,safe_accept failed on the following minions:�-r�messagez	Accepted �dz keysZprogress)r
r�sshZ	SSHClientr#r�FINGERPRINT_REGEXr0r:ZKeyr
�fingerr1�format�
subprocess�callr$�lenZ
__jid_event__Z
fire_event)�targetrZ
ssh_clientr Zfailuresr3rRZsalt_keyZfingerprintsZaccepted�pendingrNrrr�safe_accept�sD

����
rYc
CsZi}tj�td�}z
|jdddtdd�}Wnty/}zt|�|WYd}~Sd}~wwdd	d
ddd
�}i}tjj}|D]<}||rL||drQd}d}	ntjj	�
||d�}tjj�
||�}	|	|vrli||	<|rv|j||	|<q@|||	|<q@|j|d<|D]&}
|
dkr�|d|||
<q�t||
�D]}||
||�||
i�|<q�q�|S)z{
    Check the version of active minions

    CLI Example:

    .. code-block:: bash

        salt-run manage.versions
    rrztest.versionTr)Zfull_returnrNzMinion offlinezMinion requires updatez
Up to datezMinion newer than masterZMaster)������r���retcodeFrZr r])r
rrr
r#rr$�versionZ__saltstack_version__ZSaltStackVersion�parser%�compat�cmp�stringr�
setdefault)r rrr*�labelsZversion_statusZmaster_versionr3Zminion_versionZver_diffr:rrr�versions5sL

����
�rf�develop�Vhttps://github.com/saltstack/salt-bootstrap/releases/latest/download/bootstrap-salt.shr�flat�/tmp/.bootstrap�tornadoc
Cs^t��}
|dur||
d<|dur||
d<|dur||
d<|dur$||
d<|�d�D]�}||
d<d|
d	<d
�|�d�t���}tj�	|d�}zNd
|dg|
d<t
jj�
|
���d|d|	��d|��g|
d<t
jj�
|
���dd�	d||g�dg|
d<t
jj�
|
���d|g|
d<t
jj�
|
���Wq)ty�}
z
t�t|
��WYd}
~
q)d}
~
wwdS)a�	
    Bootstrap minions with salt-bootstrap

    version : develop
        Git tag of version to install

    script : https://github.com/saltstack/salt-bootstrap/releases/latest/download/bootstrap-salt.sh
        URL containing the script to execute

    hosts
        Comma-separated hosts [example: hosts='host1.local,host2.local']. These
        hosts need to exist in the specified roster.

    script_args
        Any additional arguments that you want to pass to the script.

        .. versionadded:: 2016.11.0

    roster : flat
        The roster to use for Salt SSH. More information about roster files can
        be found in :ref:`Salt's Roster Documentation <ssh-roster>`.

        A full list of roster types, see the :ref:`builtin roster modules <all-salt.roster>`
        documentation.

        .. versionadded:: 2016.11.0

    ssh_user
        If ``user`` isn't found in the ``roster``, a default SSH user can be set here.
        Keep in mind that ``ssh_user`` will not override the roster ``user`` value if
        it is already defined.

        .. versionadded:: 2016.11.0

    ssh_password
        If ``passwd`` isn't found in the ``roster``, a default SSH password can be set
        here. Keep in mind that ``ssh_password`` will not override the roster ``passwd``
        value if it is already defined.

        .. versionadded:: 2016.11.0

    ssh_privkey
        If ``priv`` isn't found in the ``roster``, a default SSH private key can be set
        here. Keep in mind that ``ssh_password`` will not override the roster ``passwd``
        value if it is already defined.

        .. versionadded:: 2016.11.0

    tmp_dir : /tmp/.bootstrap
        The temporary directory to download the bootstrap script in. This
        directory will have ``-<uuid4>`` appended to it. For example:
        ``/tmp/.bootstrap-a19a728e-d40a-4801-aba9-d00655c143a7/``

        .. versionadded:: 2016.11.0

    http_backend : tornado
        The backend library to use to download the script. If you need to use
        a ``file:///`` URL, then you should set this to ``urllib2``.

        .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt-run manage.bootstrap hosts='host1,host2'
        salt-run manage.bootstrap hosts='host1,host2' version='v3006.2'
        salt-run manage.bootstrap hosts='host1,host2' version='v3006.2' script='https://github.com/saltstack/salt-bootstrap/develop'
    N�roster�ssh_userZ
ssh_passwdZssh_priv�,rrZselected_target_optionz{}-{}/�/z	deploy.shz
file.makedirsz	mode=0700�argvz
http.queryzbackend=z	text_out=zcmd.run� �shzpython_shell=Falsezfile.remove)r
�copy�splitrS�rstrip�uuidZuuid4r'r&rr
rrPZSSH�runrr�error�str)r_Zscript�hostsZscript_argsrlrmZssh_passwordZssh_priv_keyZtmp_dirZhttp_backendZclient_opts�hostZdeploy_command�excrrr�	bootstrappsFR�����r}�win32cs|sQd}tj�|���}t�d�}	tdd�|	�|�D�t�	d�dd�}
�r.�fdd	�|
D�}
�r9�fd
d	�|
D�}
|
s=dS|
dd
�|
dd�||
dd}d}d}d}
|r`|
d|��7}
d}�dkrn|�
d|d�}n|�
d|d�}|�
|||
�}d}||f||ffD]2\}}|�d�}|d|d|dd|dd|d�|d
d��d|d |d!7}q�t
jd"d#�d
}tjj�|d$��
}|�|�Wd�n1s�wY|�d%�D]$}d&d'|g}|r�|d(|g7}|r�|d)|g7}|d*d+|g7}t�|�q�dS),aF
    Bootstrap Windows minions via PsExec.

    hosts
        Comma separated list of hosts to deploy the Windows Salt minion.

    master
        Address of the Salt master passed as an argument to the installer.

    version
        Point release of installer to download. Defaults to the most recent.

    arch
        Architecture of installer to download. Defaults to win32.

    installer_url
        URL of minion installer executable. Defaults to the latest version from
        https://packages.broadcom.com/artifactory/saltproject-generic/windows/

    username
        Optional user name for login on remote computer.

    password
        Password for optional username. If omitted, PsExec will prompt for one
        to be entered for each host.

    CLI Example:

    .. code-block:: bash

        salt-run manage.bootstrap_psexec hosts='host1,host2'
        salt-run manage.bootstrap_psexec hosts='host1,host2' version='0.17' username='DOMAIN\Administrator'
        salt-run manage.bootstrap_psexec hosts='host1,host2' installer_url='http://exampledomain/salt-installer.exe'
    z$https://repo.saltproject.io/windows/zG>(Salt-Minion-(.+?)-(.+)-Setup.exe)</a></td><td align="right">(.*?)\s*<css,�|]\}}}}|||t�|d�gVqdS)z%d-%b-%Y %H:%MN)�time�strptime)�.0r&�ver�plat�daterrr�	<genexpr> s
�
�
�z#bootstrap_psexec.<locals>.<genexpr>�T)r:�reversec�g|]
}|d�kr|�qS)r\r�r��s)r_rr�
<listcomp>(�z$bootstrap_psexec.<locals>.<listcomp>cr�)r]rr�)�archrrr�*r�r[rr\r]a	strFileURL = "{0}"
strHDLocation = "{1}"
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing
Set objShell = CreateObject("WScript.Shell")
objShell.Exec("{1}{2}")zsaltinstall.exez /S /minion-name=%COMPUTERNAME%z	 /master=zvcredist.exeZAMD64zbhttp://download.microsoft.com/download/d/2/4/d242c3fb-da5a-4542-ad66-f9661d0a8d19/vcredist_x64.exez /qzbhttp://download.microsoft.com/download/d/d/9/dd9a82d0-52ef-40db-8dab-795376989c03/vcredist_x86.exezPcd /d %TEMP%
net stop salt-minion
del c:\salt\conf\pki\minion\minion_master.pub
�
z
del z
@echo z  >z.vbs
@echo z  >>Nz.vbs
cscript.exe /NoLogo z.vbsz.bat)�suffix�wbrnZpsexecz\\z-uz-pz-hz-c)�urllib�request�urlopen�read�re�compiler�findall�operator�
itemgetterrSrtr�tempfileZmkstempr
r%r,Zfopen�writerTrU)rzZmasterr_r�Z
installer_url�username�passwordZbase_url�sourceZsalty_rxZsource_listZ	vb_scriptZvb_saltexecZvb_saltexec_argsZvb_vcrunexecZvb_vcrunZvb_saltZbatch�x�yZvb_linesZ
batch_pathZ
batch_filer{rpr)r�r_r�bootstrap_psexec�s�/���
���
��������	�
������r�)TrrNN)FrrNN)rrNN)NF)r)
rgrhrrriNNNrjrk)rNNr~NNN)3�__doc__�loggingr�r'r�rTr�r�urllib.requestr�rvZsalt.clientr
Zsalt.client.sshZsalt.keyZsalt.utils.compatZsalt.utils.filesZsalt.utils.minionsZsalt.utils.pathZsalt.utils.versionsZsalt.versionZ
salt.wheelZsalt.exceptionsrrr�rQ�	getLogger�__name__rrr"r.rrr8r>rArCrErFrGrHrIrJrKrLrYrfr}r�rrrr�<module>s�

$
�7
�#
�


!









9<
�{�