mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 22:19:28 -02:30
Add a --dry-run option to gather analytics locally, even if analytics is disabled in settings.
This commit is contained in:
@@ -88,8 +88,8 @@ def gather(dest=None, module=None, collection_type='scheduled'):
|
|||||||
logger.exception("Invalid License provided, or No License Provided")
|
logger.exception("Invalid License provided, or No License Provided")
|
||||||
return "Error: Invalid License provided, or No License Provided"
|
return "Error: Invalid License provided, or No License Provided"
|
||||||
|
|
||||||
if not settings.INSIGHTS_TRACKING_STATE:
|
if collection_type != 'dry-run' and not settings.INSIGHTS_TRACKING_STATE:
|
||||||
logger.error("Automation Analytics not enabled")
|
logger.error("Automation Analytics not enabled. Use --dry-run to gather locally without sending.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if module is None:
|
if module is None:
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ class Command(BaseCommand):
|
|||||||
help = 'Gather AWX analytics data'
|
help = 'Gather AWX analytics data'
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
|
parser.add_argument('--dry-run', dest='dry-run', action='store_true',
|
||||||
|
help='Gather analytics without shipping. Works even if analytics are disabled in settings.')
|
||||||
parser.add_argument('--ship', dest='ship', action='store_true',
|
parser.add_argument('--ship', dest='ship', action='store_true',
|
||||||
help='Enable to ship metrics to the Red Hat Cloud')
|
help='Enable to ship metrics to the Red Hat Cloud')
|
||||||
|
|
||||||
@@ -23,9 +25,14 @@ class Command(BaseCommand):
|
|||||||
self.logger.propagate = False
|
self.logger.propagate = False
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
tgz = gather(collection_type='manual')
|
|
||||||
self.init_logging()
|
self.init_logging()
|
||||||
|
opt_ship = options.get('ship')
|
||||||
|
opt_dry_run = options.get('dry-run')
|
||||||
|
if opt_ship and opt_dry_run:
|
||||||
|
self.logger.error('Both --ship and --dry-run cannot be processed at the same time.')
|
||||||
|
return
|
||||||
|
tgz = gather(collection_type='manual' if not opt_dry_run else 'dry-run')
|
||||||
if tgz:
|
if tgz:
|
||||||
self.logger.debug(tgz)
|
self.logger.debug(tgz)
|
||||||
if options.get('ship'):
|
if opt_ship:
|
||||||
ship(tgz)
|
ship(tgz)
|
||||||
|
|||||||
Reference in New Issue
Block a user