mirror of
https://github.com/ansible/awx.git
synced 2026-03-05 02:31:03 -03:30
Merge pull request #8721 from rooftopcellist/remove_available_instance
Remove redundant available_instances field Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -333,14 +333,14 @@ class BaseAccess(object):
|
|||||||
report_violation(_("License has expired."))
|
report_violation(_("License has expired."))
|
||||||
|
|
||||||
free_instances = validation_info.get('free_instances', 0)
|
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:
|
if add_host_name:
|
||||||
host_exists = Host.objects.filter(name=add_host_name).exists()
|
host_exists = Host.objects.filter(name=add_host_name).exists()
|
||||||
if not host_exists and free_instances == 0:
|
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:
|
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:
|
elif not add_host_name and free_instances < 0:
|
||||||
report_violation(_("Host count exceeds available instances."))
|
report_violation(_("Host count exceeds available instances."))
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ def metrics():
|
|||||||
'external_logger_type': getattr(settings, 'LOG_AGGREGATOR_TYPE', 'None')
|
'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)))
|
LICENSE_INSTANCE_FREE.set(str(license_info.get('free_instances', 0)))
|
||||||
|
|
||||||
current_counts = counts(None)
|
current_counts = counts(None)
|
||||||
|
|||||||
@@ -57,11 +57,11 @@ No license.
|
|||||||
See http://www.ansible.com/renew for license information.'''
|
See http://www.ansible.com/renew for license information.'''
|
||||||
|
|
||||||
LICENSE_MESSAGE = '''\
|
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.'''
|
See http://www.ansible.com/renew for license extension information.'''
|
||||||
|
|
||||||
DEMO_LICENSE_MESSAGE = '''\
|
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.'''
|
See http://www.ansible.com/renew for licensing information.'''
|
||||||
|
|
||||||
|
|
||||||
@@ -856,7 +856,7 @@ class Command(BaseCommand):
|
|||||||
raise PermissionDenied('No license found!')
|
raise PermissionDenied('No license found!')
|
||||||
elif local_license_type == 'open':
|
elif local_license_type == 'open':
|
||||||
return
|
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)
|
free_instances = license_info.get('free_instances', 0)
|
||||||
time_remaining = license_info.get('time_remaining', 0)
|
time_remaining = license_info.get('time_remaining', 0)
|
||||||
hard_error = license_info.get('trial', False) is True or license_info['instance_count'] == 10
|
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:
|
if free_instances < 0:
|
||||||
d = {
|
d = {
|
||||||
'new_count': new_count,
|
'new_count': new_count,
|
||||||
'available_instances': available_instances,
|
'instance_count': instance_count,
|
||||||
}
|
}
|
||||||
if hard_error:
|
if hard_error:
|
||||||
logger.error(LICENSE_MESSAGE % d)
|
logger.error(LICENSE_MESSAGE % d)
|
||||||
|
|||||||
@@ -419,10 +419,9 @@ class Licenser(object):
|
|||||||
current_instances = Host.objects.active_count()
|
current_instances = Host.objects.active_count()
|
||||||
else:
|
else:
|
||||||
current_instances = 0
|
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['current_instances'] = current_instances
|
||||||
attrs['available_instances'] = available_instances
|
free_instances = (instance_count - current_instances)
|
||||||
free_instances = (available_instances - current_instances)
|
|
||||||
attrs['free_instances'] = max(0, free_instances)
|
attrs['free_instances'] = max(0, free_instances)
|
||||||
|
|
||||||
license_date = int(attrs.get('license_date', 0) or 0)
|
license_date = int(attrs.get('license_date', 0) or 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user