mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
cleanup up some unused code/comments, and simplify the license migration
This commit is contained in:
parent
ef43d85271
commit
3bb930c769
@ -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)
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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
|
||||
@ -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?
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user