mirror of
https://github.com/ansible/awx.git
synced 2026-02-05 03:24:50 -03:30
Update code to pull subscriptions from console.redhat.com instead of subscription.rhsm.redhat.com Uses service account client ID and client secret instead of username/password, which is being deprecated in July 2025. Additional changes: - In awx.awx.subscriptions module, use new service account params rather than old basic auth params - Update awx.awx.license module to use subscription_id instead of pool_id. This is due to using a different API, which identifies unique subscriptions by subscriptionID instead of pool ID. Signed-off-by: Seth Foster <fosterbseth@gmail.com> Co-authored-by: Chris Meyers <chris.meyers.fsu@gmail.com> Co-authored-by: Peter Braun <pbraun@redhat.com>
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
import logging
|
|
from django.utils.timezone import now
|
|
from awx.main.utils.encryption import decrypt_field, encrypt_field
|
|
|
|
logger = logging.getLogger('awx.conf.settings')
|
|
|
|
__all__ = ['clear_old_license', 'prefill_rh_credentials']
|
|
|
|
|
|
def clear_old_license(apps, schema_editor):
|
|
Setting = apps.get_model('conf', 'Setting')
|
|
Setting.objects.filter(key='LICENSE').delete()
|
|
|
|
|
|
def _migrate_setting(apps, old_key, new_key, encrypted=False):
|
|
Setting = apps.get_model('conf', 'Setting')
|
|
if not Setting.objects.filter(key=old_key).exists():
|
|
return
|
|
new_setting = Setting.objects.create(key=new_key, created=now(), modified=now())
|
|
if encrypted:
|
|
new_setting.value = decrypt_field(Setting.objects.filter(key=old_key).first(), 'value')
|
|
new_setting.value = encrypt_field(new_setting, 'value')
|
|
else:
|
|
new_setting.value = getattr(Setting.objects.filter(key=old_key).first(), 'value')
|
|
new_setting.save()
|
|
|
|
|
|
def prefill_rh_credentials(apps, schema_editor):
|
|
_migrate_setting(apps, 'REDHAT_USERNAME', 'SUBSCRIPTIONS_CLIENT_ID', encrypted=False)
|
|
_migrate_setting(apps, 'REDHAT_PASSWORD', 'SUBSCRIPTIONS_CLIENT_SECRET', encrypted=True)
|