当前位置: 首页>>代码示例>>Python>>正文


Python utils.lazy_choices_completer函数代码示例

本文整理汇总了Python中paasta_tools.cli.utils.lazy_choices_completer函数的典型用法代码示例。如果您正苦于以下问题:Python lazy_choices_completer函数的具体用法?Python lazy_choices_completer怎么用?Python lazy_choices_completer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了lazy_choices_completer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_subparser

def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        "emergency-start",
        help="Resumes normal operation of a PaaSTA service instance by scaling to the configured instance count",
        description=(
            "'emergency-start' scales a PaaSTA service instance up to the configured instance count for a "
            "Marathon service. It does nothing to an existing Marathon service that already has the desired "
            "instance count.\n\n"
            "On a Chronos job, 'emergency-start' has the effect of forcing a job to run outside of its normal "
            "schedule."
        ),
    )
    status_parser.add_argument(
        "-s", "--service", help="Service that you want to start. Like 'example_service'."
    ).completer = lazy_choices_completer(list_services)
    status_parser.add_argument(
        "-i",
        "--instance",
        help="Instance of the service that you want to start. Like 'main' or 'canary'.",
        required=True,
    ).completer = lazy_choices_completer(list_instances)
    status_parser.add_argument(
        "-c",
        "--cluster",
        help="The PaaSTA cluster that has the service instance you want to start. Like 'norcal-prod'.",
        required=True,
    ).completer = lazy_choices_completer(list_clusters)
    status_parser.set_defaults(command=paasta_emergency_start)
开发者ID:sayi21cn,项目名称:paasta,代码行数:28,代码来源:emergency_start.py

示例2: add_subparser

def add_subparser(subparsers):
    list_parser = subparsers.add_parser(
        'rollback',
        help='Rollback a docker image to a previous deploy',
        description=(
            "'paasta rollback' is a human-friendly tool for marking a particular "
            "docker image for deployment, which invokes a bounce. While the command "
            "is called 'rollback', it can be used to roll forward or back, as long "
            "as there is a docker image available for the input git SHA."
        ),
        epilog=(
            "This rollback command uses the Git control plane, which requires network "
            "connectivity as well as authorization to the git repo."
        ),
    )
    list_parser.add_argument(
        '-k', '--commit',
        help="Git SHA to mark for rollback. "
        "A commit to rollback to is required for paasta rollback to run. However if one is not provided, "
        "paasta rollback will instead output a list of valid git shas to rollback to.",
        required=False,
    ).completer = lazy_choices_completer(list_previously_deployed_shas)
    list_parser.add_argument(
        '-d', '--deploy-groups',
        help='Mark one or more deploy groups to roll back (e.g. '
        '"all.main", "all.main,all.canary"). If no deploy groups specified,'
        ' all deploy groups for that service are rolled back',
        default='',
        required=False,
    )
    list_parser.add_argument(
        '-s', '--service',
        help='Name of the service to rollback (e.g. "service1")',
    ).completer = lazy_choices_completer(list_services)
    list_parser.set_defaults(command=paasta_rollback)
开发者ID:carriercomm,项目名称:paasta,代码行数:35,代码来源:rollback.py

示例3: add_subparser

def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'emergency-start',
        help="Resumes normal operation of a PaaSTA service instance by scaling to the configured instance count",
        description=(
            "'emergency-start' scales a PaaSTA service instance up to the configured instance count for a "
            "Marathon service. It does nothing to an existing Marathon service that already has the desired "
            "instance count.\n\n"
            "On a Chronos job, 'emergency-start' has the effect of forcing a job to run outside of its normal "
            "schedule."
        ),
    )
    status_parser.add_argument(
        '-s', '--service',
        help="Service that you want to start. Like 'example_service'.",
    ).completer = lazy_choices_completer(list_services)
    status_parser.add_argument(
        '-i', '--instance',
        help="Instance of the service that you want to start. Like 'main' or 'canary'.",
        required=True,
    ).completer = lazy_choices_completer(list_instances)
    status_parser.add_argument(
        '-c', '--cluster',
        help="The PaaSTA cluster that has the service instance you want to start. Like 'norcal-prod'.",
        required=True,
    ).completer = lazy_choices_completer(list_clusters)
    status_parser.add_argument(
        '-d', '--soa-dir',
        dest="soa_dir",
        metavar="SOA_DIR",
        default=DEFAULT_SOA_DIR,
        help="define a different soa config directory",
    )
    status_parser.set_defaults(command=paasta_emergency_start)
开发者ID:RedCobbler,项目名称:paasta,代码行数:34,代码来源:emergency_start.py

示例4: add_subparser

def add_subparser(subparsers):
    for command, lower, upper, cmd_func in [
        ('start', 'start or restart', 'Start or restart', paasta_start),
        ('restart', 'start or restart', 'Start or restart', paasta_start),
        ('stop', 'stop', 'Stop', paasta_stop)
    ]:
        status_parser = subparsers.add_parser(
            command,
            help="%ss a PaaSTA service in a graceful way." % upper,
            description=(
                "%ss a PaaSTA service in a graceful way. This uses the Git control plane." % upper
            ),
            epilog=(
                "This command uses Git, and assumes access and authorization to the Git repo "
                "for the service is available."
            ),
        )
        status_parser.add_argument(
            '-s', '--service',
            help='Service that you want to %s. Like example_service.' % lower,
        ).completer = lazy_choices_completer(list_services)
        status_parser.add_argument(
            '-i', '--instance',
            help='Instance of the service that you want to %s. Like "main" or "canary".' % lower,
            required=True,
        ).completer = lazy_choices_completer(list_instances)
        status_parser.add_argument(
            '-c', '--cluster',
            help='The PaaSTA cluster that has the service you want to %s. Like norcal-prod' % lower,
            required=True,
        ).completer = lazy_choices_completer(utils.list_clusters)
        status_parser.set_defaults(command=cmd_func)
开发者ID:iomedhealth,项目名称:paasta,代码行数:32,代码来源:start_stop_restart.py

示例5: add_subparser

def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'status',
        help="Display the status of a PaaSTA service.",
        description=(
            "'paasta status' works by SSH'ing to remote PaaSTA masters and "
            "inspecting the local APIs, and reports on the overal health "
            "of a service."
        ),
        epilog=(
            "Note: This command requires SSH and sudo privileges on the remote PaaSTA "
            "masters."
        ),
    )
    status_parser.add_argument(
        '-v', '--verbose',
        action='store_true',
        dest="verbose",
        default=False,
        help="Print out more output regarding the state of the service")
    status_parser.add_argument(
        '-s', '--service',
        help='The name of the service you wish to inspect'
    ).completer = lazy_choices_completer(list_services)
    status_parser.add_argument(
        '-c', '--clusters',
        help="A comma-separated list of clusters to view. Defaults to view all clusters.\n"
             "For example: --clusters norcal-prod,nova-prod"
    ).completer = lazy_choices_completer(list_clusters)
    status_parser.add_argument(
        '-i', '--instances',
        help="A comma-separated list of instances to view. Defaults to view all instances.\n"
             "For example: --instances canary,main"
    )  # No completer because we need to know service first and we can't until some other stuff has happened
    status_parser.set_defaults(command=paasta_status)
开发者ID:Jordan50,项目名称:paasta,代码行数:35,代码来源:status.py

示例6: add_subparser

def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'emergency-restart',
        help="Restarts a PaaSTA service instance in an emergency",
        description=(
            "'paasta emergency-restart' is useful in situations where the operator "
            "needs to bypass the normal git-based control plan, and needs to interact "
            "with the underlying APIs directly. For example, in an emergency situation "
            "it may be necessary to restart a Marathon service without doing a 'full bounce'."
            "'emergency-restart' can do this, but at the cost of the safety of the normal "
            "bouncing procedures. In other words, and emergency-restart is fast, but not safe "
            "and will cause dropped traffic.\n\n"
            "'paasta emergency-restart' is the equivalent to a 'paasta emergency-stop' followed "
            "by a 'paasta emergency-start'."
        ),
    )
    status_parser.add_argument(
        '-s', '--service',
        help="Service that you want to restart. Like 'example_service'.",
    ).completer = lazy_choices_completer(list_services)
    status_parser.add_argument(
        '-i', '--instance',
        help="Instance of the service that you want to restart. Like 'main' or 'canary'.",
        required=True,
    ).completer = lazy_choices_completer(list_instances)
    status_parser.add_argument(
        '-c', '--cluster',
        help="The PaaSTA cluster that has the service you want to restart. Like 'norcal-prod'.",
        required=True,
    ).completer = lazy_choices_completer(list_clusters)
    status_parser.set_defaults(command=paasta_emergency_restart)
开发者ID:Jordan50,项目名称:paasta,代码行数:31,代码来源:emergency_restart.py

示例7: add_subparser

def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'emergency-start',
        help="Kicks off a chronos job run. Not implemented for Marathon instances.",
        description=(
            "Chronos Jobs: Forces a job to run outside of its normal schedule.\n"
            "Marathon Apps: Not implemented.\n"
        ),
    )
    status_parser.add_argument(
        '-s', '--service',
        help="Service that you want to start. Like 'example_service'.",
    ).completer = lazy_choices_completer(list_services)
    status_parser.add_argument(
        '-i', '--instance',
        help="Instance of the service that you want to start. Like 'main' or 'canary'.",
        required=True,
    ).completer = lazy_choices_completer(list_instances)
    status_parser.add_argument(
        '-c', '--cluster',
        help="The PaaSTA cluster that has the service instance you want to start. Like 'norcal-prod'.",
        required=True,
    ).completer = lazy_choices_completer(list_clusters)
    status_parser.add_argument(
        '-d', '--soa-dir',
        dest="soa_dir",
        metavar="SOA_DIR",
        default=DEFAULT_SOA_DIR,
        help="define a different soa config directory",
    )
    status_parser.set_defaults(command=paasta_emergency_start)
开发者ID:somic,项目名称:paasta,代码行数:31,代码来源:emergency_start.py

示例8: add_subparser

def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'emergency-stop',
        help="Stop a PaaSTA service instance in an emergency",
        description=(
            "Chronos jobs: Stops and kills and inflight run.\n"
            "Marathon apps: Not implemented."
        ),
    )
    status_parser.add_argument(
        '-s', '--service',
        help="Service that you want to stop. Like 'example_service'.",
    ).completer = lazy_choices_completer(list_services)
    status_parser.add_argument(
        '-i', '--instance',
        help="Instance of the service that you want to stop. Like 'main' or 'canary'.",
        required=True,
    ).completer = lazy_choices_completer(list_instances)
    status_parser.add_argument(
        '-c', '--cluster',
        help="The PaaSTA cluster that has the service instance you want to stop. Like 'norcal-prod'.",
        required=True,
    ).completer = lazy_choices_completer(list_clusters)
    status_parser.add_argument(
        '-d', '--soa-dir',
        dest="soa_dir",
        metavar="SOA_DIR",
        default=DEFAULT_SOA_DIR,
        help="define a different soa config directory",
    )
    status_parser.set_defaults(command=paasta_emergency_stop)
开发者ID:oktopuz,项目名称:paasta,代码行数:31,代码来源:emergency_stop.py

示例9: add_subparser

def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'logs',
        help="Streams logs relevant to a service across the PaaSTA components",
        description=(
            "'paasta logs' works by streaming PaaSTA-related event messages "
            "in a human-readable way."
        ),
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    status_parser.add_argument(
        '-s', '--service',
        help='The name of the service you wish to inspect. Defaults to autodetect.'
    ).completer = lazy_choices_completer(list_services)
    components_help = 'A comma separated list of the components you want logs for.'
    status_parser.add_argument(
        '-C', '--components',
        help=components_help,
    ).completer = lazy_choices_completer(LOG_COMPONENTS.keys)
    cluster_help = 'The clusters to see relevant logs for. Defaults to all clusters to which this service is deployed.'
    status_parser.add_argument(
        '-c', '--clusters',
        help=cluster_help,
    ).completer = completer_clusters
    status_parser.add_argument(
        '-f', '-F', '--tail', dest='tail', action='store_true', default=True,
        help='Stream the logs and follow it for more data',
    )
    status_parser.add_argument(
        '-v', '--verbose', action='store_true', dest='verbose', default=False,
        help='Enable verbose logging',
    )
    status_parser.add_argument(
        '-r', '--raw-mode', action='store_true',
        dest='raw_mode', default=False,
        help="Don't pretty-print logs; emit them exactly as they are in scribe."
    )
    status_parser.add_argument(
        '-d', '--soa-dir',
        dest="soa_dir",
        metavar="SOA_DIR",
        default=DEFAULT_SOA_DIR,
        help="define a different soa config directory",
    )
    default_component_string = ','.join(DEFAULT_COMPONENTS)
    component_descriptions = build_component_descriptions(LOG_COMPONENTS)
    epilog = 'COMPONENTS\n' \
             'There are many possible components of Paasta logs that you might be interested in:\n' \
             'Run --list-components to see all available log components.\n' \
             'If unset, the default components are:\n\t%s\n' \
             'So the default behavior of `paasta logs` will be to tail those logs.\n\n' \
             'Here is a list of all components and what they are:\n%s\n\n' \
             % (default_component_string, component_descriptions)
    status_parser.epilog = epilog
    status_parser.set_defaults(command=paasta_logs)
开发者ID:edmund-troche,项目名称:paasta,代码行数:55,代码来源:logs.py

示例10: add_subparser

def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        "emergency-stop",
        help="Stop a PaaSTA service instance in an emergency",
        description=(
            "'emergency-stop' stops a Marathon service instance by scaling it down to 0. If the "
            "provided 'instance' name refers to a Chronos job, 'emergency-stop' will cancel the "
            "chronos job if it is currently running."
        ),
        epilog=(
            "Warning: 'emergency-stop' does not interact with load balancers, so any in-flight "
            "traffic will be dropped after stopping. Additionally the 'desired state' of a service "
            "is not changed after an 'emergency-stop', therefore alerts will fire for the service "
            "after an emergency stop.\n\n"
            "'emergency-stop' is not a permanant declaration of state. If the operator wishes to "
            "stop a service permanently, they should run 'paasta stop', or configure the service to "
            "have '0' instances. Otherwise, subsequent changes or bounces to a service will start "
            "it right back up."
        ),
    )
    status_parser.add_argument(
        "-s", "--service", help="Service that you want to stop. Like 'example_service'."
    ).completer = lazy_choices_completer(list_services)
    status_parser.add_argument(
        "-i",
        "--instance",
        help="Instance of the service that you want to stop. Like 'main' or 'canary'.",
        required=True,
    ).completer = lazy_choices_completer(list_instances)
    status_parser.add_argument(
        "-c",
        "--cluster",
        help="The PaaSTA cluster that has the service instance you want to stop. Like 'norcal-prod'.",
        required=True,
    ).completer = lazy_choices_completer(list_clusters)
    status_parser.add_argument(
        "-a",
        "--appid",
        help="The complete marathon appid to stop. Like 'example-service.main.gitf0cfd3a0.config7a2a00b7",
        required=False,
    )
    status_parser.add_argument(
        "-d",
        "--soa-dir",
        dest="soa_dir",
        metavar="SOA_DIR",
        default=DEFAULT_SOA_DIR,
        help="define a different soa config directory",
    )
    status_parser.set_defaults(command=paasta_emergency_stop)
开发者ID:gstarnberger,项目名称:paasta,代码行数:50,代码来源:emergency_stop.py

示例11: add_subparser

def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'metastatus',
        help="Display the status for an entire PaaSTA cluster",
        description=(
            "'paasta metastatus' is used to get the vital statistics about a PaaaSTA "
            "cluster as a whole. This tool is helpful when answering the question: 'Is "
            "it just my service or the whole cluster that is broken?'\n\n"
            "metastatus operates by ssh'ing to a Mesos master of a remote cluster, and "
            "querying the local APIs."
        ),
        epilog=(
            "The metastatus command may time out during heavy load. When that happens "
            "users may execute the ssh command directly, in order to bypass the timeout."
        ),
    )
    status_parser.add_argument(
        '-v', '--verbose',
        action='store_true',
        dest="verbose",
        default=False,
        help="Print out more output regarding the state of the cluster",
    )
    clusters_help = (
        'A comma separated list of clusters to view. Defaults to view all clusters. '
        'Try: --clusters norcal-prod,nova-prod'
    )
    status_parser.add_argument(
        '-c', '--clusters',
        help=clusters_help,
    ).completer = lazy_choices_completer(list_clusters)
    status_parser.set_defaults(command=paasta_metastatus)
开发者ID:sayi21cn,项目名称:paasta,代码行数:32,代码来源:metastatus.py

示例12: add_subparser

def add_subparser(subparsers):
    list_parser = subparsers.add_parser(
        'itest',
        help="Runs 'make itest' as part of the PaaSTA contract.",
        description=(
            "'paasta itest' runs 'make itest' in the root of a service directory. "
            "It is designed to be used in conjection with the 'Jenkins' workflow: "
            "http://paasta.readthedocs.org/en/latest/about/contract.html#jenkins-pipeline-recommended"
        )
    )
    list_parser.add_argument(
        '-s', '--service',
        help='Test and build docker image for this service. Leading '
             '"services-", as included in a Jenkins job name, '
             'will be stripped.',
        required=True,
    )
    list_parser.add_argument(
        '-c', '--commit',
        help='Git sha used to construct tag for built image',
        required=True,
    )
    list_parser.add_argument(
        '-d', '--soa-dir',
        dest='soa_dir',
        help='A directory from which soa-configs should be read from',
        default=DEFAULT_SOA_DIR,
    ).completer = lazy_choices_completer(list_services)
    list_parser.set_defaults(command=paasta_itest)
开发者ID:michaelnkang,项目名称:paasta,代码行数:29,代码来源:itest.py

示例13: add_subparser

def add_subparser(subparsers):
    rerun_parser = subparsers.add_parser(
        'rerun',
        help="Re-run a scheduled PaaSTA job",
        description=(
            "'paasta rerun' creates a copy of the specified PaaSTA scheduled job and executes it immediately. "
            "Parent-dependent relationships are ignored: 'pasta rerun' only executes individual jobs."
        ),
        epilog=(
            "Note: This command requires SSH and sudo privileges on the remote PaaSTA "
            "masters."
        ),
    )
    rerun_parser.add_argument(
        '-v', '--verbose',
        action='count',
        dest="verbose",
        default=0,
        help="Print out more output regarding the operation."
    )
    rerun_parser.add_argument(
        '-s', '--service',
        help='The name of the service you wish to operate on.',
    ).completer = lazy_choices_completer(list_services)
    rerun_parser.add_argument(
        '-i', '--instance',
        help='Name of the scheduled job (instance) that you want to rerun.',
        required=True,
    ).completer = lazy_choices_completer(list_instances)
    rerun_parser.add_argument(
        '-c', '--clusters',
        help="A comma-separated list of clusters to rerun the job on. Defaults to rerun on all clusters.\n"
             "For example: --clusters norcal-prod,nova-prod"
    ).completer = lazy_choices_completer(list_clusters)
    rerun_parser.add_argument(
        '-d', '--execution_date',
        help="The date the job should be rerun for. Expected in the format %%Y-%%m-%%dT%%H:%%M:%%S .",
        type=chronos_tools.parse_execution_date
    )
    rerun_parser.add_argument(
        '-y', '--soa-dir',
        dest="soa_dir",
        metavar="SOA_DIR",
        default=DEFAULT_SOA_DIR,
        help="define a different soa config directory",
    )
    rerun_parser.set_defaults(command=paasta_rerun)
开发者ID:edmund-troche,项目名称:paasta,代码行数:47,代码来源:rerun.py

示例14: add_subparser

def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'emergency-scale',
        help="Scale a PaaSTA service instance in Marathon without bouncing it",
        description=(
            "'emergency-scale' is used to scale a PaaSTA service instance by scaling it up or down "
            "in Marathon by N instances, where N is provided by the --delta argument.\n\n"
            "This command works by using SSH to execute commands directly on the Marathon servers, "
            "where API access and credentials are guaranteed to be available."
        ),
        epilog=(
            "Warning: Using emergency-scale to scale *down* a service will not interact with "
            "load balancers, and therefore will drop traffic."
        ),
    )
    status_parser.add_argument(
        '-s', '--service',
        help="Service that you want to scale. Like 'example_service'.",
    ).completer = lazy_choices_completer(list_services)
    status_parser.add_argument(
        '-i', '--instance',
        help="Instance of the service that you want to scale. Like 'main' or 'canary'.",
        required=True,
    ).completer = lazy_choices_completer(list_instances)
    status_parser.add_argument(
        '-c', '--cluster',
        help="The PaaSTA cluster that has the service instance you want to scale. Like 'norcal-prod'.",
        required=True,
    ).completer = lazy_choices_completer(list_clusters)
    status_parser.add_argument(
        '-a', '--appid',
        help="The complete marathon appid to scale. Like 'example-service.main.gitf0cfd3a0.config7a2a00b7",
        required=False,
    )
    status_parser.add_argument(
        '-y', '--yelpsoa-config-root',
        default=DEFAULT_SOA_DIR,
        required=False,
        help="Path to root of yelpsoa-configs checkout",
    )
    status_parser.add_argument(
        '--delta',
        required=True,
        help="Number of instances you want to scale up (positive number) or down (negative number)",
    )
    status_parser.set_defaults(command=paasta_emergency_scale)
开发者ID:Jordan50,项目名称:paasta,代码行数:46,代码来源:emergency_scale.py

示例15: add_subparser

def add_subparser(subparsers):
    fsm_parser = subparsers.add_parser(
        "fsm",
        help="Generate boilerplate configs for a new PaaSTA Service",
        description=(
            "'paasta fsm' is used to generate example soa-configs, which is useful during initial "
            "service creation. Currently 'fsm' generates 'yelp-specific' configuration, but can still "
            "be used as an example of a fully working PaaSTA service.\n\n"
            "After 'paasta fsm' is run, the operator should inspect the generated boilerplate configuration "
            "and adjust it to meet the particular needs of the new service."
        ),
    )
    fsm_parser.add_argument(
        "-y", "--yelpsoa-config-root",
        dest="yelpsoa_config_root",
        default=DEFAULT_SOA_DIR,
        required=True,
        help="Path to root of yelpsoa-configs checkout (required)")
    fsm_parser.add_argument(
        "-s", "--service-name",
        dest="srvname",
        default=None,
        help="Name of service being configured (--auto not available)")
    fsm_parser.add_argument(
        "--description",
        dest="description",
        default=None,
        help="One line description of the service. If AUTO will have placeholder text")
    fsm_parser.add_argument(
        "--external-link",
        dest="external_link",
        default=None,
        help="Link to a reference doc for the service. If AUTO will have placeholder text")
    fsm_parser.add_argument(
        "-a",
        "--auto",
        dest="auto",
        default=False,
        action="store_true",
        help="Automatically calculate and use sane defaults. Exit violently if "
             "any values cannot be automatically calculated.",
    )
    fsm_parser.add_argument(
        "-p", "--port",
        dest="port",
        default=None,
        help="Smartstack proxy port used by service.")
    fsm_parser.add_argument(
        "-t", "--team",
        dest="team",
        default=None,
        help="Team responsible for the service. Used by various notification "
             "systems. (--auto not available)",
    ).completer = lazy_choices_completer(list_teams)
    fsm_parser.set_defaults(command=paasta_fsm)
开发者ID:iomedhealth,项目名称:paasta,代码行数:55,代码来源:fsm.py


注:本文中的paasta_tools.cli.utils.lazy_choices_completer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。