def _cmdline_setup(arg_subparser): ap = arg_subparser.add_parser("images-ls", help="List supported image types") commonl.argparser_add_aka(arg_subparser, "images-ls", "images-list") ap.add_argument("target", metavar="TARGET", action="store", default=None, help="Target name") ap.set_defaults(func=_cmdline_images_list) ap = arg_subparser.add_parser( "images-flash", help="(maybe upload) and flash images in the target") ap.add_argument("target", metavar="TARGET", action="store", default=None, help="Target's name or URL") ap.add_argument("images", metavar="TYPE:FILENAME", action="store", default=None, nargs='+', help="Each FILENAME is (maybe uploaded to the daemon)" " and then set as an image of the given TYPE;" " FILENAME is assumed to be present in the server's" " storage area (unless -u is given)") ap.add_argument("-u", "--upload", action="store_true", default=False, help="upload FILENAME first and then flash") ap.add_argument("-s", "--soft", action="store_true", default=False, help="soft flash (only flash if the file's" " signature is different to the last one flashed)") ap.add_argument("-t", "--timeout", action="store", default=None, type=int, help="timeout in seconds [default taken from" " what the server declares or 1m if none]") ap.set_defaults(func=_cmdline_images_flash)
def _cmdline_setup(arg_subparsers): ap = arg_subparsers.add_parser("store-upload", help = "Upload a local file to the server") ap.add_argument("target", metavar = "TARGET", action = "store", default = None, help = "Target name") ap.add_argument("remote_filename", action = "store", help = "Path to remote file file (defaults to same as " \ "local). Note the file will be stored in a user"\ " specific area") ap.add_argument("local_filename", action = "store", help = "Path to local file to upload") ap.set_defaults(func = _cmdline_store_upload) ap = arg_subparsers.add_parser("store-dnload", help = "Download a file from the server") ap.add_argument("target", metavar = "TARGET", action = "store", default = None, help = "Target name") ap.add_argument("remote_filename", action = "store", help = "Path to remote file name in user's store") ap.add_argument("local_filename", action = "store", help = "Path to where to store the file locally") ap.set_defaults(func = _cmdline_store_dnload) ap = arg_subparsers.add_parser("store-rm", help = "Delete a file from the server") commonl.argparser_add_aka(arg_subparsers, "store-rm", "store-del") commonl.argparser_add_aka(arg_subparsers, "store-rm", "store-delete") ap.add_argument("target", metavar = "TARGET", action = "store", default = None, help = "Target name") ap.add_argument("remote_filename", action = "store", help = "Path to remote file to delete") ap.set_defaults(func = _cmdline_store_delete) ap = arg_subparsers.add_parser("store-ls", help = "List files stored in the server") ap.add_argument("target", metavar = "TARGET", action = "store", default = None, help = "Target name") ap.set_defaults(func = _cmdline_store_list)
def cmdline_setup(argsp): ap = argsp.add_parser("tunnel-add", help = "create an IP tunnel") ap.add_argument("target", metavar = "TARGET", action = "store", type = str, default = None, help = "Target's name or URL") ap.add_argument("port", metavar = "PORT", action = "store", type = int, help = "Port to tunnel to") ap.add_argument("protocol", metavar = "PROTOCOL", action = "store", nargs = "?", default = None, type = str, help = "Protocol to tunnel {tcp,udp,sctp}[{4,6}] " "(defaults to TCPv4)") ap.add_argument("ip_addr", metavar = "IP-ADDR", action = "store", nargs = "?", default = None, type = str, help = "target's IP address to tunnel to " "(default is the first IP address the target declares)") ap.set_defaults(func = _cmdline_tunnel_add) ap = argsp.add_parser("tunnel-rm", help = "remove an existing IP tunnel") commonl.argparser_add_aka(argsp, "tunnel-rm", "tunnel-remove") commonl.argparser_add_aka(argsp, "tunnel-rm", "tunnel-delete") ap.add_argument("target", metavar = "TARGET", action = "store", type = str, default = None, help = "Target's name or URL") ap.add_argument("port", metavar = "PORT", action = "store", type = int, help = "Port to tunnel to") ap.add_argument("protocol", metavar = "PROTOCOL", action = "store", nargs = "?", default = None, help = "Protocol to tunnel {tcp,udp,sctp}[{4,6}] " "(defaults to tcp and to IPv4)") ap.add_argument("ip_addr", metavar = "IP-ADDR", action = "store", nargs = "?", default = None, help = "target's IP address to tunnel to " "(default is the first IP address the target declares)") ap.set_defaults(func = _cmdline_tunnel_remove) ap = argsp.add_parser("tunnel-ls", help = "List existing IP tunnels") ap.add_argument("target", metavar = "TARGET", action = "store", type = str, default = None, help = "Target's name or URL") ap.set_defaults(func = _cmdline_tunnel_list)
def _cmdline_setup(arg_subparsers): ap = arg_subparsers.add_parser("store-upload", help="Upload a local file to the server") ap.add_argument("target", metavar="TARGET", action="store", default=None, help="Target name") ap.add_argument("remote_filename", action = "store", help = "Path to remote file file (defaults to same as " \ "local). Note the file will be stored in a user"\ " specific area") ap.add_argument("local_filename", action="store", help="Path to local file to upload") ap.set_defaults(func=_cmdline_store_upload) ap = arg_subparsers.add_parser("store-dnload", help="Download a file from the server") ap.add_argument("target", metavar="TARGET", action="store", default=None, help="Target name") ap.add_argument("remote_filename", action="store", help="Path to remote file name in user's store") ap.add_argument("local_filename", action="store", help="Path to where to store the file locally") ap.set_defaults(func=_cmdline_store_dnload) ap = arg_subparsers.add_parser("store-rm", help="Delete a file from the server") commonl.argparser_add_aka(arg_subparsers, "store-rm", "store-del") commonl.argparser_add_aka(arg_subparsers, "store-rm", "store-delete") ap.add_argument("target", metavar="TARGET", action="store", default=None, help="Target name") ap.add_argument("remote_filename", action="store", help="Path to remote file to delete") ap.set_defaults(func=_cmdline_store_delete) ap = arg_subparsers.add_parser("store-ls", help="List files stored in the server") ap.add_argument("-v", dest="verbosity", action="count", default=1, help="Increase verbosity of information to display " "(-v is a table , " "-vv hierarchical, -vvv Python format, -vvvv JSON format)") ap.add_argument( "-q", dest="quietosity", action="count", default=0, help="Decrease verbosity of information to display " "(none is a table, -q list of shortname, url and username, " "-qq the hostnames, -qqq the shortnames" "; all one per line") ap.add_argument("target", metavar="TARGET", action="store", default=None, help="Target name") ap.add_argument("--path", metavar="PATH", action="store", default=None, help="Path to list") ap.add_argument("--digest", action="store", default=None, help="Digest to use" " (zero, md5, sha256 [default], sha512)") ap.add_argument("filename", nargs="*", action="store", default=[], help="Files to list (defaults to all)") ap.set_defaults(func=_cmdline_store_list)
def _cmdline_setup(arg_subparser): ap = arg_subparser.add_parser("images-ls", help="List supported image types") commonl.argparser_add_aka(arg_subparser, "images-ls", "images-list") ap.add_argument("target", metavar="TARGET", action="store", default=None, help="Target name") ap.set_defaults(func=_cmdline_images_list) ap = arg_subparser.add_parser( "images-flash", help="(maybe upload) and flash images in the target") ap.add_argument("target", metavar="TARGET", action="store", default=None, help="Target's name or URL") ap.add_argument("images", metavar="[TYPE:]FILENAME", action="store", default=None, nargs='+', help="Each FILENAME is (maybe uploaded to the daemon)" " and then set as an image of the given TYPE;" " FILENAME is assumed to be present in the server's" " storage area (unless -u is given);" " TYPE can be omitted if the file name starts with" " the name of an image (eg: ~/place/bios-433 would" " be flashed into 'bios' if the target exposes the" " 'bios' flash destination)." " Note filenames can contain %(FIELD)s strings" " that will be expanded from the inventory.") ap.add_argument("-u", "--upload", action="store_true", default=False, help="upload FILENAME first and then flash") ap.add_argument("-s", "--soft", action="store_true", default=False, help="soft flash (only flash if the file's" " signature is different to the last one flashed)") ap.add_argument("-t", "--timeout", action="store", default=None, type=int, help="timeout in seconds [default taken from" " what the server declares or 1m if none]") ap.set_defaults(func=_cmdline_images_flash) ap = arg_subparser.add_parser("images-read", help="Read image from the target") ap.add_argument("target", metavar="TARGET", action="store", default=None, help="Target's name") ap.add_argument("image", metavar="TYPE", action="store", default=None, help="Image we are reading from") ap.add_argument("filename", metavar="FILENAME", action="store", default=None, help="File to create and write to") ap.add_argument("-o", "--offset", action="store", default=0, type=int, help="Base offset from 0 bytes to read from") ap.add_argument("-b", "--bytes", action="store", default=None, type=int, help="Bytes to read from the image" " (Defaults to reading the whole image)") ap.set_defaults(func=_cmdline_images_read)
def _cmdline_setup(arg_subparsers): ap = arg_subparsers.add_parser( "user-ls", help="List users known to the server (note you need " "admin role privilege to list users others than your own)") ap.add_argument("userid", action="store", default=None, nargs="*", help="Users to list (default all)") ap.add_argument("-v", dest="verbosity", action="count", default=0, help="Increase verbosity of information to display " "(none is a table, -v table with more details, " "-vv hierarchical, -vvv Python format, -vvvv JSON format)") ap.set_defaults(func=_cmdline_user_list) ap = arg_subparsers.add_parser("logout", help="Log user out of the servers brokers") ap.add_argument( "username", nargs='?', action="store", default=None, help="User to logout (defaults to current); to logout others " "*admin* role is needed") ap.set_defaults(func=_cmdline_logout) ap = arg_subparsers.add_parser( "role-gain", help="Gain access to a role which has been dropped") ap.add_argument("-u", "--username", action="store", default="self", help="ID of user whose role is to be dropped" " (optional, defaults to yourself)") ap.add_argument("role", action="store", help="Role to gain") ap.set_defaults(func=_cmdline_role_gain) ap = arg_subparsers.add_parser("role-drop", help="Drop access to a role") ap.add_argument("-u", "--username", action="store", default="self", help="ID of user whose role is to be dropped" " (optional, defaults to yourself)") ap.add_argument("role", action="store", help="Role to drop") ap.set_defaults(func=_cmdline_role_drop) ap = arg_subparsers.add_parser("servers", help="List configured/discovered servers") commonl.argparser_add_aka(arg_subparsers, "servers", "server-ls") ap.add_argument( "-q", dest="quietosity", action="count", default=0, help="Decrease verbosity of information to display " "(none is a table, -q list of shortname, url and username, " "-qq the hostnames, -qqq the shortnames" "; all one per line") ap.add_argument("-v", dest="verbosity", action="count", default=1, help="Increase verbosity of information to display " "(none is a table, -v table with more details, " "-vv hierarchical, -vvv Python format, -vvvv JSON format)") ap.add_argument("targets", metavar="TARGETNAMES", nargs="*", action="store", default=None, help="List of targets for which we want to find server" " information (optional; defaults to all)") ap.set_defaults(func=_cmdline_servers) ap = arg_subparsers.add_parser("servers-flush", help="Flush currently cached/known servers") ap.set_defaults(func=_cmdline_servers_flush) ap = arg_subparsers.add_parser("servers-discover", help="Discover servers") ap.add_argument( "-q", dest="quietosity", action="count", default=0, help="Decrease verbosity of information to display " "(none is a table, -q list of shortname, url and username, " "-qq the hostnames, -qqq the shortnames" "; all one per line") ap.add_argument("-v", dest="verbosity", action="count", default=1, help="Increase verbosity of progress info [%(default)d] ") ap.add_argument("--iterations", "-e", type=int, metavar="MAX_LOOPS", action="store", default=10, help="Maximum number of iterations [%(default)d]") ap.add_argument( "--zero-strikes-max", "-z", type=int, metavar="MAX", action="store", default=4, help="Stop after this many iterations [%(default)d] finding" " no new servers") ap.add_argument("--flush", "-f", action='store_true', default=False, help="Flush existing cached entries before") ap.add_argument("--ssl-ignore", "-s", action='store_false', default=True, help="Default to ignore SSL validation [False]") ap.add_argument("--port", "-p", action='store', type=int, default=5000, help="Default port when none specified %(default)s") ap.add_argument("--herd-exclude", "-x", metavar="HERDNAME", action='append', default=[], help="Exclude herd (can be given multiple times)") ap.add_argument("--herd-include", "-i", metavar="HERDNAME", action='append', default=[], help="Include herd (can be given multiple times)") ap.add_argument("items", metavar="HOSTNAME|URL", nargs="*", action="store", default=[], help="List of URLs or hostnames to seed discovery" f" [{' '.join(tcfl.server_c._seed_default.keys())}]") ap.set_defaults(func=_cmdline_servers_discover)
def _cmdline_setup(arg_subparsers): ap = arg_subparsers.add_parser( "user-ls", help="List users known to the server (note you need " "admin role privilege to list users others than your own)") ap.add_argument("userid", action="store", default=None, nargs="*", help="Users to list (default all)") ap.add_argument("-v", dest="verbosity", action="count", default=0, help="Increase verbosity of information to display " "(none is a table, -v table with more details, " "-vv hierarchical, -vvv Python format, -vvvv JSON format)") ap.set_defaults(func=_cmdline_user_list) ap = arg_subparsers.add_parser("logout", help="Log user out of the servers brokers") ap.add_argument( "username", nargs='?', action="store", default=None, help="User to logout (defaults to current); to logout others " "*admin* role is needed") ap.set_defaults(func=_cmdline_logout) ap = arg_subparsers.add_parser( "role-gain", help="Gain access to a role which has been dropped") ap.add_argument("-u", "--username", action="store", default="self", help="ID of user whose role is to be dropped" " (optional, defaults to yourself)") ap.add_argument("role", action="store", help="Role to gain") ap.set_defaults(func=_cmdline_role_gain) ap = arg_subparsers.add_parser("role-drop", help="Drop access to a role") ap.add_argument("-u", "--username", action="store", default="self", help="ID of user whose role is to be dropped" " (optional, defaults to yourself)") ap.add_argument("role", action="store", help="Role to drop") ap.set_defaults(func=_cmdline_role_drop) ap = arg_subparsers.add_parser("servers", help="List configured servers") commonl.argparser_add_aka(arg_subparsers, "servers", "server-ls") ap.add_argument( "-q", dest="quietosity", action="count", default=0, help="Decrease verbosity of information to display " "(none is a table, -q list of shortname, url and username, " "-qq the hostnames, -qqq the shortnames" "; all one per line") ap.add_argument("-v", dest="verbosity", action="count", default=1, help="Increase verbosity of information to display " "(none is a table, -v table with more details, " "-vv hierarchical, -vvv Python format, -vvvv JSON format)") ap.add_argument("targets", metavar="TARGETNAMES", nargs="*", action="store", default=None, help="List of targets for which we want to find server" " information (optional; defaults to all)") ap.set_defaults(func=_cmdline_servers)
def _cmdline_setup(arg_subparsers): ap = arg_subparsers.add_parser("alloc-targets", help="Allocate targets for exclusive use") commonl.argparser_add_aka(arg_subparsers, "alloc-targets", "acquire") ap.add_argument("-a", "--all", action="store_true", default=False, help="Consider also disabled targets") ap.add_argument( "-r", "--reason", action="store", # use instead of getfqdn(), since it does a DNS lookup and can # slow things a lot default="cmdline %s@%s:%d" % (getpass.getuser(), socket.gethostname(), os.getppid()), help="Reason to pass to the server (default: %(default)s)" " [LOGNAME:HOSTNAME:PARENTPID]") ap.add_argument( "--hold", action="store_const", const=0, dest="hold", default=None, help="Keep the reservation alive until cancelled with Ctrl-C") ap.add_argument("-d", "--hold-for", dest="hold", action="store", nargs="?", type=int, default=None, help="Keep the reservation alive for this many seconds, " "then release it") ap.add_argument("-w", "--wait", action="store_true", dest='queue', default=True, help="(default) Wait until targets are assigned") ap.add_argument("--dont-wait", action="store_false", dest='wait_in_queue', default=True, help="Do not wait until targets are assigned") ap.add_argument("-i", "--inmediate", action="store_false", dest='queue', help="Fail if target's can't be allocated inmediately") ap.add_argument("-p", "--priority", action="store", type=int, default=500, help="Priority (0 highest, 999 lowest)") ap.add_argument("-o", "--obo", action="store", default=None, help="User to alloc on behalf of") ap.add_argument("--preempt", action="store_true", default=False, help="Enable preemption (disabled by default)") ap.add_argument("target", metavar="TARGETSPEC", nargs="+", action="store", default=None, help="Target's names, all in the same server") ap.set_defaults(func=_cmdline_alloc_targets) ap = arg_subparsers.add_parser( "alloc-monitor", help="Monitor the allocations current in the system") ap.add_argument("-a", "--all", action="store_true", default=False, help="Consider also disabled targets") ap.add_argument( "target", metavar="TARGETSPEC", nargs="*", action="store", default=None, help="Target's names or a general target specification " "which might include values of tags, etc, in single quotes (eg: " "'zephyr_board and not type:\"^qemu.*\"'") ap.set_defaults(func=_cmdline_alloc_monitor) ap = arg_subparsers.add_parser( "alloc-ls", help="List information about current allocations " "in all the servers or the servers where the named " "targets are") commonl.argparser_add_aka(arg_subparsers, "alloc-ls", "alloc-list") ap.add_argument( "-q", dest="quietosity", action="count", default=0, help="Decrease verbosity of information to display " "(none is a table, -q or more just the list of allocations," " one per line") ap.add_argument("-v", dest="verbosity", action="count", default=0, help="Increase verbosity of information to display " "(none is a table, -v table with more details, " "-vv hierarchical, -vvv Python format, -vvvv JSON format)") ap.add_argument("-a", "--all", action="store_true", default=False, help="Consider also disabled targets") ap.add_argument("-u", "--username", action="store", default=None, help="ID of user whose allocs are to be displayed" " (optional, defaults to anyone visible)") ap.add_argument("-r", "--refresh", action="store", type=float, nargs="?", const=1, default=0, help="Repeat every int seconds (by default, only once)") ap.add_argument( "target", metavar="TARGETSPEC", nargs="*", action="store", default=None, help="Target's names or a general target specification " "which might include values of tags, etc, in single quotes (eg: " "'zephyr_board and not type:\"^qemu.*\"'") ap.set_defaults(func=_cmdline_alloc_ls) ap = arg_subparsers.add_parser( "alloc-rm", help="Delete an existing allocation (which might be " "in any state; any targets allocated to said allocation " "will be released") commonl.argparser_add_aka(arg_subparsers, "alloc-rm", "alloc-del") commonl.argparser_add_aka(arg_subparsers, "alloc-rm", "alloc-delete") ap.add_argument("allocid", metavar="[SERVER/]ALLOCATIONID", nargs="+", action="store", default=None, help="Allocation IDs to remove") ap.set_defaults(func=_cmdline_alloc_delete) ap = arg_subparsers.add_parser("guest-add", help="Add a guest to an allocation") ap.add_argument("allocid", metavar="[SERVER/]ALLOCATIONID", action="store", default=None, help="Allocation IDs to which to add guest to") ap.add_argument("guests", metavar="USERNAME", nargs="+", action="store", default=None, help="Name of guest to add") ap.set_defaults(func=_cmdline_guest_add) ap = arg_subparsers.add_parser("guest-ls", help="list guests in an allocation") ap.add_argument("allocid", metavar="[SERVER/]ALLOCATIONID", action="store", default=None, help="Allocation IDs to which to add guest to") ap.set_defaults(func=_cmdline_guest_list) ap = arg_subparsers.add_parser("guest-rm", help="Remove a guest from an allocation") commonl.argparser_add_aka(arg_subparsers, "guest-rm", "guest-remove") ap.add_argument("allocid", metavar="[SERVER/]ALLOCATIONID", action="store", default=None, help="Allocation IDs to which to add guest to") ap.add_argument("guests", metavar="USERNAME", nargs="*", action="store", default=None, help="Name of guest to remove (all if none given)") ap.set_defaults(func=_cmdline_guest_remove)