Fix an issue where an unlicensed system would throw errors

In the case where the license was entirely not present but the tower
license module was present
This commit is contained in:
Matthew Jones
2017-07-14 10:20:53 -04:00
parent f5bbccf0cd
commit 891f26c850
4 changed files with 4 additions and 4 deletions

View File

@@ -279,7 +279,7 @@ class ApiV1ConfigView(APIView):
license_info=license_data, license_info=license_data,
version=get_awx_version(), version=get_awx_version(),
ansible_version=get_ansible_version(), ansible_version=get_ansible_version(),
eula=render_to_string("eula.md") if license_data['license_type'] != 'open' else '', eula=render_to_string("eula.md") if license_data.get('license_type', 'UNLICENSED') != 'open' else '',
analytics_status=pendo_state analytics_status=pendo_state
) )

View File

@@ -43,7 +43,7 @@ def get_licensed_features():
def feature_enabled(name): def feature_enabled(name):
"""Return True if the requested feature is enabled, False otherwise.""" """Return True if the requested feature is enabled, False otherwise."""
validated_license_data = _get_validated_license_data() validated_license_data = _get_validated_license_data()
if validated_license_data['license_type'] == 'open': if validated_license_data.get('license_type', 'UNLICENSED') == 'open':
return True return True
return validated_license_data.get('features', {}).get(name, False) return validated_license_data.get('features', {}).get(name, False)

View File

@@ -254,7 +254,7 @@ class BaseAccess(object):
def check_license(self, add_host_name=None, feature=None, check_expiration=True): def check_license(self, add_host_name=None, feature=None, check_expiration=True):
validation_info = get_licenser().validate() validation_info = get_licenser().validate()
if validation_info['license_type'] == 'open': if validation_info.get('license_type', 'UNLICENSED') == 'open':
return return
if ('test' in sys.argv or 'py.test' in sys.argv[0] or 'jenkins' in sys.argv) and not os.environ.get('SKIP_LICENSE_FIXUP_FOR_TEST', ''): if ('test' in sys.argv or 'py.test' in sys.argv[0] or 'jenkins' in sys.argv) and not os.environ.get('SKIP_LICENSE_FIXUP_FOR_TEST', ''):

View File

@@ -852,7 +852,7 @@ class Command(NoArgsCommand):
if license_info.get('license_key', 'UNLICENSED') == 'UNLICENSED': if license_info.get('license_key', 'UNLICENSED') == 'UNLICENSED':
logger.error(LICENSE_NON_EXISTANT_MESSAGE) logger.error(LICENSE_NON_EXISTANT_MESSAGE)
raise CommandError('No license found!') raise CommandError('No license found!')
elif license_info['license_type'] == 'open': elif license_info('license_type', 'UNLICENSED') == 'open':
return return
available_instances = license_info.get('available_instances', 0) available_instances = license_info.get('available_instances', 0)
free_instances = license_info.get('free_instances', 0) free_instances = license_info.get('free_instances', 0)