mirror of
https://pagure.io/fedora-infra/ansible.git
synced 2026-03-20 03:57:02 +08:00
updates+uptimes: Minor UI changes, mostly --history
Signed-off-by: James Antill <james@and.org>
This commit is contained in:
@@ -1022,17 +1022,17 @@ def _usage(short=False):
|
||||
info [host*] [backup] [backup]...
|
||||
= See the current state, in long form, can be filtered by name.
|
||||
list [host*]...
|
||||
--hist backup
|
||||
--history backup
|
||||
--osnames os*
|
||||
= 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*]...
|
||||
--hist backup
|
||||
--history backup
|
||||
= See the current state, can be filtered by OS.
|
||||
|
||||
stats [host*]...
|
||||
--hist backup
|
||||
--history backup
|
||||
= Show general stats.
|
||||
|
||||
update
|
||||
@@ -1191,6 +1191,11 @@ def _cmd_history(args):
|
||||
last_data = list(filter_osname_datas(last_data, args.osnames))
|
||||
last_suff = ""
|
||||
|
||||
# Do this early, so if "not conf_fast_width_history" then we don't do
|
||||
# things we don't need to do.
|
||||
if conf_hist_show > 0 and conf_hist_show < len(backups):
|
||||
backups = backups[-conf_hist_show:]
|
||||
|
||||
hl, ul, rl = _hist_lengths()
|
||||
|
||||
print('', _ui_t_title("Day", 10), _ui_t_title("Hosts", hl),
|
||||
@@ -1198,9 +1203,6 @@ def _cmd_history(args):
|
||||
'', _ui_t_title("Added", ul), _ui_t_title("Inst.", ul+1), '',
|
||||
_ui_t_title("Boots", rl))
|
||||
|
||||
if conf_hist_show > 0 and conf_hist_show < len(backups):
|
||||
backups = backups[-conf_hist_show:]
|
||||
|
||||
for backup in reversed(backups):
|
||||
data = list(sorted(lines2datas(bfname2lines(backup))))
|
||||
data = list(filter_name_datas(data, args.hosts))
|
||||
@@ -1754,6 +1756,7 @@ def _cmd_host(args):
|
||||
|
||||
_max_update(last_data)
|
||||
if not conf_fast_width_history:
|
||||
# Would be a lot faster if we could exit early here, but it's difficult
|
||||
for backup in hbackups:
|
||||
data = filter_name_datas(lines2datas(bfname2lines(backup)), hosts)
|
||||
data = list(sorted(data))
|
||||
@@ -2023,7 +2026,7 @@ utf8: {conf_utf8}
|
||||
elif _eq_cmd("list"):
|
||||
print(f"""\
|
||||
Usage: {prog} {args.hcmd} [host*] [host*]...
|
||||
{' '*len(prog)} {' '*len(args.hcmd)} --hist backup
|
||||
{' '*len(prog)} {' '*len(args.hcmd)} --history backup
|
||||
{' '*len(prog)} {' '*len(args.hcmd)} --osnames os*
|
||||
|
||||
See the current state of the hosts, can be filtered by name.
|
||||
@@ -2052,7 +2055,7 @@ utf8: {conf_utf8}
|
||||
elif _eq_cmd("oslist"):
|
||||
print(f"""\
|
||||
Usage: {prog} {args.hcmd} [os*] [os*]...
|
||||
{' '*len(prog)} {' '*len(args.hcmd)} --hist backup
|
||||
{' '*len(prog)} {' '*len(args.hcmd)} --history backup
|
||||
|
||||
See the current state, can be filtered by OS.
|
||||
|
||||
@@ -2060,13 +2063,13 @@ utf8: {conf_utf8}
|
||||
Eg. {prog} {args.hcmd}
|
||||
{prog} {args.hcmd} RedHat
|
||||
{prog} {args.hcmd} F 10
|
||||
{prog} {args.hcmd} 10 --hist yesterday 41
|
||||
{prog} {args.hcmd} 10 --history yesterday 41
|
||||
""", end='')
|
||||
|
||||
elif _eq_cmd("statistics"):
|
||||
print(f"""\
|
||||
Usage: {prog} {args.hcmd} [backup] [host*] [host*]...
|
||||
{' '*len(prog)} {' '*len(args.hcmd)} --hist backup
|
||||
{' '*len(prog)} {' '*len(args.hcmd)} --history backup
|
||||
|
||||
Show general statistics.
|
||||
|
||||
@@ -2074,7 +2077,7 @@ utf8: {conf_utf8}
|
||||
|
||||
{_hlp_als("statistics")}
|
||||
Eg. {prog} {args.hcmd}
|
||||
{prog} {args.hcmd} --host yesterday
|
||||
{prog} {args.hcmd} --history yesterday
|
||||
{prog} {args.hcmd} '*.stg.*' '*-test.*'
|
||||
""", end='')
|
||||
|
||||
@@ -2264,7 +2267,7 @@ def _main():
|
||||
# list/list-n/old-list/olist/oslist/oslist-n commands
|
||||
cmd = subparsers.add_parser("list", help="list hosts")
|
||||
cmd.add_argument("--osnames", action='append', default=[], help="wildcard OSname(s)")
|
||||
cmd.add_argument("--hist",
|
||||
cmd.add_argument("--history", dest="hist",
|
||||
type=_cmdline_arg_hist, help="history file")
|
||||
cmd.add_argument("hosts", nargs='*', help="wildcard hostname(s)")
|
||||
__defs(func=_cmd_list)
|
||||
@@ -2277,7 +2280,7 @@ def _main():
|
||||
__defs(func=_cmd_list)
|
||||
|
||||
cmd = subparsers.add_parser("oslist", help="list hosts")
|
||||
cmd.add_argument("--hist",
|
||||
cmd.add_argument("--history", dest="hist",
|
||||
type=_cmdline_arg_hist, help="history file")
|
||||
cmd.add_argument("osnames", nargs='*', help="wildcard OSname(s)")
|
||||
__defs(func=_cmd_list)
|
||||
@@ -2285,8 +2288,8 @@ def _main():
|
||||
# stats commands
|
||||
hlp = "show stats information"
|
||||
cmd = subparsers.add_parser("statistics", aliases=['stats'], help=hlp)
|
||||
cmd.add_argument("--hist", type=_cmdline_arg_hist, default="main",
|
||||
help="history file")
|
||||
cmd.add_argument("--history", dest="hist", type=_cmdline_arg_hist,
|
||||
default="main", help="history file")
|
||||
cmd.add_argument("hosts", nargs='*', help="wildcard hostname(s)")
|
||||
__defs(func=_cmd_stats)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user