From bc5ef7f1c8f3485d7ce20c37b268efcf15a94872 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Wed, 15 Jan 2020 10:05:20 -0500 Subject: [PATCH] Only warn when license is exceeded non-fatally --- .../management/commands/inventory_import.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/awx/main/management/commands/inventory_import.py b/awx/main/management/commands/inventory_import.py index 7bd60e3402..dd1b8f3eca 100644 --- a/awx/main/management/commands/inventory_import.py +++ b/awx/main/management/commands/inventory_import.py @@ -921,11 +921,14 @@ class Command(BaseCommand): available_instances = license_info.get('available_instances', 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 new_count = Host.objects.active_count() - if time_remaining <= 0 and not license_info.get('demo', False): - logger.error(LICENSE_EXPIRED_MESSAGE) - if license_info.get('trial', False) is True: + if time_remaining <= 0: + if hard_error: + logger.error(LICENSE_EXPIRED_MESSAGE) raise CommandError("License has expired!") + else: + logger.warning(LICENSE_EXPIRED_MESSAGE) # special check for tower-type inventory sources # but only if running the plugin TOWER_SOURCE_FILES = ['tower.yml', 'tower.yaml'] @@ -938,15 +941,11 @@ class Command(BaseCommand): 'new_count': new_count, 'available_instances': available_instances, } - if license_info.get('demo', False): - logger.error(DEMO_LICENSE_MESSAGE % d) - else: + if hard_error: logger.error(LICENSE_MESSAGE % d) - if ( - license_info.get('trial', False) is True or - license_info['instance_count'] == 10 # basic 10 license - ): raise CommandError('License count exceeded!') + else: + logger.warning(LICENSE_MESSAGE % d) def check_org_host_limit(self): license_info = get_licenser().validate()