mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-13 01:58:35 -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:
@@ -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