diff --git a/awx/api/views/root.py b/awx/api/views/root.py index 6a64ea8a77..a933da7582 100644 --- a/awx/api/views/root.py +++ b/awx/api/views/root.py @@ -358,8 +358,6 @@ class ApiV2ConfigView(APIView): return Response({"error": 'Invalid license submitted.'}, status=status.HTTP_400_BAD_REQUEST) try: - # Validate entitlement cert and get subscription metadata - # validate() will clear the entitlement cert if not valid license_data_validated = get_licenser().license_from_manifest(license_data) except Exception: logger.warning(smart_text(u"Invalid license submitted."), @@ -379,11 +377,9 @@ class ApiV2ConfigView(APIView): return Response({"error": _("Invalid license")}, status=status.HTTP_400_BAD_REQUEST) def delete(self, request): - # Clear license and entitlement certificate try: settings.LICENSE = {} return Response(status=status.HTTP_204_NO_CONTENT) except Exception: # FIX: Log return Response({"error": _("Failed to remove license.")}, status=status.HTTP_400_BAD_REQUEST) - diff --git a/awx/conf/migrations/_subscriptions.py b/awx/conf/migrations/_subscriptions.py index b28c8dd195..1ec1aa1052 100644 --- a/awx/conf/migrations/_subscriptions.py +++ b/awx/conf/migrations/_subscriptions.py @@ -2,16 +2,11 @@ import logging from django.conf import settings -from awx.main.utils.licensing import Licenser - logger = logging.getLogger('awx.conf.settings') __all__ = ['clear_old_license'] def clear_old_license(apps, schema_editor): - # Setting = apps.get_model('conf', 'Organization') - # setting.objects.filter(key=LICENSE) - licenser = Licenser() - if licenser._check_product_cert(): - settings.LICENSE = licenser.UNLICENSED_DATA.copy() + Setting = apps.get_model('conf', 'Setting') + Setting.objects.filter(key='LICENSE').delete() diff --git a/awx/main/tests/functional/core/test_licenses.py b/awx/main/tests/functional/core/test_licenses.py deleted file mode 100644 index ba8b1ff9af..0000000000 --- a/awx/main/tests/functional/core/test_licenses.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2015 Ansible, Inc. -# All Rights Reserved. - -# from awx.main.utils.common import StubLicense -# -# -# def test_stub_license(): -# license_actual = StubLicense().validate() -# assert license_actual['license_key'] == 'OPEN' -# assert license_actual['valid_key'] -# assert license_actual['compliant'] -# assert license_actual['license_type'] == 'open' - - - -# Test license_date is always seconds diff --git a/awx/main/utils/common.py b/awx/main/utils/common.py index f628d8f831..cc2c78976d 100644 --- a/awx/main/utils/common.py +++ b/awx/main/utils/common.py @@ -201,7 +201,6 @@ def get_awx_http_client_headers(): return headers -# Update all references of this function in the codebase to just import `from awx.main.utils.licensing import Licenser` directly def get_licenser(*args, **kwargs): try: # Get License Config from db? diff --git a/awx/main/utils/licensing.py b/awx/main/utils/licensing.py index 87641d7bbb..08bddcf02d 100644 --- a/awx/main/utils/licensing.py +++ b/awx/main/utils/licensing.py @@ -97,7 +97,7 @@ class Licenser(object): if 'company_name' in kwargs: kwargs.pop('company_name') self._attrs.update(kwargs) - if self._check_product_cert(): + if os.path.exists('/var/lib/awx/.tower_version'): if 'license_key' in self._attrs: self._unset_attrs() if 'valid_key' in self._attrs: @@ -109,14 +109,6 @@ class Licenser(object): self._generate_open_config() - def _check_product_cert(self): - # Product Cert Name: ansible-tower-3.7-rhel-7.x86_64.pem - # Maybe check validity of Product Cert somehow? - if os.path.exists('/etc/tower/certs') and os.path.exists('/var/lib/awx/.tower_version'): - return True - return False - - def _generate_open_config(self): self._attrs.update(dict(license_type='open', valid_key=True, @@ -130,11 +122,6 @@ class Licenser(object): self._attrs = self.UNLICENSED_DATA.copy() - def _clear_license_setting(self): - self.unset_attrs() - settings.LICENSE = {} - - def license_from_manifest(self, manifest): # Parse output for subscription metadata to build config license = dict()