From 0b31e771b17da18b5b92d4f10b81c893bbbefb04 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Wed, 17 Mar 2021 14:01:32 -0400 Subject: [PATCH] Fix the gather_analytics management command Previously, invoking the command with neither of the --ship or --dry-run flags would result in effectively doing a dry run. With the stricter checks now in place in analytics.core.gather, let's make sure that we pass the 'dry-run' parameter in to gather() in the no-flags case. --- awx/main/analytics/core.py | 2 +- awx/main/management/commands/gather_analytics.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/awx/main/analytics/core.py b/awx/main/analytics/core.py index ff878cf624..4077730408 100644 --- a/awx/main/analytics/core.py +++ b/awx/main/analytics/core.py @@ -135,7 +135,7 @@ def gather(dest=None, module=None, subset=None, since=None, until=None, collecti return None if not (settings.AUTOMATION_ANALYTICS_URL and settings.REDHAT_USERNAME and settings.REDHAT_PASSWORD): - logger.log(log_level, "Not gathering analytics, configuration is invalid") + logger.log(log_level, "Not gathering analytics, configuration is invalid. Use --dry-run to gather locally without sending.") return None with advisory_lock('gather_analytics_lock', wait=False) as acquired: diff --git a/awx/main/management/commands/gather_analytics.py b/awx/main/management/commands/gather_analytics.py index 25fffb4dec..cb5506103e 100644 --- a/awx/main/management/commands/gather_analytics.py +++ b/awx/main/management/commands/gather_analytics.py @@ -48,7 +48,8 @@ class Command(BaseCommand): if opt_ship and opt_dry_run: self.logger.error('Both --ship and --dry-run cannot be processed at the same time.') return - tgzfiles = analytics.gather(collection_type='manual' if not opt_dry_run else 'dry-run', since=since, until=until) + tgzfiles = analytics.gather(collection_type='manual' if opt_ship else 'dry-run', + since=since, until=until) if tgzfiles: for tgz in tgzfiles: self.logger.info(tgz)