コード例 #1
0
def _list(json_, app_id, cli_only, package_name):
    """List installed apps

    :param json_: output json if True
    :type json_: bool
    :param app_id: App ID of app to show
    :type app_id: str
    :param cli_only: if True, only show packages with installed subcommands
    :type cli_only: bool
    :param package_name: The package to show
    :type package_name: str
    :returns: process return code
    :rtype: int
    """

    package_manager = get_package_manager()
    if app_id is not None:
        app_id = util.normalize_marathon_id_path(app_id)
    results = package.installed_packages(package_manager, app_id, package_name,
                                         cli_only)

    # only emit those packages that match the provided package_name and app_id
    if results or json_:
        emitting.publish_table(emitter, results, tables.package_table, json_)
    else:
        msg = ("There are currently no installed packages. "
               "Please use `dcos package install` to install a package.")
        raise DCOSException(msg)
    return 0
コード例 #2
0
ファイル: main.py プロジェクト: SStar1314/dcos-cli
def _list(json_, app_id, package_name):
    """List installed apps

    :param json_: output json if True
    :type json_: bool
    :param app_id: App ID of app to show
    :type app_id: str
    :param package_name: The package to show
    :type package_name: str
    :returns: process return code
    :rtype: int
    """

    package_manager = _get_package_manager()
    if app_id is not None:
        app_id = util.normalize_app_id(app_id)
    results = package.installed_packages(
        package_manager, app_id, package_name)

    # only emit those packages that match the provided package_name and app_id
    if results or json_:
        emitting.publish_table(emitter, results, tables.package_table, json_)
    else:
        msg = ("There are currently no installed packages. "
               "Please use `dcos package install` to install a package.")
        raise DCOSException(msg)
    return 0
コード例 #3
0
ファイル: main.py プロジェクト: BIGpoppastg/dcos-cli
def _list(json_, endpoints, app_id, package_name):
    """List installed apps

    :param json_: output json if True
    :type json_: bool
    :param endpoints: Whether to include a list of
        endpoints as port-host pairs
    :type endpoints: boolean
    :param app_id: App ID of app to show
    :type app_id: str
    :param package_name: The package to show
    :type package_name: str
    :returns: process return code
    :rtype: int
    """

    config = util.get_config()
    init_client = marathon.create_client(config)
    installed = package.installed_packages(init_client, endpoints)

    # only emit those packages that match the provided package_name and app_id
    results = []
    for pkg in installed:
        pkg_info = pkg.dict()
        if (_matches_package_name(package_name, pkg_info) and
                _matches_app_id(app_id, pkg_info)):
            if app_id:
                # if the user is asking a specific id then only show that id
                pkg_info['apps'] = [
                    app for app in pkg_info['apps']
                    if app == app_id
                ]

            results.append(pkg_info)

    if results or json_:
        emitting.publish_table(emitter, results, tables.package_table, json_)
    else:
        msg = ("There are currently no installed packages. "
               "Please use `dcos package install` to install a package.")
        raise DCOSException(msg)
    return 0
コード例 #4
0
ファイル: main.py プロジェクト: sggraham32/dcos-cli
def _list(json_, endpoints, app_id, package_name):
    """List installed apps

    :param json_: output json if True
    :type json_: bool
    :param endpoints: Whether to include a list of
        endpoints as port-host pairs
    :type endpoints: boolean
    :param app_id: App ID of app to show
    :type app_id: str
    :param package_name: The package to show
    :type package_name: str
    :returns: process return code
    :rtype: int
    """

    config = util.get_config()
    init_client = marathon.create_client(config)
    installed = package.installed_packages(init_client, endpoints)

    # only emit those packages that match the provided package_name and app_id
    results = []
    for pkg in installed:
        pkg_info = pkg.dict()
        if (_matches_package_name(package_name, pkg_info)
                and _matches_app_id(app_id, pkg_info)):
            if app_id:
                # if the user is asking a specific id then only show that id
                pkg_info['apps'] = [
                    app for app in pkg_info['apps'] if app == app_id
                ]

            results.append(pkg_info)

    if results or json_:
        emitting.publish_table(emitter, results, tables.package_table, json_)
    else:
        msg = ("There are currently no installed packages. "
               "Please use `dcos package install` to install a package.")
        raise DCOSException(msg)
    return 0
コード例 #5
0
ファイル: main.py プロジェクト: kvish/dcos-core-cli
def _uninstall(package_name, remove_all, app_id, cli, app, skip_confirmation, manager_id):
    """Uninstall the specified package.

    :param package_name: The package to uninstall
    :type package_name: str
    :param remove_all: Whether to remove all instances of the named package
    :type remove_all: boolean
    :param app_id: App ID of the package instance to uninstall
    :type app_id: str
    :param skip_confirmation: Skip confirmation for uninstall
    :type skip_confirmation: boolean
    :returns: Process status
    :rtype: int
    :param manager_id: defines the custom manager to forward this operation to
    :manager_id: str

    """

    package_manager = get_package_manager()

    # Don't gate CLI uninstalls.
    # Don't gate uninstalls if the user wants to skip confirmation.
    if not cli and not skip_confirmation:
        installed = package.installed_packages(
            package_manager, None, package_name, cli_only=False)
        installed_pkg = next(iter(installed), None)
        if not installed_pkg or not installed_pkg.get('name'):
            msg = "Package '{}' is not installed.".format(package_name)
            emitter.publish(msg)
            return 1

        if not _confirm_uninstall(installed_pkg, remove_all, app_id):
            return 0

    package.uninstall(
        package_manager, package_name, remove_all, app_id, cli, app, manager_id)

    return 0