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__/rabbitmq.cpython-310.pyc
o

�N�g3��@sZdZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
ZddlZddlm
Z
mZddlmZe�e�Zdadadd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Zdddd�Zdd�Zdd�Zdddd�Zdddd�Z dddd�Z!dddd�Z"dddd �Z#ddd!d"�Z$ded#d$�Z%ddd%d&�Z&ddd'd(�Z'ddd)d*�Z(ddd+d,�Z)ddd-d.�Z*ddd/d0�Z+dfd2d3�Z,ddd4d5�Z-ddd6d7�Z.ddd8d9�Z/ddd:d;�Z0ddd<d=�Z1dgd?d@�Z2dddAdB�Z3dddCdD�Z4dddEdF�Z5dddGdH�Z6dddIdJ�Z7dddKdL�Z8dhdNdO�Z9	didPdQ�Z:dddRdS�Z;dddTdU�Z<dddVdW�Z=dddXdY�Z>dddZd[�Z?ddd\d]�Z@ddd^d_�ZA											djd`da�ZBdddbdc�ZCdS)kz�
Module to provide RabbitMQ compatibility to Salt.
Todo: A lot, need to add cluster support, logging, and minion configuration
data.
�N)�CommandExecutionError�SaltInvocationError)�Versionc	CsXtjj��r�ddl}d}z�zk|�|jdd|j|jB�}|�	|d�\}}||j
kr/td|����tj
�|�s<td|����d}t�|�D]}|�d�r]tj
�||�}tj
�|�r]||kr]|}qC|sgtd	|����tj
�|d
d�atj
�|d
d�aWn	ty�YnwW|dur�|�|�n|dur�|�|�wwtjj
�d
�atjj
�d�ats�dSdS)z'
    Verify RabbitMQ is installed.
    rNz%SOFTWARE\VMware, Inc.\RabbitMQ ServerZInstall_Dirz(Invalid RabbitMQ Server directory type: zRabbitMQ directory not found: �zrabbitmq_server-z/"rabbitmq_server-*" subdirectory not found in: Zsbinzrabbitmqctl.batzrabbitmq-plugins.batZrabbitmqctlzrabbitmq-plugins)Fz=Module rabbitmq: module only works when RabbitMQ is installedT)�salt�utils�platform�
is_windows�winreg�	OpenKeyEx�HKEY_LOCAL_MACHINEZKEY_READZKEY_WOW64_32KEY�QueryValueExZREG_SZ�	TypeError�os�path�isdir�OSError�listdir�
startswith�join�RABBITMQCTL�RABBITMQ_PLUGINS�	ExceptionZCloseKey�which)r
�keyZdir_pathZ
value_typeZsubdir_match�nameZsubdir_path�r�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/rabbitmq.py�__virtual__sZ
�

�����
���rcCsNt|t�r|ddks|drtd�|d���dSd|vr%td|����dS)N�retcoder�stderr�RabbitMQ command failed: {}�Error�RabbitMQ command failed: ��
isinstance�dictr�format)�responserrr�_check_responseOs
���r)cCs^t|t�r |ddks|drtd�|d���|d}||iSd|vr+td|����||iS)Nrrr r!�stdoutr"r#r$)r(�msgrrr�_format_responseZs
��r,cCs,tdurtdd��d�d}d�|�atS)z�
    Returns the rabbitmq-plugin command path if we're running an OS that
    doesn't put it in the standard /usr/bin or /usr/local/bin
    This works by taking the rabbitmq-server version and looking for where it
    seems to be hidden in /usr/lib.
    N�pkg.version�rabbitmq-server�-rz>/usr/lib/rabbitmq/lib/rabbitmq_server-{}/sbin/rabbitmq-plugins)r�__salt__�splitr')�versionrrr�_get_rabbitmq_pluginhs	��r3cCsDt|�d�o
|�d�|�d�od|vd|v|�d�t|�dkg�S)z�
    Looks for rabbitmqctl warning, or general formatting, strings that aren't
    intended to be parsed as output.
    Returns a boolean whether the line can be parsed as rabbitmqctl output.
    ZListingz...�	z...donezWARNING:r)�anyr�endswith�len)�linerrr�_safe_output|s
��r9cCsdd�|D�S)z�
    Conditionally remove non-relevant first and last line,
    "Listing ..." - "...done".
    outputlist: rabbitmq command output split by newline
    return value: list, conditionally modified, may be empty.
    cSsg|]}t|�r|�qSr)r9��.0r8rrr�
<listcomp>�sz*_strip_listing_to_done.<locals>.<listcomp>r)Zoutput_listrrr�_strip_listing_to_done�sr=c	Cs�t|t�r|ddks|drtd�|d���|d}i}|dur&dd�}t|���}|D]'}z
|�d	d
�\}}WntyNt�	d||�d||<Yq.w||�||<q.|S)
z�
    Convert rabbitmqctl output to a dict of data
    cmdoutput: string output of rabbitmqctl commands
    values_mapper: function object to process the values part of each line
    rrr r!r*NcSs
|�d�S)Nr4�r1��stringrrr�
values_mapper�s
z&_output_to_dict.<locals>.values_mapperr4�zKCould not find any values for key '%s'. Setting to '%s' to an empty string.r)
r%r&rr'r=�
splitlinesr1�
ValueError�log�debug)�	cmdoutputrA�retZ	data_rows�rowr�valuesrrr�_output_to_dict�s0
���rKcC�dd�|��D�S)z�
    Convert rabbitmqctl output to a list of strings (assuming whitespace-delimited output).
    Ignores output lines that shouldn't be parsed, like warnings.
    cmdoutput: string output of rabbitmqctl commands
    cSs&g|]}t|�r|��D]}|�qqSr)r9r1)r;r8�itemrrrr<�s����z#_output_to_list.<locals>.<listcomp>�rC�rGrrr�_output_to_list�s�rPcCrL)z�
    Convert rabbitmqctl output to a list of strings (assuming newline-delimited output).
    Ignores output lines that shouldn't be parsed, like warnings.
    cmdoutput: string output of rabbitmqctl commands
    cSsg|]
}t|�r|���qSr)r9�stripr:rrrr<�sz)_output_lines_to_list.<locals>.<listcomp>rNrOrrr�_output_lines_to_list�srRcCsL|durtjj��stjj��}tdtddgd|dd�}dd�}t||�S)	z�
    Return a list of users based off of rabbitmqctl user_list.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.list_users
    N�cmd.run_all�
list_users�-qF��reset_system_locale�runas�python_shellcSs@d|vrdd�|dd��d�D�Sdd�|dd��d�D�S)N�,cSsg|]}|���qSr)rQ�r;�xrrrr<��z,list_users.<locals>.func.<locals>.<listcomp>rB���cSsg|]}|�qSrrr[rrrr<�s� r>r?rrr�func�szlist_users.<locals>.func)	rrrr	�user�get_userr0rrK)rX�resr`rrrrT�s
�
rTcCsN|durtjj��stjj��}tdtddgd|dd�}t|�t	|d�S)z�
    Return a list of vhost based on rabbitmqctl list_vhosts.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.list_vhosts
    NrS�list_vhostsrUFrVr*)
rrrr	rarbr0rr)rP�rXrcrrrrd�s
�rdcCsv|durtjj��stjj��}i}tdtddgd|dd�}|d�d�D]}t	|�r8|�d	�\}}}|||<q&|S)
a
    Returns a dict of upstreams based on rabbitmqctl list_parameters.

    :param str runas: The name of the user to run this command as.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.list_upstreams

    .. versionadded:: 3000
    NrSZlist_parametersrUFrVr*�
r4)
rrrr	rarbr0rr1r9)rXrHrcZraw_line�_r�
definitionrrr�list_upstreamss��ricC�.|durtjj��stjj��}|t|d�vS)z�
    Return whether the user exists based on rabbitmqctl list_users.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.user_exists rabbit_user
    N�rX)rrrr	rarbrT�rrXrrr�user_exists,�
rmcCrj)z�
    Return whether the vhost exists based on rabbitmqctl list_vhosts.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.vhost_exists rabbit_host
    Nrk)rrrr	rarbrdrlrrr�vhost_exists;rnrocCrj)aS
    Return whether the upstreamexists based on rabbitmqctl list_parameters.

    :param str name: The name of the upstream to check for.
    :param str runas: The name of the user to run the command as.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.upstream_exists rabbit_upstream

    .. versionadded:: 3000
    Nrk)rrrr	rarbrirlrrr�upstream_existsJsrpcCs�d}|durd}d�dd�td�D��}|dur$tjj��s$tjj��}tjj��r9d}dt�d	|�d
|�d�}nd}td||g}t	d|dd
||d�}|rczt
||�Wn
tybt||��wd}t
||�S)z�
    Add a rabbitMQ user via rabbitmqctl user_add <user> <password>

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.add_user rabbit_user password
    FNTrcss&�|]}t���tjtj�VqdS�N)�random�SystemRandom�choicer@�ascii_uppercase�digitsr[rrr�	<genexpr>ms
��
�zadd_user.<locals>.<genexpr>��"z" add_user "�" "�add_userrS�quiet)rW�output_loglevelrXrY�Added)r�rangerrrr	rarbrr0�clear_passwordr�delete_userr,)r�passwordrXZclear_pwrY�cmdrcr+rrrr{^s:

��
�
r{cCsH|durtjj��stjj��}tdtd|gdd|d�}d}t||�S)z�
    Deletes a user via rabbitmqctl delete_user.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.delete_user rabbit_user
    NrSr�F)rWrYrX�Deleted�	rrrr	rarbr0rr,�rrXrcr+rrrr���
�
r�cCs~|durtjj��stjj��}tjj��r%d}dt�d|�d|�d�}nd}td||g}td|d|d	|d
�}d}t||�S)z�
    Changes a user's password.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.change_password rabbit_user password
    NTryz" change_password "rzF�change_passwordrSr|�rWrXr}rYzPassword Changed)	rrrr	rarbrr0r,)rr�rXrYr�rcr+rrrr��s 
�
r�cC�H|durtjj��stjj��}tdtd|gd|dd�}d}t||�S)z�
    Removes a user's password.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.clear_password rabbit_user
    NrSr�FrVzPassword Clearedr�r�rrrr��r�r�cCs�|durtjj��stjj��}z<tdtdgd|dd�}t�	d|�}t�	d|�}|dur3|dur3t
�|r7|}|�d��d	�d
}dd�|�d
�D�}Wnt
yWd}Ynwt
|�dkr`d}t|�dkr�tjj��r{d}dt�d|�d|�d�}nd}td||g}td|d|d|d�}|dd
ks�|dr�dSdSd�|�dd�|�dd��}tdtd|gd|ddd�}d}	t||	�}
tt|
��}d|
|vr�dSdS) z�
    .. versionadded:: 2016.3.0

    Checks if a user's password is valid.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.check_password rabbit_user password
    Nzcmd.run�statusFrVz\{rabbit,"RabbitMQ","(.+)"\}zRabbitMQ version:\s*(.+)rBr/rcSsg|]}t|��qSr)�int)r;�irrrr<
r]z"check_password.<locals>.<listcomp>�.)rrr�)r���Tryz" authenticate_user "rzZauthenticate_userrSr|r�rr zRrabbit_auth_backend_internal:check_user_login(<<"{}">>, [{{password, <<"{}">>}}]).z\"�evalzpassword-checkzinvalid credentials)rrrr	rarbr0r�re�searchrD�groupr1r7�tupler'�replacer,�next�iter)rr�rXrcZold_server_versionZserver_versionr2rYr�r+Z	_responseZ_keyrrr�check_password�sp������
r�cCr�)z�
    Adds a vhost via rabbitmqctl add_vhost.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq add_vhost '<vhost_name>'
    NrS�	add_vhostFrVr~r���vhostrXrcr+rrrr�Hs
�
r�cCr�)z�
    Deletes a vhost rabbitmqctl delete_vhost.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.delete_vhost '<vhost_name>'
    NrS�delete_vhostFrVr�r�r�rrrr�_s
�
r��.*c	CsR|durtjj��stjj��}tdtdd|||||gd|dd�}d}t||�S)z�
    Sets permissions for vhost via rabbitmqctl set_permissions

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.set_permissions myvhost myuser
    NrS�set_permissions�-pFrVzPermissions Setr�)r�raZconf�write�readrXrcr+rrrr�us
�
r�cCs||durtjj��stjj��}tdtddd|gd|dd�}tjj�	|d�}i}|D]}|d	}|||<||d	=q,|S)
z�
    Lists permissions for vhost via rabbitmqctl list_permissions

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.list_permissions /myvhost
    NrS�list_permissions�--formatter=jsonr�FrVr*ra�
rrrr	rarbr0r�json�loads)r�rXrc�perms�
perms_dict�permrarrrr��s
�r�cCsz|durtjj��stjj��}tdtd|dgd|dd�}tjj�	|d�}i}|D]}|d}|||<||d=q+|S)	z�
    List permissions for a user via rabbitmqctl list_user_permissions

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.list_user_permissions user
    NrS�list_user_permissionsr�FrVr*r�r�)rrXrcr�r�r�r�rrrr��s

�r�cCsd|durtjj��stjj��}t|ttf�s|g}t	dt
d|gt|�d|dd�}d}t||�S)z�Add user tags via rabbitmqctl set_user_tags

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.set_user_tags myadmin administrator
    NrS�
set_user_tagsFrVz
Tag(s) set)rrrr	rarbr%�listr�r0rr,)r�tagsrXrcr+rrrr��s	�
r�cC�H|durtjj��stjj��}tdtdgd|dd�}t|�|dS)zn
    return rabbitmq status

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.status
    NrSr�FrVr*�	rrrr	rarbr0rr)rerrrr���
�r�cCr�)z~
    return rabbitmq cluster_status

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.cluster_status
    NrS�cluster_statusFrVr*r�rerrrr��r�r��rabbitcCsxtdg}|r|�d�|�|�d|���|dur%tjj��s%tjj��}t|�t	d|d|dd�}t
|�t|d�S)	z�
    Join a rabbit cluster

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.join_cluster rabbit.example.com rabbit
    �join_clusterz--ram�@NrSFrVZJoin)r�appendrrrr	rarb�stop_appr0�	start_appr,)�hostraZram_noderXr�rcrrrr�s

�
r�cCr�)z�
    Stops the RabbitMQ application, leaving the Erlang node running.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.stop_app
    NrSr�FrVr*r�rerrrr�"r�r�cCr�)zz
    Start the RabbitMQ application.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.start_app
    NrSr�FrVr*r�rerrrr�8r�r�cCr�)z�
    Return a RabbitMQ node to its virgin state

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.reset
    NrS�resetFrVr*r�rerrrr�Nr�r�cCr�)z�
    Forcefully Return a RabbitMQ node to its virgin state

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.force_reset
    NrS�force_resetFrVr*r�rerrrr�dr�r�cGs\|durtjj��stjj��}tddg}|�|�td|d|dd�}t	|�t
|d�S)z�
    Returns queue details of the / virtual host

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.list_queues messages consumers
    N�list_queuesrUrSFrVr*�rrrr	rarbr�extendr0r)rK)rX�argsr�rcrrrr�zs


�r�cGs`|durtjj��stjj��}tddd|g}|�|�td|d|dd�}t	|�t
|d�S)	a}
    Returns queue details of specified virtual host. This command will consider
    first parameter as the vhost name and rest will be treated as
    queueinfoitem. For getting details on vhost ``/``, use :mod:`list_queues
    <salt.modules.rabbitmq.list_queues>` instead).

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.list_queues messages consumers
    Nr�rUr�rSFrVr*r�)r�rXr�r�rcrrr�list_queues_vhost�s

�r��/c
Cs�i}|durtjj��stjj��}tdtddd|gd|dd�}t|�|d}t	d	d
kr;tdd��
d
�d}ntdd��
d
�d}t|�D]�}|�
d�}t|�dvrXqJ|d|d}}||vrii||<i|||<t
|�t
d�kr�|d|||d<|d|||d<|d|||d<|d|||d<qJt|�d}	t|�dkr�|d|||d<|||�||	d||	d||	dd��qJ|S)a
    Return a dictionary of policies nested by vhost and name
    based on the data returned from rabbitmqctl list_policies.

    Reference: http://www.rabbitmq.com/ha.html

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.list_policies
    NrS�
list_policiesrUr�FrVr*Z	os_familyZFreeBSDr-r.r/rZrabbitmqr4)r��rBz3.7��patternr��apply_to�rhr��priorityr�)r�rhr�)rrrr	rarbr0rr)Z
__grains__r1rRr7r�update)
r�rXrHrc�outputr2r8�partsr�offsetrrrr��sJ
�



��r�c	Cs�|durtjj��stjj��}t|t�rtjj�	|�}t|t
�s%td��tdd|g}|r4|�
d|g�|r=|�
d|g�|�
|||g�td|d|dd	�}t�d
|d�t|d�S)
z�
    Set a policy based on rabbitmqctl set_policy.

    Reference: http://www.rabbitmq.com/ha.html

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.set_policy / HA '.*' '{"ha-mode":"all"}'
    Nz=The 'definition' argument must be a dictionary or JSON string�
set_policyr�z
--priorityz
--apply-torSFrVzSet policy: %sr*�Set)rrrr	rarbr%r&r��dumps�strrrr�r0rErFr,)	r�rr�rhr�rXr�r�rcrrrr��s&

��
r�cCsX|durtjj��stjj��}tdtdd||gd|dd�}t�	d|d�t
|d	�S)
z�
    Delete a policy based on rabbitmqctl clear_policy.

    Reference: http://www.rabbitmq.com/ha.html

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.delete_policy / HA
    NrSZclear_policyr�FrVzDelete policy: %sr*r�)rrrr	rarbr0rrErFr,)r�rrXrcrrr�
delete_policy
s�
r�cCsB|durtjj��stjj��}t|d�}t||vo|||v�S)z�
    Return whether the policy exists based on rabbitmqctl list_policies.

    Reference: http://www.rabbitmq.com/ha.html

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.policy_exists / HA
    Nrk)rrrr	rarbr��bool)r�rrXZpoliciesrrr�
policy_exists%s
r�cCsT|durtjj��stjj��}t�ddg}td|d|dd�}t|�t	|d�S)z�
    Returns a list of the names of all available plugins (enabled and disabled).

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.list_available_plugins
    Nr��-mrSFrVr*�
rrrr	rarbr3r0r)rP�rXr�rHrrr�list_available_plugins7s
�r�cCsV|durtjj��stjj��}t�dddg}td|d|dd�}t|�t	|d�S)	z�
    Returns a list of the names of the enabled plugins.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.list_enabled_plugins
    Nr�r�z-erSFrVr*r�r�rrr�list_enabled_pluginsKs
�r�cCs,|durtjj��stjj��}|t|�vS)z�
    Return whether the plugin is enabled.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.plugin_is_enabled rabbitmq_plugin_name
    N)rrrr	rarbr�rlrrr�plugin_is_enabled_s
r�cC�J|durtjj��stjj��}t�d|g}td|d|dd�}t|d�S)z�
    Enable a RabbitMQ plugin via the rabbitmq-plugins command.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.enable_plugin foo
    N�enablerSFrVZEnabled�	rrrr	rarbr3r0r,�rrXr�rHrrr�
enable_pluginn�
�
r�cCr�)z�
    Disable a RabbitMQ plugin via the rabbitmq-plugins command.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.disable_plugin foo
    N�disablerSFrVZDisabledr�r�rrr�disable_plugin�r�r�c
Csz|durtjj��stjj��}tjj�|||||||||	|
|d��}
tdt	dd|tjj
�|
�gd|dd�}t|�dS)	a
    Configures an upstream via rabbitmqctl set_parameter. This can be an exchange-upstream,
    a queue-upstream or both.

    :param str name: The name of the upstream to configure.

    The following parameters apply to federated exchanges and federated queues:

    :param str uri: The AMQP URI(s) for the upstream.
    :param int prefetch_count: The maximum number of unacknowledged messages copied
        over a link at any one time. Default: 1000
    :param int reconnect_delay: The duration (in seconds) to wait before reconnecting
        to the broker after being disconnected. Default: 1
    :param str ack_mode: Determines how the link should acknowledge messages.
        If set to ``on-confirm`` (the default), messages are acknowledged to the
        upstream broker after they have been confirmed downstream. This handles
        network errors and broker failures without losing messages, and is the
        slowest option.
        If set to ``on-publish``, messages are acknowledged to the upstream broker
        after they have been published downstream. This handles network errors
        without losing messages, but may lose messages in the event of broker failures.
        If set to ``no-ack``, message acknowledgements are not used. This is the
        fastest option, but may lose messages in the event of network or broker failures.
    :param bool trust_user_id: Determines how federation should interact with the
        validated user-id feature. If set to true, federation will pass through
        any validated user-id from the upstream, even though it cannot validate
        it itself. If set to false or not set, it will clear any validated user-id
        it encounters. You should only set this to true if you trust the upstream
        server (and by extension, all its upstreams) not to forge user-ids.

    The following parameters apply to federated exchanges only:

    :param str exchange: The name of the upstream exchange. Default is to use the
        same name as the federated exchange.
    :param int max_hops: The maximum number of federation links that a message
        published to a federated exchange can traverse before it is discarded.
        Default is 1. Note that even if max-hops is set to a value greater than 1,
        messages will never visit the same node twice due to travelling in a loop.
        However, messages may still be duplicated if it is possible for them to
        travel from the source to the destination via multiple routes.
    :param int expires: The expiry time (in milliseconds) after which an upstream
        queue for a federated exchange may be deleted, if a connection to the upstream
        broker is lost. The default is 'none', meaning the queue should never expire.
        This setting controls how long the upstream queue will last before it is
        eligible for deletion if the connection is lost.
        This value is used to set the "x-expires" argument for the upstream queue.
    :param int message_ttl: The expiry time for messages in the upstream queue
        for a federated exchange (see expires), in milliseconds. Default is ``None``,
        meaning messages should never expire. This does not apply to federated queues.
        This value is used to set the "x-message-ttl" argument for the upstream queue.
    :param str ha_policy: Determines the "x-ha-policy" argument for the upstream
        queue for a federated exchange (see expires). This is only of interest
        when connecting to old brokers which determine queue HA mode using this
        argument. Default is ``None``, meaning the queue is not HA.

    The following parameter applies to federated queues only:

    :param str queue: The name of the upstream queue. Default is to use the same
        name as the federated queue.

    :param str runas: The name of the user to run the command as.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.set_upstream upstream_name ack_mode=on-confirm max_hops=1             trust_user_id=True uri=amqp://hostname

    .. versionadded:: 3000
    N)�urizprefetch-countzreconnect-delayzack-modez
trust-user-id�exchangezmax-hops�expireszmessage-ttlz	ha-policy�queuerSZ
set_parameter�federation-upstreamFrVT)
rrrr	rarb�dataZ
filter_falseyr0rr�r�r))rr�Zprefetch_countZreconnect_delayZack_modeZ
trust_user_idr�Zmax_hopsr�Zmessage_ttlZ	ha_policyr�rX�paramsrcrrr�set_upstream�s:V����r�cCsH|durtjj��stjj��}tdtdd|gd|dd�}t|�dS)a;
    Deletes an upstream via rabbitmqctl clear_parameter.

    :param str name: The name of the upstream to delete.
    :param str runas: The name of the user to run the command as.

    CLI Example:

    .. code-block:: bash

        salt '*' rabbitmq.delete_upstream upstream_name

    .. versionadded:: 3000
    NrSZclear_parameterr�FrVTr�)rrXrcrrr�delete_upstreams
�r�rq)NN)r�r�r�N)r�NN)r�N)NNN)NNNNNNNNNNN)D�__doc__�loggingrrrr�r@Zsalt.utils.itertoolsrZsalt.utils.jsonZsalt.utils.pathZsalt.utils.platformZsalt.utils.userZsalt.exceptionsrrZsalt.utils.versionsr�	getLogger�__name__rErrrr)r,r3r9r=rKrPrRrTrdrirmrorpr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�<module>s�
4

+
	






:

$

^














D
�
#






�w