示例#1
0
def wait_for_cosmos():
    """ Waits for the Cosmos API to become responsive. """
    cosmos_pm = packagemanager.PackageManager(cosmos.get_cosmos_url())
    try:
        cosmos_pm.has_capability('METRONOME')
    except Exception as e:
        assert False, f"Expecting Metronome service to be up but it did not get healthy after 5 minutes. Last exception: {e}"  # noqa
示例#2
0
def _get_package_manager():
    """ Get an instance of Cosmos with the correct URL.

        # :return: Cosmos instance
        :rtype: packagemanager.P:return: Cosmos instanceackageManager
    """
    return packagemanager.PackageManager(cosmos.get_cosmos_url())
示例#3
0
文件: log.py 项目: insighty/dcos-cli
def has_journald_capability():
    """ functions checks LOGGING capability.

    :return: does cosmos have LOGGING capability.
    :rtype: bool
    """
    return packagemanager.PackageManager(
        get_cosmos_url()).has_capability('LOGGING')
示例#4
0
def dcos_log_enabled():
    """ functions checks the cosmos capability LOGGING
        to know if `dcos-log` is enabled on the cluster.

    :return: does cosmos have LOGGING capability.
    :rtype: bool
    """
    return packagemanager.PackageManager(
        get_cosmos_url()).has_capability('LOGGING')
def test_custom_service_name():
    """  Install MoM with a custom service name.
    """
    cosmos_pm = packagemanager.PackageManager(cosmos.get_cosmos_url())
    pkg = cosmos_pm.get_package_version('marathon', None)
    options = {'service': {'name': "test-marathon"}}
    shakedown.install_package('marathon', options_json=options)
    shakedown.deployment_wait()

    assert shakedown.wait_for_service_endpoint('test-marathon')
示例#6
0
文件: log.py 项目: insighty/dcos-cli
def has_log_v2_capability():
    """ function checks the cosmos capability LOGGING_V2
        to know if `dcos-log` suppports v2 on the cluster.

        :return: cosmos has LOGGING_V2 capability.
        :rtype: bool
    """

    return packagemanager.PackageManager(
        get_cosmos_url()).has_capability('LOGGING_V2')
示例#7
0
def _check_capability():
    """
    The function checks if cluster has metronome capability.

    :raises: DCOSException if cluster does not have metronome capability
    """

    cosmos = packagemanager.PackageManager(get_cosmos_url())
    if not cosmos.has_capability('METRONOME'):
        raise DCOSException(
            'DC/OS backend does not support metronome capabilities in this '
            'version. Must be DC/OS >= 1.8')
def uninstall(service, package=PACKAGE_NAME):
    try:
        task = get_service_task(package, service)
        if task is not None:
            cosmos = packagemanager.PackageManager(get_cosmos_url())
            cosmos.uninstall_app(package, True, service)
            deployment_wait()
            assert wait_for_service_endpoint_removal('test-marathon')
            delete_zk_node('/universe/{}'.format(service))

    except Exception as e:
        pass
示例#9
0
文件: main.py 项目: arun-rai/dcos-cli
def _check_3dt_version():
    """
    The function checks if cluster has diagnostics capability.

    :raises: DCOSException if cluster does not have diagnostics capability
    """

    cosmos = packagemanager.PackageManager(get_cosmos_url())
    if not cosmos.has_capability('SUPPORT_CLUSTER_REPORT'):
        raise DCOSException(
            'DC/OS backend does not support diagnostics capabilities in this '
            'version. Must be DC/OS >= 1.8')
def test_custom_service_name():
    """  Install MoM with a custom service name.
    """
    cosmos_pm = packagemanager.PackageManager(cosmos.get_cosmos_url())
    cosmos_pm.get_package_version('marathon', None)
    options = {'service': {'name': "test-marathon"}}
    shakedown.install_package('marathon', options_json=options)
    common.deployment_wait(service_id=options["service"]["name"],
                           max_attempts=300)

    common.wait_for_service_endpoint('test-marathon',
                                     timeout_sec=300,
                                     path="ping")
示例#11
0
def get_package_manager():
    """Returns type of package manager to use

    :returns: PackageManager instance
    :rtype: packagemanager.PackageManager
    """
    cosmos_url = cosmos.get_cosmos_url()
    cosmos_manager = packagemanager.PackageManager(cosmos_url)
    if cosmos_manager.enabled():
        return cosmos_manager
    else:
        msg = ("This version of the DC/OS CLI is not supported for your "
               "cluster. Please downgrade the CLI to an older version: "
               "https://dcos.io/docs/usage/cli/update/#downgrade")
        raise DCOSException(msg)
示例#12
0
def logging_strategy():
    """ function returns logging strategy

    :return: does cosmos have LOGGING capability.
    :rtype: str
    """
    # default strategy is sandbox logging.
    strategy = 'logrotate'

    has_capability = packagemanager.PackageManager(
        get_cosmos_url()).has_capability('LOGGING')

    if not has_capability:
        return strategy

    base_url = config.get_config_val("core.dcos_url")
    url = urllib.parse.urljoin(base_url, '/dcos-metadata/ui-config.json')

    if not base_url:
        raise config.missing_config_exception(['core.dcos_url'])

    try:
        response = http.get(url).json()
    except (DCOSAuthenticationException, DCOSAuthorizationException):
        raise
    except DCOSException:
        emitter.publish('Unable to determine logging mechanism for '
                        'your cluster. Defaulting to files API.')
        return strategy

    try:
        strategy = response['uiConfiguration']['plugins']['mesos'][
            'logging-strategy']  # noqa: ignore=F403,E501
    except KeyError:
        pass

    return strategy
示例#13
0
def pkg_mgr():
    return packagemanager.PackageManager('http://testserver/cosmos')