From b88892be49dca2db9d7a16e2696f6da6cedeb9b1 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 23 Feb 2016 12:33:30 -0500 Subject: [PATCH] Sanity check and force proper types in admin check --- awx/main/tasks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 4b51893a98..58e5425866 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -95,7 +95,9 @@ def run_administrative_checks(self): return reader = TaskSerializer() validation_info = reader.from_database() - used_percentage = validation_info.get('current_instances',0) / validation_info.get('instance_count', 100) + if validation_info.get('instance_count', 0) < 1: + return + used_percentage = float(validation_info.get('current_instances', 0)) / float(validation_info.get('instance_count', 100)) tower_admin_emails = User.objects.filter(is_superuser=True).values_list('email', flat=True) if (used_percentage * 100) > 90: send_mail("Ansible Tower host usage over 90%",