Esempio n. 1
0
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,
            description="%ss a PaaSTA service in a graceful way." % upper,
            help="%ss a PaaSTA service" % upper,
        )
        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)
Esempio n. 2
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'status',
        description=(
            "PaaSTA client will attempt to deduce the SERVICE option if"
            " none is provided."),
        help="Display the status of a PaaSTA service.")
    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)
Esempio n. 3
0
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,
            description="%ss a PaaSTA service in a graceful way." % upper,
            help="%ss a PaaSTA service" % upper,
        )
        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)
Esempio n. 4
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'emergency-stop',
        description="Stop a PaaSTA service instance",
        help=("Stops a PaaSTA service instance by scaling it down to 0 instances (for Marathon apps)"
              " or by killing the tasks for any version of it and disabling it (for Chronos jobs)."))
    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(
        '-y', '--yelpsoa-config-root',
        default=DEFAULT_SOA_DIR,
        required=False,
        help="Path to root of yelpsoa-configs checkout",
    )
    status_parser.set_defaults(command=paasta_emergency_stop)
Esempio n. 5
0
def add_subparser(subparsers):
    list_parser = subparsers.add_parser(
        'rollback',
        description='Rollback a docker image to a previous deploy',
        help='Rollback a docker image to a previous deploy')

    list_parser.add_argument('-k', '--commit',
                             help='Git SHA to mark for rollback',
                             required=True,
                             )
    list_parser.add_argument('-i', '--instances',
                             help='Mark one or more instances to roll back (e.g. '
                             '"canary", "canary,main"). If no instances specified,'
                             ' all instances for that service are rolled back',
                             default='',
                             required=False,
                             ).completer = lazy_choices_completer(list_instances)
    list_parser.add_argument('-c', '--cluster',
                             help='Mark the cluster to rollback (e.g. '
                             'cluster1)',
                             required=True,
                             ).completer = lazy_choices_completer(list_clusters)
    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)
Esempio n. 6
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        "emergency-start",
        description="Resumes normal operation of a PaaSTA service instance",
        help=(
            "Starts a PaaSTA service instance up by setting instance count to its configured value"
            " (for Marathon apps) or by running the latest version of the job (for Chronos jobs)."
        ),
    )
    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)
Esempio n. 7
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'status',
        description=("PaaSTA client will attempt to deduce the SERVICE option if"
                     " none is provided."),
        help="Display the status of a PaaSTA service.")
    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)
Esempio n. 8
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'logs',
        description=
        "Gets logs relevant to a service across the PaaSTA components",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        help="Gets logs relevant to a service across the PaaSTA components.")
    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('-d',
                               '--debug',
                               action='store_true',
                               dest='debug',
                               default=False,
                               help='Enable debug 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."
    )
    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)
Esempio n. 9
0
def add_subparser(subparsers):
    list_parser = subparsers.add_parser(
        'info',
        description="Prints the general information about a service.",
        help="Prints general service information")
    list_parser.add_argument(
        '-s', '--service', help='The name of the service you wish to inspect'
    ).completer = lazy_choices_completer(list_services)
    list_parser.set_defaults(command=paasta_info)
Esempio n. 10
0
def add_subparser(subparsers):
    list_parser = subparsers.add_parser(
        'info',
        description="Prints the general information about a service.",
        help="Prints general service information")
    list_parser.add_argument(
        '-s', '--service',
        help='The name of the service you wish to inspect'
    ).completer = lazy_choices_completer(list_services)
    list_parser.set_defaults(command=paasta_info)
Esempio n. 11
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'emergency-stop',
        description="Stop a PaaSTA service instance",
        help=
        ("Stops a PaaSTA service instance by scaling it down to 0 instances (for Marathon apps)"
         " or by killing the tasks for any version of it and disabling it (for Chronos jobs)."
         ))
    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(
        '-y',
        '--yelpsoa-config-root',
        default=DEFAULT_SOA_DIR,
        required=False,
        help="Path to root of yelpsoa-configs checkout",
    )
    status_parser.set_defaults(command=paasta_emergency_stop)
Esempio n. 12
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'emergency-restart',
        description="Restarts a PaaSTA service instance in an emergency",
        help="Restarts a PaaSTA service instance by running emergency-stop then emergency-start on it.")
    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)
Esempio n. 13
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'logs',
        description="Gets logs relevant to a service across the PaaSTA components",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        help="Gets logs relevant to a service across the PaaSTA components.")
    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('-d', '--debug', action='store_true',
                               dest='debug', default=False,
                               help='Enable debug 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.")
    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)
Esempio n. 14
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'emergency-start',
        description="Resumes normal operation of a PaaSTA service instance",
        help=("Starts a PaaSTA service instance up by setting instance count to its configured value"
              " (for Marathon apps) or by running the latest version of the job (for Chronos jobs)."))
    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)
Esempio n. 15
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        "emergency-restart",
        description="Restarts a PaaSTA service instance in an emergency",
        help="Restarts a PaaSTA service instance by running emergency-stop then emergency-start on it.",
    )
    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)
Esempio n. 16
0
def add_subparser(subparsers):
    list_parser = subparsers.add_parser(
        'generate-pipeline',
        description='Run `paasta generate-pipeline` in root of your service or '
                    'with -s $SERVICENAME. Uses a deploy.yaml in '
                    '/nail/etc/services/$SERVICENAME/deploy.yaml',
        help='Configure a Jenkins build pipeline.')

    list_parser.add_argument('-s', '--service',
                             help='Name of service for which you wish to generate a Jenkins pipeline',
                             ).completer = lazy_choices_completer(list_services)

    list_parser.set_defaults(command=paasta_generate_pipeline)
Esempio n. 17
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        "logs",
        description="Gets logs relevant to a service across the PaaSTA components",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        help="Gets logs relevant to a service across the PaaSTA components.",
    )
    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(
        "-d", "--debug", action="store_true", dest="debug", default=False, help="Enable debug 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.",
    )
    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)
Esempio n. 18
0
def add_subparser(subparsers):
    fsm_parser = subparsers.add_parser(
        "fsm",
        description="Configure A New PaaSTA Service -- http://y/paasta-deploy For Details",
        help="Start A New Service From Scratch",
    )
    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)
Esempio n. 19
0
def add_subparser(subparsers):
    fsm_parser = subparsers.add_parser(
        "fsm",
        description="Configure A New PaaSTA Service -- http://y/paasta-deploy For Details",
        help="Start A New Service From Scratch",
    )
    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)
Esempio n. 20
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'emergency-scale',
        description="Scale a PaaSTA service instance",
        help=("Scale a PaaSTA service instance by scaling it up or down to n instances (for Marathon apps)"))
    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)
Esempio n. 21
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'metastatus',
        help="Display the status for an entire PaaSTA cluster")
    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)
Esempio n. 22
0
def add_subparser(subparsers):
    list_parser = subparsers.add_parser(
        'generate-pipeline',
        description='Run `paasta generate-pipeline` in root of your service or '
        'with -s $SERVICENAME. Uses a deploy.yaml in '
        '/nail/etc/services/$SERVICENAME/deploy.yaml',
        help='Configure a Jenkins build pipeline.')

    list_parser.add_argument(
        '-s',
        '--service',
        help=
        'Name of service for which you wish to generate a Jenkins pipeline',
    ).completer = lazy_choices_completer(list_services)

    list_parser.set_defaults(command=paasta_generate_pipeline)
Esempio n. 23
0
def add_subparser(subparsers):
    status_parser = subparsers.add_parser(
        'metastatus', help="Display the status for an entire PaaSTA cluster")
    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)
Esempio n. 24
0
def test_lazy_choices_completer():
    completer = utils.lazy_choices_completer(lambda: ['1', '2', '3'])
    assert completer(prefix='') == ['1', '2', '3']
Esempio n. 25
0
def add_subparser(subparsers):
    list_parser = subparsers.add_parser(
        'local-run',
        description="Build and run a service's Docker container locally",
        help='Test run service Docker container',
    )
    list_parser.add_argument(
        '-s', '--service',
        help='The name of the service you wish to inspect',
    ).completer = lazy_choices_completer(list_services)
    list_parser.add_argument(
        '-c', '--cluster',
        help='The name of the cluster you wish to simulate. If omitted, attempts to guess a cluster to simulate',
    ).completer = lazy_choices_completer(list_clusters)
    list_parser.add_argument(
        '-y', '--yelpsoa-config-root',
        dest='yelpsoa_config_root',
        help='A directory from which yelpsoa-configs should be read from',
        default=service_configuration_lib.DEFAULT_SOA_DIR
    )
    list_parser.add_argument(
        '-C', '--cmd',
        help=(
            'Run Docker container with particular command, '
            'for instance bash'
        ),
        required=False,
        default='',
    )
    list_parser.add_argument(
        '-i', '--instance',
        help='Simulate a docker run for a particular instance of the service, like "main" or "canary"',
        required=False,
        default='main',
    ).completer = lazy_choices_completer(list_instances)
    list_parser.add_argument(
        '-v', '--verbose',
        help='Show Docker commands output',
        action='store_true',
        required=False,
        default=True,
    )
    list_parser.add_argument(
        '-I', '--interactive',
        help='Run container in interactive mode',
        action='store_true',
        required=False,
        default=False,
    )
    list_parser.add_argument(
        '-k', '--no-healthcheck',
        help='Disable simulated healthcheck',
        dest='healthcheck',
        action='store_false',
        required=False,
        default=True,
    )
    list_parser.add_argument(
        '-t', '--healthcheck-only',
        help='Terminates container after healthcheck (exits with status code 0 on success, 1 otherwise)',
        dest='healthcheck_only',
        action='store_true',
        required=False,
        default=False,
    )

    list_parser.set_defaults(command=paasta_local_run)
Esempio n. 26
0
def add_subparser(subparsers):
    list_parser = subparsers.add_parser(
        'local-run',
        description="Build and run a service's Docker container locally",
        help='Test run service Docker container',
    )
    list_parser.add_argument(
        '-s',
        '--service',
        help='The name of the service you wish to inspect',
    ).completer = lazy_choices_completer(list_services)
    list_parser.add_argument(
        '-c',
        '--cluster',
        help=
        'The name of the cluster you wish to simulate. If omitted, attempts to guess a cluster to simulate',
    ).completer = lazy_choices_completer(list_clusters)
    list_parser.add_argument(
        '-y',
        '--yelpsoa-config-root',
        dest='yelpsoa_config_root',
        help='A directory from which yelpsoa-configs should be read from',
        default=service_configuration_lib.DEFAULT_SOA_DIR)
    list_parser.add_argument(
        '-C',
        '--cmd',
        help=('Run Docker container with particular command, '
              'for instance bash'),
        required=False,
        default='',
    )
    list_parser.add_argument(
        '-i',
        '--instance',
        help=
        'Simulate a docker run for a particular instance of the service, like "main" or "canary"',
        required=False,
        default='main',
    ).completer = lazy_choices_completer(list_instances)
    list_parser.add_argument(
        '-v',
        '--verbose',
        help='Show Docker commands output',
        action='store_true',
        required=False,
        default=True,
    )
    list_parser.add_argument(
        '-I',
        '--interactive',
        help='Run container in interactive mode',
        action='store_true',
        required=False,
        default=False,
    )
    list_parser.add_argument(
        '-k',
        '--no-healthcheck',
        help='Disable simulated healthcheck',
        dest='healthcheck',
        action='store_false',
        required=False,
        default=True,
    )
    list_parser.add_argument(
        '-t',
        '--healthcheck-only',
        help=
        'Terminates container after healthcheck (exits with status code 0 on success, 1 otherwise)',
        dest='healthcheck_only',
        action='store_true',
        required=False,
        default=False,
    )

    list_parser.set_defaults(command=paasta_local_run)
Esempio n. 27
0
def add_subparser(subparsers):
    list_parser = subparsers.add_parser(
        'local-run',
        description="Build and run a service's Docker container locally",
        help='Test run service Docker container',
    )
    list_parser.add_argument(
        '-s', '--service',
        help='The name of the service you wish to inspect',
    ).completer = lazy_choices_completer(list_services)
    list_parser.add_argument(
        '-c', '--cluster',
        help='The name of the cluster you wish to simulate. If omitted, attempts to guess a cluster to simulate',
    ).completer = lazy_choices_completer(list_clusters)
    list_parser.add_argument(
        '-y', '--yelpsoa-config-root',
        dest='yelpsoa_config_root',
        help='A directory from which yelpsoa-configs should be read from',
        default=service_configuration_lib.DEFAULT_SOA_DIR,
    )
    build_pull_group = list_parser.add_mutually_exclusive_group()
    build_pull_group.add_argument(
        '-b', '--build',
        help=("Build the docker image to run from scratch using the local Makefile's ",
              "'cook-image' target. Defaults to try to use the local Makefile if present. ",
              "otherwise local-run will pull and run the Docker image that is marked for ",
              "deployment in the Docker registry. Mutually exclusive with '--pull'."),
        required=False,
        action='store_true',
        default=None,
    )
    build_pull_group.add_argument(
        '-p', '--pull',
        help=("Pull the docker image marked for deployment from the Docker registry and ",
              "use that for the local-run. This is the opposite of --build. Defaults to ",
              "autodetect a Makefile, if present will not pull, and instead assume that ",
              "a local build is desired. Mutally exclusive with '--build'"),
        required=False,
        action='store_true',
        default=None,
    )
    list_parser.add_argument(
        '-C', '--cmd',
        help=('Run Docker container with particular command, '
              'for example: "bash". By default will use the command or args specified by the '
              'soa-configs or what was specified in the Dockefile'),
        required=False,
        default=None,
    )
    list_parser.add_argument(
        '-i', '--instance',
        help='Simulate a docker run for a particular instance of the service, like "main" or "canary"',
        required=False,
        default='main',
    ).completer = lazy_choices_completer(list_instances)
    list_parser.add_argument(
        '-v', '--verbose',
        help='Show Docker commands output',
        action='store_true',
        required=False,
        default=True,
    )
    list_parser.add_argument(
        '-I', '--interactive',
        help=('Run container in interactive mode. If interactive is set the default command will be "bash" '
              'unless otherwise set by the "--cmd" flag'),
        action='store_true',
        required=False,
        default=False,
    )
    list_parser.add_argument(
        '-k', '--no-healthcheck',
        help='Disable simulated healthcheck',
        dest='healthcheck',
        action='store_false',
        required=False,
        default=True,
    )
    list_parser.add_argument(
        '-t', '--healthcheck-only',
        help='Terminates container after healthcheck (exits with status code 0 on success, 1 otherwise)',
        dest='healthcheck_only',
        action='store_true',
        required=False,
        default=False,
    )
    list_parser.set_defaults(command=paasta_local_run)