django-admin faults: show/reset api auth faults counter

This commit is contained in:
Thomas Waldmann 2019-04-09 12:08:00 +02:00
parent 974af1e72d
commit b8daf1a8ef

View File

@ -60,6 +60,11 @@ class Command(BaseCommand):
dest='show_client', dest='show_client',
default=False, default=False,
help='show client fault counters') help='show client fault counters')
parser.add_argument('--show-api-auth',
action='store_true',
dest='show_api_auth',
default=False,
help='show api auth fault counters')
parser.add_argument('--reset-server', parser.add_argument('--reset-server',
action='store_true', action='store_true',
dest='reset_server', dest='reset_server',
@ -70,6 +75,11 @@ class Command(BaseCommand):
dest='reset_client', dest='reset_client',
default=False, default=False,
help='reset the client fault counters of all hosts') help='reset the client fault counters of all hosts')
parser.add_argument('--reset-api-auth',
action='store_true',
dest='reset_api_auth',
default=False,
help='reset the api auth fault counters of all hosts')
parser.add_argument('--reset-abuse', parser.add_argument('--reset-abuse',
action='store_true', action='store_true',
dest='reset_abuse', dest='reset_abuse',
@ -100,8 +110,10 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
show_client = options['show_client'] show_client = options['show_client']
show_server = options['show_server'] show_server = options['show_server']
show_api_auth = options['show_api_auth']
reset_client = options['reset_client'] reset_client = options['reset_client']
reset_server = options['reset_server'] reset_server = options['reset_server']
reset_api_auth = options['reset_api_auth']
reset_available = options['reset_available'] reset_available = options['reset_available']
reset_abuse = options['reset_abuse'] reset_abuse = options['reset_abuse']
reset_abuse_blocked = options['reset_abuse_blocked'] reset_abuse_blocked = options['reset_abuse_blocked']
@ -116,9 +128,11 @@ class Command(BaseCommand):
output += u"%-6d " % h.client_faults output += u"%-6d " % h.client_faults
if show_server: if show_server:
output += u"%-6d " % h.server_faults output += u"%-6d " % h.server_faults
if show_api_auth:
output += u"%-6d " % h.api_auth_faults
output += u"%s %s\n" % (h.created_by.username, h.get_fqdn(),) output += u"%s %s\n" % (h.created_by.username, h.get_fqdn(),)
self.stdout.write(output) self.stdout.write(output)
if (flag_abuse is not None or reset_client or reset_server or if (flag_abuse is not None or reset_client or reset_server or reset_api_auth or
reset_available or reset_abuse or reset_abuse_blocked): reset_available or reset_abuse or reset_abuse_blocked):
if flag_abuse is not None: if flag_abuse is not None:
if h.client_faults > flag_abuse: if h.client_faults > flag_abuse:
@ -144,6 +158,8 @@ class Command(BaseCommand):
h.client_faults = 0 h.client_faults = 0
if reset_server: if reset_server:
h.server_faults = 0 h.server_faults = 0
if reset_api_auth:
h.api_auth_faults = 0
if reset_available: if reset_available:
h.available = True h.available = True
if reset_abuse: if reset_abuse: