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/modules/__pycache__/marathon.cpython-310.pyc
o

�N�g1�@s�dZddlZddlZddlZddlZddlmZdgZe�	e
�Zdd�Zdd�Z
d	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zddd�ZdS)z�
Module providing a simple management interface to a marathon cluster.

Currently this only works when run through a proxy minion.

.. versionadded:: 2015.8.2
�N)�get_error_messageZmarathoncCstjj��rdtvrdSdS)N�proxyT)FzQThe marathon execution module cannot be loaded: this only works on proxy minions.)�salt�utils�platformZis_proxy�__opts__�rr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/marathon.py�__virtual__sr
cCs d}dtvrtd�d|�}|S)z/
    Return the proxy configured base url.
    zhttp://locahost:8080r�base_url)r�get)rrrr	�	_base_urlsr
cCs|ddkrd|��}|S)z8
    Make sure the app_id is in the correct format.
    r�/r)Zapp_idrrr	�_app_id)s
rcCs6tjjjt��d�ddd�}ddd�|ddD�iS)	z�
    Return a list of the currently installed app ids.

    CLI Example:

    .. code-block:: bash

        salt marathon-minion-id marathon.apps
    z/v2/apps�jsonT��decode_type�decode�appscSsg|]}|d�qS��idr)�.0�apprrr	�
<listcomp>Aszapps.<locals>.<listcomp>�dict�rr�http�queryr
��responserrr	r2s

�rcCst|�t�dvS)z�
    Return whether the given app id is currently configured.

    CLI Example:

    .. code-block:: bash

        salt marathon-minion-id marathon.has_app my-app
    r)rrrrrr	�has_appDs
r cCs(tjjjt��d|��ddd�}|dS)z�
    Return the current server configuration for the specified app.

    CLI Example:

    .. code-block:: bash

        salt marathon-minion-id marathon.app my-app
    �	/v2/apps/rTrrr�rrrrr	rQs
�rc
Cs�d|vr||d<|�dd�|�dd�tjj�|�}z"tjjjt��d|�d�ddd	|d
d
d�d�}t�	d
|�|dWSt
y_}zt�dt|��ddt|�iiWYd}~Sd}~ww)z�
    Update the specified app with the given configuration.

    CLI Example:

    .. code-block:: bash

        salt marathon-minion-id marathon.update_app my-app '<config yaml>'
    r�versionNZfetchr!z?force=true�PUTrT�application/json�zContent-TypeZAccept)�methodrr�data�header_dictzupdate response: %srz!unable to update marathon app: %s�	exception�message)
�poprrr�dumpsrrr
�log�debug�	Exception�errorr)rZconfigr(r�exrrr	�
update_appcs.
��
��r3cCs*tjjjt��d|��dddd�}|dS)z�
    Remove the specified app from the server.

    CLI Example:

    .. code-block:: bash

        salt marathon-minion-id marathon.rm_app my-app
    r!ZDELETErT)r'rrrrr"rrr	�rm_app�s
�r4cCs$tjjjt��d�ddd�}|dS)z�
    Return configuration and status information about the marathon instance.

    CLI Example:

    .. code-block:: bash

        salt marathon-minion-id marathon.info
    z/v2/inforTrrrrrrr	�info�s

�r5FTc
Cs�ddi}|sd|d<|Sz.tjjjt��dt|��d|��dddd	d	d
�d�}t�d|�d|d<|�|d
�|WSt	yZ}zt�
d|j�dd|jiiWYd}~Sd}~ww)a�
    Restart the current server configuration for the specified app.

    :param restart: Restart the app
    :param force: Override the current deployment

    CLI Example:

    .. code-block:: bash

        salt marathon-minion-id marathon.restart_app my-app

    By default, this will only check if the app exists in marathon. It does
    not check if there are any tasks associated with it or if the app is suspended.

    .. code-block:: bash

        salt marathon-minion-id marathon.restart_app my-app true true

    The restart option needs to be set to True to actually issue a rolling
    restart to marathon.

    The force option tells marathon to ignore the current app deployment if
    there is one.
    Z	restartedNFr!z/restart?force=�POSTrTr%r&)r'rrr)zrestart response: %srz"unable to restart marathon app: %sr*r+)rrrrr
rr.r/�updater0r1r+)rZrestart�force�retrr2rrr	�restart_app�s.��
��r:)FT)�__doc__�loggingZsalt.utils.httprZsalt.utils.jsonZsalt.utils.platformZsalt.exceptionsrZ__proxyenabled__�	getLogger�__file__r.r
r
rrr rr3r4r5r:rrrr	�<module>s$

	
$