Пример #1
0
    def add_arguments(self, parser):
        SubParser = get_sub_parser_class(self)

        sub = parser.add_subparsers(dest="sub_command",
                                    help="Sub commands",
                                    parser_class=SubParser)
        sub.required = True

        # "add" sub-command
        add_parser = sub.add_parser(
            "add", help="Add alias to an existing device type")
        add_parser.add_argument("alias", help="Alias to add to device type")
        add_parser.add_argument("devicetype", help="Device type")

        # "list" sub-command
        list_parser = sub.add_parser("list", help="List Aliases")

        # "show" sub-command
        show_parser = sub.add_parser(
            "show", help="Show all aliases for an existing device type")
        show_parser.add_argument("alias",
                                 help="Alias to display details about")

        # "remove" sub-command
        remove_parser = sub.add_parser("remove",
                                       help="Remove alias from device type")
        remove_parser.add_argument("alias",
                                   help="Alias to remove from device type")
Пример #2
0
    def add_arguments(self, parser):
        SubParser = get_sub_parser_class(self)

        sub = parser.add_subparsers(
            dest="sub_command", help="Sub commands", parser_class=SubParser
        )
        sub.required = True

        add_parser = sub.add_parser("add", help="Create a worker")
        add_parser.add_argument("hostname", type=str, help="Hostname of the worker")
        add_parser.add_argument(
            "--description", type=str, default="", help="Worker description"
        )
        add_parser.add_argument(
            "--health",
            type=str,
            default="ACTIVE",
            choices=["ACTIVE", "MAINTENANCE", "RETIRED"],
            help="Worker health",
        )

        details_parser = sub.add_parser("details", help="Details of a worker")
        details_parser.add_argument("hostname", type=str, help="Hostname of the worker")
        details_parser.add_argument(
            "--devices",
            action="store_true",
            default=False,
            help="Print the list of attached devices",
        )

        list_parser = sub.add_parser("list", help="List the workers")
        list_parser.add_argument(
            "-a",
            "--all",
            default=False,
            action="store_true",
            help="Show all workers (including retired ones)",
        )
        list_parser.add_argument(
            "--csv", dest="csv", default=False, action="store_true", help="Print as csv"
        )

        update_parser = sub.add_parser("update", help="Update worker properties")
        update_parser.add_argument("hostname", type=str, help="Hostname of the worker")
        update_parser.add_argument(
            "--description", type=str, default=None, help="Worker description"
        )
        update_parser.add_argument(
            "--health",
            type=str,
            default=None,
            choices=["ACTIVE", "MAINTENANCE", "RETIRED"],
            help="Set worker health",
        )
Пример #3
0
    def add_arguments(self, parser):
        SubParser = get_sub_parser_class(self)

        sub = parser.add_subparsers(dest="sub_command",
                                    help="Sub commands",
                                    parser_class=SubParser)
        sub.required = True

        # "add" sub-command
        add_parser = sub.add_parser("add", help="Add a group")
        add_parser.add_argument("name", help="Name of the Django group")
        add_parser.add_argument(
            "--username",
            default=None,
            dest="username",
            help="Username of a user to add to the new group",
        )
        add_parser.add_argument(
            "--submitting",
            default=False,
            action="store_true",
            dest="submitting",
            help="Give users in this group permission to submit test jobs.",
        )

        # "update" sub-command
        update_parser = sub.add_parser("update", help="Update a group")
        update_parser.add_argument("name", help="Name of the Django group")
        update_parser.add_argument(
            "--username",
            dest="username",
            help="Username of a user to add to the group")
        update_parser.add_argument(
            "--submitting",
            default=False,
            dest="submitting",
            action="store_true",
            help="Give users in this group permission to submit test jobs.",
        )

        # "list" sub-command
        list_parser = sub.add_parser("list", help="List groups")
        list_parser.add_argument(
            "--verbose",
            dest="verbose",
            default=False,
            action="store_true",
            help="Show all permissions for listed groups.",
        )
Пример #4
0
    def add_arguments(self, parser):
        SubParser = get_sub_parser_class(self)

        sub = parser.add_subparsers(dest="sub_command",
                                    help="Sub commands",
                                    parser_class=SubParser)
        sub.required = True

        # "add" sub-command
        add_parser = sub.add_parser(
            "add",
            help="Add one or more existing device tag(s) to an existing device"
        )
        add_parser.add_argument("hostname", help="Hostname of the device")
        add_parser.add_argument(
            "--tags",
            nargs="*",
            required=False,
            help="List of tags to add to the device",
        )

        # "show" sub-command
        show_parser = sub.add_parser(
            "show", help="Show all device tag(s) for an existing device")
        show_parser.add_argument("hostname", help="Hostname of the device")

        # "list" sub-command
        sub.add_parser("list", help="List all device tag(s)")

        # "remove" sub-command
        remove_parser = sub.add_parser(
            "remove",
            help=
            "Remove one or more existing device tag(s) from an existing device",
        )
        remove_parser.add_argument("hostname", help="Hostname of the device")
        remove_parser.add_argument(
            "--tags",
            nargs="*",
            required=False,
            help="List of tags to remove from the device",
        )

        # "create" sub-command
        create_parser = sub.add_parser("create",
                                       help="Create a new device tag")
        create_parser.add_argument("name", help="Name of the new tag")
        create_parser.add_argument("description",
                                   help="Description of the new tag")
Пример #5
0
Файл: site.py Проект: slawr/lava
    def add_arguments(self, parser):
        SubParser = get_sub_parser_class(self)

        sub = parser.add_subparsers(
            dest="sub_command", help="Sub commands", parser_class=SubParser
        )
        sub.required = True

        list_parser = sub.add_parser("list", help="List the current Site")

        update_parser = sub.add_parser("update", help="Update site properties")
        update_parser.add_argument("--name", type=str, help="Display name of the Site")
        update_parser.add_argument(
            "--domain", type=str, default=None, help="site domain"
        )
Пример #6
0
    def add_arguments(self, parser):
        SubParser = get_sub_parser_class(self)

        sub = parser.add_subparsers(dest="sub_command",
                                    help="Sub commands",
                                    parser_class=SubParser)
        sub.required = True

        add_parser = sub.add_parser("add", help="Create a token")
        add_parser.add_argument("--user",
                                "-u",
                                type=str,
                                required=True,
                                help="The token owner")
        add_parser.add_argument("--description",
                                "-d",
                                type=str,
                                default="",
                                help="The token description")
        add_parser.add_argument("--secret",
                                type=str,
                                default=None,
                                help="The token to import")

        list_parser = sub.add_parser("list", help="List the tokens")
        list_parser.add_argument("--user",
                                 "-u",
                                 type=str,
                                 required=True,
                                 help="The tokens owner")
        list_parser.add_argument("--csv",
                                 dest="csv",
                                 default=False,
                                 action="store_true",
                                 help="Print as csv")

        del_parser = sub.add_parser("rm", help="Remove a token")
        del_parser.add_argument("token", type=str, help="The token to remove")
Пример #7
0
    def add_arguments(self, parser):
        SubParser = get_sub_parser_class(self)

        sub = parser.add_subparsers(
            dest="sub_command", help="Sub commands", parser_class=SubParser
        )
        sub.required = True

        # "add" sub-command
        add_parser = sub.add_parser(
            "add", help="Add V2 device type(s) to the database."
        )
        add_parser.add_argument(
            "device-type",
            help="The device type name. "
            "Passing '*' will add all known V2 device types.",
        )
        alias = add_parser.add_argument_group(
            "alias", "Only supported when creating a single device-type"
        )
        alias.add_argument(
            "--alias", default="", help="Name of an alias for this device-type."
        )
        health = add_parser.add_argument_group(
            "health check", "Only supported when creating a single device-type"
        )
        health.add_argument(
            "--health-frequency", default=24, help="How often to run health checks."
        )
        health.add_argument(
            "--health-denominator",
            default="hours",
            choices=["hours", "jobs"],
            help="Initiate health checks by hours or by jobs.",
        )

        # "update" sub-command
        update_parser = sub.add_parser(
            "update", help="Update an existing V2 device type in the database."
        )
        update_parser.add_argument("device-type", help="The device type name.")
        update_alias = update_parser.add_argument_group("alias")
        update_alias.add_argument(
            "--alias", required=True, help="Name of an alias for this device-type."
        )

        # "details" sub-command
        details_parser = sub.add_parser("details", help="Details about a device-type")
        details_parser.add_argument("name", help="Name of the device-type")
        details_parser.add_argument(
            "--devices",
            action="store_true",
            default=False,
            help="Print the corresponding devices",
        )

        # "list" sub-command
        list_parser = sub.add_parser("list", help="List the installed device types")
        list_parser.add_argument(
            "--all",
            "-a",
            dest="show_all",
            default=False,
            action="store_true",
            help="Show all device types in the database, "
            "including non-installed ones",
        )
        list_parser.add_argument(
            "--csv", dest="csv", default=False, action="store_true", help="Print as csv"
        )
Пример #8
0
    def add_arguments(self, parser):
        SubParser = get_sub_parser_class(self)

        sub = parser.add_subparsers(
            dest="sub_command", help="Sub commands", parser_class=SubParser
        )
        sub.required = True

        # "add" sub-command
        add_parser = sub.add_parser("add", help="Add a device")
        add_parser.add_argument("hostname", help="Hostname of the device")
        add_parser.add_argument("--device-type", required=True, help="Device type")
        add_parser.add_argument(
            "--description", default=None, help="Device description"
        )
        add_parser.add_argument(
            "--offline",
            action="store_false",
            dest="online",
            default=True,
            help="Create the device offline (online by default)",
        )
        add_parser.add_argument(
            "--private",
            action="store_false",
            dest="public",
            default=True,
            help="Make the device private (public by default)",
        )
        add_parser.add_argument(
            "--worker", required=True, help="The name of the worker"
        )
        add_parser.add_argument(
            "--tags",
            nargs="*",
            required=False,
            help="List of tags to add to the device",
        )
        physical = add_parser.add_mutually_exclusive_group()
        physical.add_argument(
            "--physical-user",
            help="Username of the user with physical access to the device",
        )
        physical.add_argument(
            "--physical-group",
            help="Name of the group with physical access to the device",
        )
        owner = add_parser.add_mutually_exclusive_group()
        owner.add_argument(
            "--owner", help="Username of the user with ownership of the device"
        )
        owner.add_argument(
            "--group", help="Name of the group with ownership of the device"
        )

        # "copy" sub-command
        add_parser = sub.add_parser(
            "copy", help="Copy an existing device as a new hostname"
        )
        add_parser.add_argument("original", help="Hostname of the existing device")
        add_parser.add_argument("target", help="Hostname of the device to create")
        add_parser.add_argument(
            "--offline",
            action="store_false",
            dest="online",
            default=True,
            help="Create the device offline (online by default)",
        )
        add_parser.add_argument(
            "--private",
            action="store_false",
            dest="public",
            default=True,
            help="Make the device private (public by default)",
        )
        add_parser.add_argument(
            "--worker", required=True, help="The name of the worker (required)"
        )
        add_parser.add_argument(
            "--copy-with-tags",
            action="store_true",
            dest="copytags",
            default=False,
            help="Set all the tags of the original device on the target device",
        )

        # "details" sub-command
        details_parser = sub.add_parser("details", help="Details about a device")
        details_parser.add_argument("hostname", help="Hostname of the device")

        # "list" sub-command
        list_parser = sub.add_parser("list", help="List the installed devices")
        list_parser.add_argument(
            "--state",
            default=None,
            choices=["IDLE", "RESERVED", "RUNNING"],
            help="Show only devices with the given state",
        )
        health = list_parser.add_mutually_exclusive_group()
        health.add_argument(
            "--all",
            "-a",
            dest="show_all",
            default=None,
            action="store_true",
            help="Show all devices, including retired ones",
        )
        health.add_argument(
            "--health",
            default=None,
            choices=["GOOD", "UNKNOWN", "LOOPING", "BAD", "MAINTENANCE", "RETIRED"],
            help="Show only devices with the given health",
        )
        list_parser.add_argument(
            "--csv", dest="csv", default=False, action="store_true", help="Print as csv"
        )

        # "update" sub-command
        update_parser = sub.add_parser(
            "update", help="Update properties of the given device"
        )
        update_parser.add_argument("hostname", help="Hostname of the device")
        update_parser.add_argument(
            "--description", default=None, help="Set the description"
        )
        update_parser.add_argument(
            "--health",
            default=None,
            choices=["GOOD", "UNKNOWN", "LOOPING", "BAD", "MAINTENANCE", "RETIRED"],
            help="Update the device health",
        )
        update_parser.add_argument("--worker", default=None, help="Update the worker")
        display = update_parser.add_mutually_exclusive_group()
        display.add_argument(
            "--public", default=None, action="store_true", help="make the device public"
        )
        display.add_argument(
            "--private",
            dest="public",
            action="store_false",
            help="Make the device private",
        )
        physical = update_parser.add_mutually_exclusive_group()
        physical.add_argument(
            "--physical-user",
            help="Username of the user with physical access to the device",
        )
        physical.add_argument(
            "--physical-group",
            help="Name of the group with physical access to the device",
        )
        owner = update_parser.add_mutually_exclusive_group()
        owner.add_argument(
            "--owner", help="Username of the user with ownership of the device"
        )
        owner.add_argument(
            "--group",
            dest="group",
            help="Name of the group with ownership of the device",
        )

        # "check" sub-command
        check_parser = sub.add_parser("check", help="Validate device configuration")
        check_devices = check_parser.add_mutually_exclusive_group(required=True)
        check_devices.add_argument(
            "-a", "--all", action="store_true", help="check all devices", default=None
        )
        check_devices.add_argument(
            "hostname", type=str, nargs="*", help="Hostname of the device", default=[]
        )

        # "control" sub-command
        control_parser = sub.add_parser(
            "control", help="Control devices power and serial"
        )
        control_parser.add_argument(
            "-n",
            "--dry-run",
            action="store_true",
            help="Print command instead of running it",
        )
        control_parser.add_argument("hostname", help="Device to control")
        control_parser.add_argument(
            "action",
            choices=("on", "off", "reset", "connect"),
            help="""
            "on" turns the device on;
            "off" turns the device off;
            "reset" hard resets the device;
            "connect" connects to the device serial port
            """,
        )
Пример #9
0
    def add_arguments(self, parser):
        SubParser = get_sub_parser_class(self)

        sub = parser.add_subparsers(dest="sub_command",
                                    help="Sub commands",
                                    parser_class=SubParser)
        sub.required = True

        fail = sub.add_parser(
            "fail",
            help="Force the job status in the database. Keep "
            "in mind that any corresponding lava-run "
            "process will NOT be stopped by this operation.",
        )
        fail.add_argument("job_id", help="job id", type=int)

        list_p = sub.add_parser("list", help="List jobs")
        list_p.add_argument("--lxc",
                            default=False,
                            action="store_true",
                            help="Only list lxc jobs")
        list_p.add_argument(
            "--newer-than",
            default=None,
            type=str,
            help="List jobs newer than this. The time is of the "
            "form: 1h (one hour) or 2d (two days). ",
        )

        list_p.add_argument(
            "--state",
            default=None,
            choices=[
                "SUBMITTED",
                "SCHEDULING",
                "SCHEDULED",
                "RUNNING",
                "CANCELING",
                "FINISHED",
            ],
            help="Filter by job state",
        )
        list_p.add_argument("--submitter",
                            default=None,
                            type=str,
                            help="Filter jobs by submitter")
        list_p.add_argument(
            "--no-submitter",
            default=None,
            type=str,
            help="Filter out jobs by submitter",
        )

        rm = sub.add_parser(
            "rm",
            help="Remove selected jobs. Keep in mind "
            "that v1 bundles won't be removed, "
            "leading to strange behavior when "
            "browsing the bundle pages.",
        )
        rm.add_argument(
            "--older-than",
            default=None,
            type=str,
            help="Remove jobs older than this. The time is of the "
            "form: 1h (one hour) or 2d (two days). "
            "By default, all jobs will be removed.",
        )
        rm.add_argument("--submitter",
                        default=None,
                        type=str,
                        help="Filter jobs by submitter")
        rm.add_argument(
            "--dry-run",
            default=False,
            action="store_true",
            help="Do not remove any data, simulate the output",
        )
        rm.add_argument(
            "--slow",
            default=False,
            action="store_true",
            help="Be nice with the system by sleeping regularly",
        )

        valid = sub.add_parser(
            "validate",
            help=
            "Validate selected historical jobs against the current schema. ",
        )
        valid.add_argument(
            "--mail-admins",
            action="store_true",
            default=False,
            help="Send a mail to the admins with a list of failing jobs",
        )
        valid.add_argument("--submitter",
                           default=None,
                           type=str,
                           help="Filter jobs by submitter")
        valid.add_argument(
            "--newer-than",
            default="1d",
            type=str,
            help="Validate jobs newer than this. The time is of the "
            "form: 1h (one hour) or 2d (two days). "
            "By default, only jobs in the last 24 hours will be validated.",
        )
        valid.add_argument(
            "--strict",
            default=False,
            action="store_true",
            help="If set to True, the validator will reject any extra keys "
            "that are present in the job definition but not defined in the schema",
        )

        comp = sub.add_parser("compress",
                              help="Compress the corresponding job logs")
        comp.add_argument(
            "--newer-than",
            default=None,
            type=str,
            help="Compress jobs newer than this. The time is of the "
            "form: 1h (one hour) or 2d (two days). "
            "By default, all jobs will be compressed.",
        )
        comp.add_argument(
            "--older-than",
            default=None,
            type=str,
            help="Compress jobs older than this. The time is of the "
            "form: 1h (one hour) or 2d (two days). "
            "By default, all jobs logs will be compressed.",
        )
        comp.add_argument("--submitter",
                          default=None,
                          type=str,
                          help="Filter jobs by submitter")
        comp.add_argument(
            "--dry-run",
            default=False,
            action="store_true",
            help="Do not compress any logs, simulate the output",
        )
        comp.add_argument(
            "--slow",
            default=False,
            action="store_true",
            help="Be nice with the system by sleeping regularly",
        )
Пример #10
0
    def add_arguments(self, parser):
        SubParser = get_sub_parser_class(self)

        sub = parser.add_subparsers(dest="sub_command",
                                    help="Sub commands",
                                    parser_class=SubParser)
        sub.required = True

        # "add" sub-command
        add_parser = sub.add_parser("add", help="Add a user")
        add_parser.add_argument("username", help="Username of the user")
        add_parser.add_argument("--email",
                                type=str,
                                default=None,
                                help="email of the user")
        add_parser.add_argument(
            "--passwd",
            type=str,
            default=None,
            help=
            "Password for this user. If empty, a random password is generated.",
        )
        add_parser.add_argument(
            "--staff",
            default=False,
            action="store_true",
            help="Make this user a staff member",
        )
        add_parser.add_argument(
            "--superuser",
            default=False,
            action="store_true",
            help="Make this user a super user",
        )

        # "update" sub-command
        update_parser = sub.add_parser("update",
                                       help="Update an existing user")
        update_parser.add_argument("username", help="Username of the user")
        update_parser.add_argument("--email",
                                   type=str,
                                   default=None,
                                   help="Change email of the user")

        active_parser = update_parser.add_mutually_exclusive_group(
            required=False)
        active_parser.add_argument(
            "--active",
            dest="active",
            action="store_const",
            const=True,  # not a boolean
            help="Make this user active",
        )
        active_parser.add_argument(
            "--not-active",
            dest="active",
            action="store_const",
            const=False,
            help="Make this user inactive",
        )
        active_parser.set_defaults(
            active=None)  # tri-state - None, True, False

        staff_parser = update_parser.add_mutually_exclusive_group(
            required=False)
        staff_parser.add_argument(
            "--staff",
            dest="staff",
            action="store_const",
            const=True,
            help="Make this user a staff member",
        )
        staff_parser.add_argument(
            "--not-staff",
            dest="staff",
            action="store_const",
            const=False,
            help="Make this user no longer a staff member",
        )
        staff_parser.set_defaults(staff=None)

        superuser_parser = update_parser.add_mutually_exclusive_group(
            required=False)
        superuser_parser.add_argument(
            "--superuser",
            dest="superuser",
            action="store_const",
            const=True,
            help="Make this user a superuser",
        )
        superuser_parser.add_argument(
            "--not-superuser",
            dest="superuser",
            action="store_const",
            const=False,
            help="Make this user no longer a superuser",
        )
        superuser_parser.set_defaults(superuser=None)

        # "details" sub-command
        details_parser = sub.add_parser("details", help="User details")
        details_parser.add_argument("username", help="Username of the user")

        # "list" sub-command
        list_parser = sub.add_parser("list", help="List users")
        list_parser.add_argument(
            "--all",
            dest="all",
            default=False,
            action="store_true",
            help="Show all users including inactive ones",
        )
        list_parser.add_argument("--csv",
                                 dest="csv",
                                 default=False,
                                 action="store_true",
                                 help="Print as csv")