From 8ec6e556a116d72c6d691848208b4422cfbbfb39 Mon Sep 17 00:00:00 2001 From: Martin Slemr Date: Wed, 22 Mar 2023 11:31:12 +0100 Subject: [PATCH] HostMetricSummaryMonthly API commented out --- .../api/host_metric_summary_monthly_list.md | 12 ------------ awx/api/urls/urls.py | 5 +++-- awx/api/views/__init__.py | 19 ++++++++++--------- awx/api/views/root.py | 3 ++- awx/main/conf.py | 2 +- awx/main/management/commands/host_metric.py | 2 +- awx/main/utils/licensing.py | 4 ++-- awx/settings/defaults.py | 1 - 8 files changed, 19 insertions(+), 29 deletions(-) delete mode 100644 awx/api/templates/api/host_metric_summary_monthly_list.md diff --git a/awx/api/templates/api/host_metric_summary_monthly_list.md b/awx/api/templates/api/host_metric_summary_monthly_list.md deleted file mode 100644 index 953b1827a6..0000000000 --- a/awx/api/templates/api/host_metric_summary_monthly_list.md +++ /dev/null @@ -1,12 +0,0 @@ -# Intended Use Case - -To get summaries from a certain day or earlier, you can filter this -endpoint in the following way. - - ?date__gte=2023-01-01 - -This will return summaries that were produced on that date or later. -These host metric monthly summaries should be automatically produced -by a background task that runs once each month. - -{% include "api/list_api_view.md" %} diff --git a/awx/api/urls/urls.py b/awx/api/urls/urls.py index c7d73165c3..9eafb51d64 100644 --- a/awx/api/urls/urls.py +++ b/awx/api/urls/urls.py @@ -30,7 +30,7 @@ from awx.api.views import ( OAuth2TokenList, ApplicationOAuth2TokenList, OAuth2ApplicationDetail, - HostMetricSummaryMonthlyList, + # HostMetricSummaryMonthlyList, # It will be enabled in future version of the AWX ) from awx.api.views.bulk import ( @@ -121,7 +121,8 @@ v2_urls = [ re_path(r'^inventories/', include(inventory_urls)), re_path(r'^hosts/', include(host_urls)), re_path(r'^host_metrics/', include(host_metric_urls)), - re_path(r'^host_metric_summary_monthly/$', HostMetricSummaryMonthlyList.as_view(), name='host_metric_summary_monthly_list'), + # It will be enabled in future version of the AWX + # re_path(r'^host_metric_summary_monthly/$', HostMetricSummaryMonthlyList.as_view(), name='host_metric_summary_monthly_list'), re_path(r'^groups/', include(group_urls)), re_path(r'^inventory_sources/', include(inventory_source_urls)), re_path(r'^inventory_updates/', include(inventory_update_urls)), diff --git a/awx/api/views/__init__.py b/awx/api/views/__init__.py index a9f2e0ce25..c1e99a4002 100644 --- a/awx/api/views/__init__.py +++ b/awx/api/views/__init__.py @@ -1570,15 +1570,16 @@ class HostMetricDetail(RetrieveDestroyAPIView): return Response(status=status.HTTP_204_NO_CONTENT) -class HostMetricSummaryMonthlyList(ListAPIView): - name = _("Host Metrics Summary Monthly") - model = models.HostMetricSummaryMonthly - serializer_class = serializers.HostMetricSummaryMonthlySerializer - permission_classes = (IsSystemAdminOrAuditor,) - search_fields = ('date',) - - def get_queryset(self): - return self.model.objects.all() +# It will be enabled in future version of the AWX +# class HostMetricSummaryMonthlyList(ListAPIView): +# name = _("Host Metrics Summary Monthly") +# model = models.HostMetricSummaryMonthly +# serializer_class = serializers.HostMetricSummaryMonthlySerializer +# permission_classes = (IsSystemAdminOrAuditor,) +# search_fields = ('date',) +# +# def get_queryset(self): +# return self.model.objects.all() class HostList(HostRelatedSearchMixin, ListCreateAPIView): diff --git a/awx/api/views/root.py b/awx/api/views/root.py index f343d8169d..be4d9cc44b 100644 --- a/awx/api/views/root.py +++ b/awx/api/views/root.py @@ -103,7 +103,8 @@ class ApiVersionRootView(APIView): data['groups'] = reverse('api:group_list', request=request) data['hosts'] = reverse('api:host_list', request=request) data['host_metrics'] = reverse('api:host_metric_list', request=request) - data['host_metric_summary_monthly'] = reverse('api:host_metric_summary_monthly_list', request=request) + # It will be enabled in future version of the AWX + # data['host_metric_summary_monthly'] = reverse('api:host_metric_summary_monthly_list', request=request) data['job_templates'] = reverse('api:job_template_list', request=request) data['jobs'] = reverse('api:job_list', request=request) data['ad_hoc_commands'] = reverse('api:ad_hoc_command_list', request=request) diff --git a/awx/main/conf.py b/awx/main/conf.py index f983b26a31..33b3b4714d 100644 --- a/awx/main/conf.py +++ b/awx/main/conf.py @@ -809,7 +809,7 @@ register( 'SUBSCRIPTION_USAGE_MODEL', field_class=fields.ChoiceField, choices=[ - ('', _('Default model for AWX - no subscription')), + ('', _('Default model for AWX - no subscription. Deletion of host_metrics will not be considered for purposes of managed host counting')), ( SUBSCRIPTION_USAGE_MODEL_UNIQUE_HOSTS, _('Usage based on unique managed nodes in a large historical time frame and delete functionality for no longer used managed nodes'), diff --git a/awx/main/management/commands/host_metric.py b/awx/main/management/commands/host_metric.py index a0933b7fb9..1d76d634b7 100644 --- a/awx/main/management/commands/host_metric.py +++ b/awx/main/management/commands/host_metric.py @@ -227,7 +227,7 @@ class Command(BaseCommand): # --json flag is not set, output in plain text else: - print(f"Printing up to {BATCHED_FETCH_COUNT } automated hosts:") + print(f"Printing up to {BATCHED_FETCH_COUNT} automated hosts:") result = HostMetric.objects.filter(**filter_kwargs) list_of_queryset = self.host_metric_queryset(result, 0, BATCHED_FETCH_COUNT) for item in list_of_queryset: diff --git a/awx/main/utils/licensing.py b/awx/main/utils/licensing.py index 62c0deb56a..b3ea7723e5 100644 --- a/awx/main/utils/licensing.py +++ b/awx/main/utils/licensing.py @@ -384,8 +384,8 @@ class Licenser(object): current_instances = Host.objects.active_count() license_date = int(attrs.get('license_date', 0) or 0) - model = getattr(settings, 'SUBSCRIPTION_USAGE_MODEL', '') - if model == SUBSCRIPTION_USAGE_MODEL_UNIQUE_HOSTS: + subscription_model = getattr(settings, 'SUBSCRIPTION_USAGE_MODEL', '') + if subscription_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: diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index 23d61a98a0..f3b6c18eef 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -1032,5 +1032,4 @@ 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 = ''