Switch out existing obfuscated license with external module

This creates a new fallback license module called StubLicense that
will be used in the event that the tower_license module is not
installed.

All existing license mechanisms are routed through the get_licenser()
util method
This commit is contained in:
Matthew Jones
2017-07-11 12:01:24 -04:00
parent 7fda3c0658
commit 8486944eaa
13 changed files with 83 additions and 45 deletions

View File

@@ -8,7 +8,7 @@ from django.utils.translation import ugettext_lazy as _
from rest_framework.exceptions import APIException
# Tower
from awx.main.task_engine import TaskEnhancer
from awx.main.utils.common import get_licenser
__all__ = ['LicenseForbids', 'get_license', 'get_licensed_features',
'feature_enabled', 'feature_exists']
@@ -20,7 +20,7 @@ class LicenseForbids(APIException):
def _get_validated_license_data():
return TaskEnhancer().validate_enhancements()
return get_licenser().validate()
def get_license(show_key=False):
@@ -42,7 +42,10 @@ def get_licensed_features():
def feature_enabled(name):
"""Return True if the requested feature is enabled, False otherwise."""
return _get_validated_license_data().get('features', {}).get(name, False)
validated_license_data = _get_validated_license_data()
if validated_license_data['license_type'] == 'open':
return True
return validated_license_data.get('features', {}).get(name, False)
def feature_exists(name):