mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
reimplement licensing to work with RHSM and entitlement uploads
Co-authored-by: Christian Adams <chadams@redhat.com>
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
# Copyright (c) 2016 Ansible, Inc.
|
||||
# All Rights Reserved.
|
||||
|
||||
|
||||
__all__ = ['get_license']
|
||||
|
||||
|
||||
def _get_validated_license_data():
|
||||
from awx.main.utils.common import get_licenser
|
||||
return get_licenser().validate()
|
||||
from awx.main.utils.licensing import Licenser
|
||||
return Licenser().validate(new_cert=False)
|
||||
|
||||
|
||||
def get_license(show_key=False):
|
||||
def get_license():
|
||||
"""Return a dictionary representing the active license on this Tower instance."""
|
||||
license_data = _get_validated_license_data()
|
||||
if not show_key:
|
||||
license_data.pop('license_key', None)
|
||||
return license_data
|
||||
return _get_validated_license_data()
|
||||
|
||||
20
awx/conf/migrations/0008_subscriptions.py
Normal file
20
awx/conf/migrations/0008_subscriptions.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Generated by Django 2.2.11 on 2020-08-04 15:19
|
||||
|
||||
import logging
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
from awx.conf.migrations import _subscriptions as subscriptions
|
||||
|
||||
logger = logging.getLogger('awx.conf.migrations')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('conf', '0007_v380_rename_more_settings'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(subscriptions.clear_old_license),
|
||||
]
|
||||
17
awx/conf/migrations/_subscriptions.py
Normal file
17
awx/conf/migrations/_subscriptions.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
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()
|
||||
@@ -78,14 +78,6 @@ class Setting(CreatedModifiedModel):
|
||||
def get_cache_id_key(self, key):
|
||||
return '{}_ID'.format(key)
|
||||
|
||||
def display_value(self):
|
||||
if self.key == 'LICENSE' and 'license_key' in self.value:
|
||||
# don't log the license key in activity stream
|
||||
value = self.value.copy()
|
||||
value['license_key'] = '********'
|
||||
return value
|
||||
return self.value
|
||||
|
||||
|
||||
import awx.conf.signals # noqa
|
||||
|
||||
|
||||
Reference in New Issue
Block a user