mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-15 07:48:38 -05:00
Handle inventory types where Automation Hub collection names differ
Move imports added by Bill to be in-line, because utils should not import models at top Remove more get_licenser inline imports
This commit is contained in:
@@ -11,3 +11,4 @@ from awx.main.utils.encryption import ( # noqa
|
||||
decrypt_value,
|
||||
encrypt_dict,
|
||||
)
|
||||
from awx.main.utils.licensing import get_licenser # noqa
|
||||
|
||||
@@ -51,7 +51,6 @@ __all__ = [
|
||||
'underscore_to_camelcase',
|
||||
'memoize',
|
||||
'memoize_delete',
|
||||
'get_licenser',
|
||||
'get_awx_http_client_headers',
|
||||
'get_awx_version',
|
||||
'update_scm_url',
|
||||
@@ -255,18 +254,6 @@ def get_awx_http_client_headers():
|
||||
return headers
|
||||
|
||||
|
||||
def get_licenser(*args, **kwargs):
|
||||
from awx.main.utils.licensing import Licenser, OpenLicense
|
||||
|
||||
try:
|
||||
if os.path.exists('/var/lib/awx/.tower_version'):
|
||||
return Licenser(*args, **kwargs)
|
||||
else:
|
||||
return OpenLicense()
|
||||
except Exception as e:
|
||||
raise ValueError(_('Error importing License: %s') % e)
|
||||
|
||||
|
||||
def update_scm_url(scm_type, url, username=True, password=True, check_special_cases=True, scp_format=False):
|
||||
"""
|
||||
Update the given SCM URL to add/replace/remove the username/password. When
|
||||
|
||||
@@ -15,6 +15,7 @@ from datetime import datetime, timezone
|
||||
import collections
|
||||
import copy
|
||||
import io
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
@@ -34,8 +35,6 @@ from cryptography import x509
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
# AWX
|
||||
from awx.main.models import Host, HostMetric, Instance
|
||||
|
||||
MAX_INSTANCES = 9999999
|
||||
|
||||
@@ -379,10 +378,9 @@ class Licenser(object):
|
||||
return attrs
|
||||
attrs['valid_key'] = True
|
||||
|
||||
if Host:
|
||||
current_instances = Host.objects.active_count()
|
||||
else:
|
||||
current_instances = 0
|
||||
from awx.main.models import Host, HostMetric, Instance
|
||||
|
||||
current_instances = Host.objects.active_count()
|
||||
license_date = int(attrs.get('license_date', 0) or 0)
|
||||
automated_instances = HostMetric.objects.count()
|
||||
first_host = HostMetric.objects.only('first_automation').order_by('first_automation').first()
|
||||
@@ -408,3 +406,19 @@ class Licenser(object):
|
||||
attrs['date_warning'] = bool(time_remaining < self.SUBSCRIPTION_TIMEOUT)
|
||||
attrs['date_expired'] = bool(time_remaining <= 0)
|
||||
return attrs
|
||||
|
||||
|
||||
def get_licenser(*args, **kwargs):
|
||||
from awx.main.utils.licensing import Licenser, OpenLicense
|
||||
|
||||
try:
|
||||
if os.path.exists('/var/lib/awx/.tower_version'):
|
||||
return Licenser(*args, **kwargs)
|
||||
else:
|
||||
return OpenLicense()
|
||||
except Exception as e:
|
||||
raise ValueError(_('Error importing License: %s') % e)
|
||||
|
||||
|
||||
def server_product_name():
|
||||
return 'AWX' if isinstance(get_licenser(), OpenLicense) else 'Red Hat Ansible Automation Platform'
|
||||
|
||||
Reference in New Issue
Block a user