PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/proxy/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : //proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/proxy/marathon.py

"""
Marathon
========

Proxy minion for managing a Marathon cluster.

Dependencies
------------

- :mod:`marathon execution module (salt.modules.marathon) <salt.modules.marathon>`

Pillar
------

The marathon proxy configuration requires a 'base_url' property that points to
the marathon endpoint:

.. code-block:: yaml

    proxy:
      proxytype: marathon
      base_url: http://my-marathon-master.mydomain.com:8080

.. versionadded:: 2015.8.2
"""

import logging

import salt.utils.http

__proxyenabled__ = ["marathon"]
CONFIG = {}
CONFIG_BASE_URL = "base_url"
log = logging.getLogger(__file__)


def __virtual__():
    return True


def init(opts):
    """
    Perform any needed setup.
    """
    if CONFIG_BASE_URL in opts["proxy"]:
        CONFIG[CONFIG_BASE_URL] = opts["proxy"][CONFIG_BASE_URL]
    else:
        log.error("missing proxy property %s", CONFIG_BASE_URL)
    log.debug("CONFIG: %s", CONFIG)


def ping():
    """
    Is the marathon api responding?
    """
    try:
        response = salt.utils.http.query(
            f"{CONFIG[CONFIG_BASE_URL]}/ping",
            decode_type="plain",
            decode=True,
        )
        log.debug(
            "marathon.info returned successfully: %s",
            response,
        )
        if "text" in response and response["text"].strip() == "pong":
            return True
    except Exception as ex:  # pylint: disable=broad-except
        log.error(
            "error calling marathon.info with base_url %s: %s",
            CONFIG[CONFIG_BASE_URL],
            ex,
        )
    return False


def shutdown(opts):
    """
    For this proxy shutdown is a no-op
    """
    log.debug("marathon proxy shutdown() called...")