mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 17:28:51 -03:30
changes to license compliance
now if a license is expired or over the managed node limit, it won't prevent host creation or Job/JobTemplate launches see: https://github.com/ansible/ansible-tower/issues/7860
This commit is contained in:
@@ -308,7 +308,7 @@ class BaseAccess(object):
|
|||||||
if check_expiration and validation_info.get('time_remaining', None) is None:
|
if check_expiration and validation_info.get('time_remaining', None) is None:
|
||||||
raise PermissionDenied(_("License is missing."))
|
raise PermissionDenied(_("License is missing."))
|
||||||
if check_expiration and validation_info.get("grace_period_remaining") <= 0:
|
if check_expiration and validation_info.get("grace_period_remaining") <= 0:
|
||||||
raise PermissionDenied(_("License has expired."))
|
logger.error(_("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)
|
available_instances = validation_info.get('available_instances', 0)
|
||||||
@@ -316,11 +316,11 @@ class BaseAccess(object):
|
|||||||
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:
|
||||||
raise PermissionDenied(_("License count of %s instances has been reached.") % available_instances)
|
logger.error(_("License count of %s instances has been reached.") % available_instances)
|
||||||
elif not host_exists and free_instances < 0:
|
elif not host_exists and free_instances < 0:
|
||||||
raise PermissionDenied(_("License count of %s instances has been exceeded.") % available_instances)
|
logger.error(_("License count of %s instances has been exceeded.") % available_instances)
|
||||||
elif not add_host_name and free_instances < 0:
|
elif not add_host_name and free_instances < 0:
|
||||||
raise PermissionDenied(_("Host count exceeds available instances."))
|
raise logger.error(_("Host count exceeds available instances."))
|
||||||
|
|
||||||
if feature is not None:
|
if feature is not None:
|
||||||
if "features" in validation_info and not validation_info["features"].get(feature, False):
|
if "features" in validation_info and not validation_info["features"].get(feature, False):
|
||||||
|
|||||||
@@ -904,7 +904,6 @@ class Command(BaseCommand):
|
|||||||
new_count = Host.objects.active_count()
|
new_count = Host.objects.active_count()
|
||||||
if time_remaining <= 0 and not license_info.get('demo', False):
|
if time_remaining <= 0 and not license_info.get('demo', False):
|
||||||
logger.error(LICENSE_EXPIRED_MESSAGE)
|
logger.error(LICENSE_EXPIRED_MESSAGE)
|
||||||
raise CommandError("License has expired!")
|
|
||||||
if free_instances < 0:
|
if free_instances < 0:
|
||||||
d = {
|
d = {
|
||||||
'new_count': new_count,
|
'new_count': new_count,
|
||||||
@@ -914,7 +913,6 @@ class Command(BaseCommand):
|
|||||||
logger.error(DEMO_LICENSE_MESSAGE % d)
|
logger.error(DEMO_LICENSE_MESSAGE % d)
|
||||||
else:
|
else:
|
||||||
logger.error(LICENSE_MESSAGE % d)
|
logger.error(LICENSE_MESSAGE % d)
|
||||||
raise CommandError('License count exceeded!')
|
|
||||||
|
|
||||||
def mark_license_failure(self, save=True):
|
def mark_license_failure(self, save=True):
|
||||||
self.inventory_update.license_error = True
|
self.inventory_update.license_error = True
|
||||||
|
|||||||
Reference in New Issue
Block a user