mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 12:20:45 -03:30
Compliance computation settings
This commit is contained in:
parent
7285d82f00
commit
9badbf0b4e
@ -10,7 +10,7 @@ from rest_framework import serializers
|
||||
# AWX
|
||||
from awx.conf import fields, register, register_validate
|
||||
from awx.main.models import ExecutionEnvironment
|
||||
|
||||
from awx.main.constants import SUBSCRIPTION_USAGE_MODEL_UNIQUE_HOSTS, SUBSCRIPTION_USAGE_MODEL_UNIQUE_HOSTS_MONTHLY
|
||||
|
||||
logger = logging.getLogger('awx.main.conf')
|
||||
|
||||
@ -805,6 +805,17 @@ register(
|
||||
category_slug='system',
|
||||
)
|
||||
|
||||
register(
|
||||
'SUBSCRIPTION_USAGE_MODEL',
|
||||
field_class=fields.ChoiceField,
|
||||
choices=[SUBSCRIPTION_USAGE_MODEL_UNIQUE_HOSTS, SUBSCRIPTION_USAGE_MODEL_UNIQUE_HOSTS_MONTHLY],
|
||||
default='',
|
||||
allow_blank=True,
|
||||
label=_('Defines subscription usage model and shows Host Metrics'),
|
||||
category=_('System'),
|
||||
category_slug='system',
|
||||
)
|
||||
|
||||
|
||||
def logging_validate(serializer, attrs):
|
||||
if not serializer.instance or not hasattr(serializer.instance, 'LOG_AGGREGATOR_HOST') or not hasattr(serializer.instance, 'LOG_AGGREGATOR_TYPE'):
|
||||
|
||||
@ -106,3 +106,7 @@ JOB_VARIABLE_PREFIXES = [
|
||||
ANSIBLE_RUNNER_NEEDS_UPDATE_MESSAGE = (
|
||||
'\u001b[31m \u001b[1m This can be caused if the version of ansible-runner in your execution environment is out of date.\u001b[0m'
|
||||
)
|
||||
|
||||
# Values for setting SUBSCRIPTION_USAGE_MODEL
|
||||
SUBSCRIPTION_USAGE_MODEL_UNIQUE_HOSTS = 'unique_managed_hosts'
|
||||
SUBSCRIPTION_USAGE_MODEL_UNIQUE_HOSTS_MONTHLY = 'unique_managed_hosts_monthly'
|
||||
|
||||
@ -35,6 +35,7 @@ from cryptography import x509
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from awx.main.constants import SUBSCRIPTION_USAGE_MODEL_UNIQUE_HOSTS
|
||||
|
||||
MAX_INSTANCES = 9999999
|
||||
|
||||
@ -382,8 +383,15 @@ class Licenser(object):
|
||||
|
||||
current_instances = Host.objects.active_count()
|
||||
license_date = int(attrs.get('license_date', 0) or 0)
|
||||
automated_instances = HostMetric.active_objects.count()
|
||||
first_host = HostMetric.active_objects.only('first_automation').order_by('first_automation').first()
|
||||
|
||||
model = getattr(settings, 'SUBSCRIPTION_USAGE_MODEL', '')
|
||||
if model == SUBSCRIPTION_USAGE_MODEL_UNIQUE_HOSTS:
|
||||
automated_instances = HostMetric.active_objects.count()
|
||||
first_host = HostMetric.active_objects.only('first_automation').order_by('first_automation').first()
|
||||
else:
|
||||
automated_instances = HostMetric.objects.count()
|
||||
first_host = HostMetric.objects.only('first_automation').order_by('first_automation').first()
|
||||
|
||||
if first_host:
|
||||
automated_since = int(first_host.first_automation.timestamp())
|
||||
else:
|
||||
|
||||
@ -1028,3 +1028,9 @@ AWX_MOUNT_ISOLATED_PATHS_ON_K8S = False
|
||||
CLUSTER_HOST_ID = socket.gethostname()
|
||||
|
||||
UI_NEXT = True
|
||||
|
||||
# License compliance for total host count. Possible values:
|
||||
# - '': No model - Subscription not counted from Host Metrics
|
||||
# - 'unique_managed_hosts': Compliant = automated - deleted hosts (using /api/v2/host_metrics/)
|
||||
# - 'unique_managed_hosts_monthly': TBD: AoC on Azure (now equal to '')
|
||||
SUBSCRIPTION_USAGE_MODEL = ''
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user