mirror of
https://pagure.io/fedora-infra/ansible.git
synced 2026-03-20 03:57:02 +08:00
updates-uptimes: Fix uptimes. Allow list cmds to add extra matches.
Signed-off-by: James Antill <james@and.org>
This commit is contained in:
@@ -107,6 +107,10 @@ conf_suffix_dns_replace = {
|
||||
}
|
||||
_suffix_dns_replace = {}
|
||||
|
||||
# How many days of history do we keep. Note that 1 is the minimum, as today
|
||||
# has to be kept around with the main file.
|
||||
conf_history_keep_def = 16
|
||||
|
||||
# Dir. where we put, and look for, the files...
|
||||
conf_path = "/var/log/"
|
||||
|
||||
@@ -913,10 +917,10 @@ def _usage(short=False):
|
||||
history-keep [days]
|
||||
hosts/-u [host*] [host*]...
|
||||
info [host*] [backup] [backup]...
|
||||
list [host*] [backup]
|
||||
list [host*] [backup] [host*]...
|
||||
list-n [host*] [host*]...
|
||||
old-list duration
|
||||
oslist [os*] [backup]
|
||||
oslist [os*] [backup] [os*]...
|
||||
oslist-n [os*] [os*]...
|
||||
stats [backup] [host*] [host*]...
|
||||
update
|
||||
@@ -940,12 +944,12 @@ def _usage(short=False):
|
||||
= See the history of a host(s).
|
||||
info [host*] [backup] [backup]...
|
||||
= See the current state, in long form, can be filtered by name.
|
||||
list [host*] [backup]
|
||||
list [host*] [backup] [host*]...
|
||||
list-n [host*] [host*]...
|
||||
= See the current state, can be filtered by name.
|
||||
old-list duration
|
||||
= See the current state of hosts with data older than duration.
|
||||
oslist [os*] [backup]
|
||||
oslist [os*] [backup] [os*]...
|
||||
oslist-n [os*] [os*]...
|
||||
= See the current state, can be filtered by OS.
|
||||
|
||||
@@ -1400,8 +1404,8 @@ def _cmd_list(args):
|
||||
hists = []
|
||||
hosts = []
|
||||
osnames = []
|
||||
if hasattr(args, 'hists'):
|
||||
hists = args.hists[:]
|
||||
if hasattr(args, 'hist') and args.hist is not None:
|
||||
hists = [args.hist]
|
||||
if hasattr(args, 'hosts'):
|
||||
hosts = args.hosts[:]
|
||||
if hasattr(args, 'osnames'):
|
||||
@@ -1429,7 +1433,7 @@ def _cmd_uptime(args):
|
||||
if args.dur > 0:
|
||||
age = args.dur
|
||||
|
||||
data = fname1(args.hists[:])
|
||||
data = fname1()
|
||||
if cmd == "uptime-max":
|
||||
data = list(filter_uptime_max_datas(data, age))
|
||||
else:
|
||||
@@ -1733,13 +1737,13 @@ better for this. Kind of like git blame, but instead of lines it's events.
|
||||
""", end='')
|
||||
elif args.hcmd in ("list",):
|
||||
print(f"""\
|
||||
Usage: {prog} {args.hcmd} [host*] [backup]
|
||||
Usage: {prog} {args.hcmd} [host*] [backup] [host*]...
|
||||
|
||||
See the current state of the hosts, can be filtered by name.
|
||||
|
||||
Eg. {prog} {args.hcmd}
|
||||
{prog} {args.hcmd} 'batcave*'
|
||||
{prog} {args.hcmd} 'noc*' yesterday
|
||||
{prog} {args.hcmd} 'noc*' yesterday '*-test.*'
|
||||
""", end='')
|
||||
elif args.hcmd in ("list-n",):
|
||||
print(f"""\
|
||||
@@ -1763,13 +1767,13 @@ better for this. Kind of like git blame, but instead of lines it's events.
|
||||
""", end='')
|
||||
elif args.hcmd in ("oslist",):
|
||||
print(f"""\
|
||||
Usage: {prog} {args.hcmd} [os*] [backup]
|
||||
Usage: {prog} {args.hcmd} [os*] [backup] [os*]...
|
||||
|
||||
See the current state, can be filtered by OS.
|
||||
|
||||
Eg. {prog} {args.hcmd}
|
||||
{prog} {args.hcmd} RedHat
|
||||
{prog} {args.hcmd} 10 yesterday
|
||||
{prog} {args.hcmd} 10 yesterday 41
|
||||
""", end='')
|
||||
elif args.hcmd in ("oslist-n",):
|
||||
print(f"""\
|
||||
@@ -1817,7 +1821,7 @@ better for this. Kind of like git blame, but instead of lines it's events.
|
||||
|
||||
Run update-fast, only for the specified host(s).
|
||||
|
||||
Eg. {prog} {args.hcmd} bat\*
|
||||
Eg. {prog} {args.hcmd} bat\\*
|
||||
""", end='')
|
||||
elif args.hcmd in ("update-daily",):
|
||||
print(f"""\
|
||||
@@ -1935,7 +1939,7 @@ def _main():
|
||||
# history-keep command
|
||||
cmd = subparsers.add_parser("history-keep", help="remove old files")
|
||||
hlp = "number of history files to keep"
|
||||
cmd.add_argument("keep", nargs='?', default=8,
|
||||
cmd.add_argument("keep", nargs='?', default=conf_history_keep_def,
|
||||
type=_cmdline_arg_positive_integer, help=hlp)
|
||||
__defs(func=_cmd_history_keep)
|
||||
|
||||
@@ -1943,13 +1947,16 @@ def _main():
|
||||
hlp = "show host information"
|
||||
cmd = subparsers.add_parser("information", aliases=['info'], help=hlp)
|
||||
cmd.add_argument("host", nargs='?', help="wildcard hostname")
|
||||
cmd.add_argument("hists", nargs='*', type=_cmdline_arg_hist, help="history file")
|
||||
cmd.add_argument("hists", nargs='*',
|
||||
type=_cmdline_arg_hist, help="history file")
|
||||
__defs(func=_cmd_info)
|
||||
|
||||
# list/list-n/old-list/olist/oslist/oslist-n commands
|
||||
cmd = subparsers.add_parser("list", help="list hosts")
|
||||
cmd.add_argument("host", nargs='?', help="wildcard hostname")
|
||||
cmd.add_argument("hists", nargs='*', type=_cmdline_arg_hist, help="history file")
|
||||
cmd.add_argument("hists", nargs='?',
|
||||
type=_cmdline_arg_hist, help="history file")
|
||||
cmd.add_argument("hosts", nargs='*', help="wildcard hostname(s)")
|
||||
__defs(func=_cmd_list)
|
||||
|
||||
cmd = subparsers.add_parser("list-n", help="list hosts")
|
||||
@@ -1963,7 +1970,9 @@ def _main():
|
||||
|
||||
cmd = subparsers.add_parser("oslist", help="list hosts")
|
||||
cmd.add_argument("osname", nargs='?', help="wildcard OSname")
|
||||
cmd.add_argument("hists", nargs='*', type=_cmdline_arg_hist, help="history file")
|
||||
cmd.add_argument("hists", nargs='?',
|
||||
type=_cmdline_arg_hist, help="history file")
|
||||
cmd.add_argument("osnames", nargs='*', help="wildcard OSname(s)")
|
||||
__defs(func=_cmd_list)
|
||||
|
||||
cmd = subparsers.add_parser("oslist-n", help="list hosts")
|
||||
|
||||
Reference in New Issue
Block a user