From 8e66172ed4d420db7223a0916da0003c61940a85 Mon Sep 17 00:00:00 2001 From: "Christian M. Adams" Date: Mon, 30 Nov 2020 10:10:53 -0500 Subject: [PATCH] Remove redundant available_instances field --- awx/main/access.py | 6 +++--- awx/main/analytics/metrics.py | 2 +- awx/main/management/commands/inventory_import.py | 8 ++++---- awx/main/utils/licensing.py | 5 ++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/awx/main/access.py b/awx/main/access.py index 0ecb025d92..89a6c0607d 100644 --- a/awx/main/access.py +++ b/awx/main/access.py @@ -333,14 +333,14 @@ class BaseAccess(object): report_violation(_("License has expired.")) free_instances = validation_info.get('free_instances', 0) - available_instances = validation_info.get('available_instances', 0) + instance_count = validation_info.get('instance_count', 0) if add_host_name: host_exists = Host.objects.filter(name=add_host_name).exists() if not host_exists and free_instances == 0: - report_violation(_("License count of %s instances has been reached.") % available_instances) + report_violation(_("License count of %s instances has been reached.") % instance_count) elif not host_exists and free_instances < 0: - report_violation(_("License count of %s instances has been exceeded.") % available_instances) + report_violation(_("License count of %s instances has been exceeded.") % instance_count) elif not add_host_name and free_instances < 0: report_violation(_("Host count exceeds available instances.")) diff --git a/awx/main/analytics/metrics.py b/awx/main/analytics/metrics.py index 9346de0a80..20bf8ae830 100644 --- a/awx/main/analytics/metrics.py +++ b/awx/main/analytics/metrics.py @@ -68,7 +68,7 @@ def metrics(): 'external_logger_type': getattr(settings, 'LOG_AGGREGATOR_TYPE', 'None') }) - LICENSE_INSTANCE_TOTAL.set(str(license_info.get('available_instances', 0))) + LICENSE_INSTANCE_TOTAL.set(str(license_info.get('instance_count', 0))) LICENSE_INSTANCE_FREE.set(str(license_info.get('free_instances', 0))) current_counts = counts(None) diff --git a/awx/main/management/commands/inventory_import.py b/awx/main/management/commands/inventory_import.py index 2179faad6b..30529cdf72 100644 --- a/awx/main/management/commands/inventory_import.py +++ b/awx/main/management/commands/inventory_import.py @@ -57,11 +57,11 @@ No license. See http://www.ansible.com/renew for license information.''' LICENSE_MESSAGE = '''\ -Number of licensed instances exceeded, would bring available instances to %(new_count)d, system is licensed for %(available_instances)d. +Number of licensed instances exceeded, would bring available instances to %(new_count)d, system is licensed for %(instance_count)d. See http://www.ansible.com/renew for license extension information.''' DEMO_LICENSE_MESSAGE = '''\ -Demo mode free license count exceeded, would bring available instances to %(new_count)d, demo mode allows %(available_instances)d. +Demo mode free license count exceeded, would bring available instances to %(new_count)d, demo mode allows %(instance_count)d. See http://www.ansible.com/renew for licensing information.''' @@ -856,7 +856,7 @@ class Command(BaseCommand): raise PermissionDenied('No license found!') elif local_license_type == 'open': return - available_instances = license_info.get('available_instances', 0) + instance_count = license_info.get('instance_count', 0) free_instances = license_info.get('free_instances', 0) time_remaining = license_info.get('time_remaining', 0) hard_error = license_info.get('trial', False) is True or license_info['instance_count'] == 10 @@ -877,7 +877,7 @@ class Command(BaseCommand): if free_instances < 0: d = { 'new_count': new_count, - 'available_instances': available_instances, + 'instance_count': instance_count, } if hard_error: logger.error(LICENSE_MESSAGE % d) diff --git a/awx/main/utils/licensing.py b/awx/main/utils/licensing.py index 3956460337..7150983ad6 100644 --- a/awx/main/utils/licensing.py +++ b/awx/main/utils/licensing.py @@ -419,10 +419,9 @@ class Licenser(object): current_instances = Host.objects.active_count() else: current_instances = 0 - available_instances = int(attrs.get('instance_count', None) or 0) + instance_count = int(attrs.get('instance_count', 0)) attrs['current_instances'] = current_instances - attrs['available_instances'] = available_instances - free_instances = (available_instances - current_instances) + free_instances = (instance_count - current_instances) attrs['free_instances'] = max(0, free_instances) license_date = int(attrs.get('license_date', 0) or 0)