コード例 #1
0
def _queue(job_id, json_flag=False, quiet=False):
    """
    :param job_id: Id of the job
    :type job_id: str
    :param json_flag: Output json if True
    :type json_flag: bool
    :param quiet: Output only job run ids if true
    :type quiet: bool
    :returns: process return code
    :rtype: int
    """

    client = metronome.create_client()
    deployment_list = client.get_queued_job_runs(job_id)

    if not deployment_list and not json_flag:
        if job_id:
            msg = "There are no deployments in the queue for "
            msg += "'{}'".format(job_id)
            emitter.publish(msg)
        return 0

    if quiet:
        for deployment in deployment_list:
            for runs in deployment.get("runs"):
                emitter.publish(runs.get("runId"))
    else:
        emitting.publish_table(emitter,
                               deployment_list,
                               tables.job_queue_table,
                               json_flag)
    return 0
コード例 #2
0
ファイル: main.py プロジェクト: timcharper/dcos-cli
def _search(json_, query):
    """Search for matching packages.

    :param json_: output json if True
    :type json_: bool
    :param query: The search term
    :type query: str
    :returns: Process status
    :rtype: int
    """

    if not query:
        query = ''

    package_manager = get_package_manager()
    results = package_manager.search_sources(query)

    if json_ or results['packages']:
        emitting.publish_table(emitter,
                               results,
                               tables.package_search_table,
                               json_)
    else:
        raise DCOSException('No packages found.')
    return 0
コード例 #3
0
ファイル: main.py プロジェクト: BIGpoppastg/dcos-cli
def _search(json_, query):
    """Search for matching packages.

    :param json_: output json if True
    :type json_: bool
    :param query: The search term
    :type query: str
    :returns: Process status
    :rtype: int
    """
    if not query:
        query = ''

    config = util.get_config()
    results = [index_entry.as_dict()
               for index_entry in package.search(query, config)]

    if any(result['packages'] for result in results) or json_:
        emitting.publish_table(emitter,
                               results,
                               tables.package_search_table,
                               json_)
    else:
        raise DCOSException('No packages found.')
    return 0
コード例 #4
0
ファイル: main.py プロジェクト: surdy/dcos-cli
    def debug_summary(self, app_id, json_):
        """
        :param app_id: the Marathon ID to display details
        :type app_id: string
        :param json_: output json if True
        :type json_: bool
        :returns: process return code
        :rtype: int
        """

        client = self._create_marathon_client()
        queued_app = client.get_queued_app(app_id)

        if queued_app:
            if queued_app.get('processedOffersSummary'):
                emitting.publish_table(
                    emitter, queued_app,
                    tables.queued_app_table, json_)
            else:
                msg = "This command is not supported on your cluster"
                raise DCOSException(msg)
        else:
            raise DCOSException("No apps found in Marathon queue")

        return 0
コード例 #5
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
コード例 #6
0
ファイル: main.py プロジェクト: SStar1314/dcos-cli
def _search(json_, query):
    """Search for matching packages.

    :param json_: output json if True
    :type json_: bool
    :param query: The search term
    :type query: str
    :returns: Process status
    :rtype: int
    """

    if not query:
        query = ''

    package_manager = _get_package_manager()
    results = package_manager.search_sources(query)

    if json_ or results['packages']:
        emitting.publish_table(emitter,
                               results,
                               tables.package_search_table,
                               json_)
    else:
        raise DCOSException('No packages found.')
    return 0
コード例 #7
0
ファイル: main.py プロジェクト: jeffwhite530/dcos-core-cli
    def deployment_list(self, app_id, json_, quiet_=False):
        """
        :param app_id: the application id
        :type app_id: str
        :param json_: output json if True
        :type json_: bool
        :returns: process return code
        :rtype: int
        """

        client = self._create_marathon_client()

        deployments = client.get_deployments(app_id)

        if not deployments and not json_:
            msg = "There are no deployments"
            if app_id:
                msg += " for '{}'".format(app_id)
            raise DCOSException(msg)

        if quiet_:
            for deployment in deployments:
                emitter.publish(deployment.get('id'))
        else:
            emitting.publish_table(emitter, deployments,
                                   tables.deployment_table, json_)
        return 0
コード例 #8
0
def _deployment_list(app_id, json_):
    """
    :param app_id: the application id
    :type app_id: str
    :param json_: output json if True
    :type json_: bool
    :returns: process return code
    :rtype: int
    """

    client = marathon.create_client()

    deployments = client.get_deployments(app_id)

    if not deployments and not json_:
        msg = "There are no deployments"
        if app_id:
            msg += " for '{}'".format(app_id)
        raise DCOSException(msg)

    emitting.publish_table(emitter,
                           deployments,
                           tables.deployment_table,
                           json_)
    return 0
コード例 #9
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
コード例 #10
0
    def debug_summary(self, app_id, json_):
        """
        :param app_id: the Marathon ID to display details
        :type app_id: string
        :param json_: output json if True
        :type json_: bool
        :returns: process return code
        :rtype: int
        """

        client = self._create_marathon_client()
        queued_app = client.get_queued_app(app_id)

        if queued_app:
            if queued_app.get('processedOffersSummary'):
                emitting.publish_table(
                    emitter, queued_app,
                    tables.queued_app_table, json_)
            else:
                msg = "This command is not supported on your cluster"
                raise DCOSException(msg)
        else:
            raise DCOSException("No apps found in Marathon queue")

        return 0
コード例 #11
0
def _list_providers(json_):
    """
    :returns: providers available for configured cluster
    :rtype: dict
    """

    providers = auth.get_providers()
    if providers or json_:
        emitting.publish_table(emitter, providers, tables.auth_provider_table,
                               json_)
    else:
        raise DCOSException("No providers configured for your cluster")
コード例 #12
0
def _group_list(json_):
    """
    :param json_: output json if True
    :type json_: bool
    :rtype: int
    :returns: process return code
    """

    client = marathon.create_client()
    groups = client.get_groups()

    emitting.publish_table(emitter, groups, tables.group_table, json_)
    return 0
コード例 #13
0
ファイル: main.py プロジェクト: jeffwhite530/dcos-core-cli
    def debug_list(self, json_):
        """
        :param json_: output json if True
        :type json_: bool
        :returns: process return code
        :rtype: int
        """

        client = self._create_marathon_client()
        queued_apps = client.get_queued_apps()

        emitting.publish_table(emitter, queued_apps, tables.queued_apps_table,
                               json_)
        return 0
コード例 #14
0
    def pod_list(self, json_):
        """
        :param json_: output JSON if true
        :type json_: bool
        :returns: process return code
        :rtype: int
        """

        marathon_client = self._create_marathon_client()
        self._ensure_pods_support(marathon_client)

        pods = marathon_client.list_pod()
        emitting.publish_table(emitter, pods, tables.pod_table, json_)
        return 0
コード例 #15
0
ファイル: main.py プロジェクト: surdy/dcos-cli
    def debug_list(self, json_):
        """
        :param json_: output json if True
        :type json_: bool
        :returns: process return code
        :rtype: int
        """

        client = self._create_marathon_client()
        queued_apps = client.get_queued_apps()

        emitting.publish_table(emitter, queued_apps,
                               tables.queued_apps_table, json_)
        return 0
コード例 #16
0
def _task_list(app_id, json_):
    """
    :param app_id: the id of the application
    :type app_id: str
    :param json_: output json if True
    :type json_: bool
    :returns: process return code
    :rtype: int
    """

    client = marathon.create_client()
    tasks = client.get_tasks(app_id)

    emitting.publish_table(emitter, tasks, tables.app_task_table, json_)
    return 0
コード例 #17
0
ファイル: main.py プロジェクト: surdy/dcos-cli
    def pod_list(self, json_):
        """
        :param json_: output JSON if true
        :type json_: bool
        :returns: process return code
        :rtype: int
        """

        marathon_client = self._create_marathon_client()
        self._ensure_pods_support(marathon_client)

        pods = marathon_client.list_pod()
        queued_apps = marathon_client.get_queued_apps()
        _enhance_row_with_overdue_information(pods, queued_apps)
        emitting.publish_table(emitter, pods, tables.pod_table, json_)
        return 0
コード例 #18
0
    def pod_list(self, json_):
        """
        :param json_: output JSON if true
        :type json_: bool
        :returns: process return code
        :rtype: int
        """

        marathon_client = self._create_marathon_client()
        self._ensure_pods_support(marathon_client)

        pods = marathon_client.list_pod()
        queued_apps = marathon_client.get_queued_apps()
        _enhance_row_with_overdue_information(pods, queued_apps)
        emitting.publish_table(emitter, pods, tables.pod_table, json_)
        return 0
コード例 #19
0
ファイル: main.py プロジェクト: sttts/dcos-cli
def _deployment_list(app_id, json_):
    """
    :param app_id: the application id
    :type app_id: str
    :param json_: output json if True
    :type json_: bool
    :returns: process return code
    :rtype: int
    """

    client = marathon.create_client()

    deployments = client.get_deployments(app_id)

    emitting.publish_table(emitter,
                           deployments,
                           tables.deployment_table,
                           json_)
    return 0
コード例 #20
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
コード例 #21
0
ファイル: main.py プロジェクト: jeffwhite530/dcos-core-cli
    def task_list(self, app_id, json_, quiet_=False):
        """
        :param app_id: the id of the application
        :type app_id: str
        :param json_: output json if True
        :type json_: bool
        :returns: process return code
        :rtype: int
        """

        client = self._create_marathon_client()
        tasks = client.get_tasks(app_id)

        if quiet_:
            for task in tasks:
                emitter.publish(task.get('id'))
        else:
            emitting.publish_table(emitter, tasks, tables.app_task_table,
                                   json_)
        return 0
コード例 #22
0
    def debug_details(self, app_id, json_):
        """
        :param app_id: the Marathon ID to display details
        :type app_id: string
        :param json_: output json if True
        :type json_: bool
        :returns: process return code
        :rtype: int
        """

        client = self._create_marathon_client()
        queued_app = client.get_queued_app(app_id)

        if queued_app:
            emitting.publish_table(emitter, queued_app,
                                   tables.queued_app_details_table, json_)
        else:
            raise DCOSException("No apps found in Marathon queue")

        return 0
コード例 #23
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
コード例 #24
0
ファイル: main.py プロジェクト: surdy/dcos-cli
    def debug_details(self, app_id, json_):
        """
        :param app_id: the Marathon ID to display details
        :type app_id: string
        :param json_: output json if True
        :type json_: bool
        :returns: process return code
        :rtype: int
        """

        client = self._create_marathon_client()
        queued_app = client.get_queued_app(app_id)

        if queued_app:
            emitting.publish_table(
                emitter, queued_app,
                tables.queued_app_details_table, json_)
        else:
            raise DCOSException("No apps found in Marathon queue")

        return 0
コード例 #25
0
ファイル: main.py プロジェクト: sttts/dcos-cli
def _search(json_, query):
    """Search for matching packages.

    :param json_: output json if True
    :type json_: bool
    :param query: The search term
    :type query: str
    :returns: Process status
    :rtype: int
    """
    if not query:
        query = ''

    config = util.get_config()
    results = [index_entry.as_dict()
               for index_entry in package.search(query, config)]

    emitting.publish_table(emitter,
                           results,
                           tables.package_search_table,
                           json_)
    return 0
コード例 #26
0
ファイル: main.py プロジェクト: sggraham32/dcos-cli
def _search(json_, query):
    """Search for matching packages.

    :param json_: output json if True
    :type json_: bool
    :param query: The search term
    :type query: str
    :returns: Process status
    :rtype: int
    """
    if not query:
        query = ''

    config = util.get_config()
    results = [
        index_entry.as_dict() for index_entry in package.search(query, config)
    ]

    if any(result['packages'] for result in results) or json_:
        emitting.publish_table(emitter, results, tables.package_search_table,
                               json_)
    else:
        raise DCOSException('No packages found.')
    return 0
コード例 #27
0
ファイル: maintenance.py プロジェクト: minyk/dcos-management
 def list(self, json_):
     emitting.publish_table(emitter, self.full_maintenance_status,
                            tables.maintenance_table, json_)
コード例 #28
0
 def list(self, json_):
     emitting.publish_table(emitter, self.full_maintenance_status, tables.maintenance_table, json_)