From 7a8234bb096677103cf6935b3b9ea55ca482dec9 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Tue, 3 Sep 2019 13:42:26 -0400 Subject: [PATCH] include license data/state in the sosreport --- awx/main/management/commands/check_license.py | 13 ++++++++++++- tools/sosreport/tower.py | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/awx/main/management/commands/check_license.py b/awx/main/management/commands/check_license.py index cb2620455d..8c0798cc53 100644 --- a/awx/main/management/commands/check_license.py +++ b/awx/main/management/commands/check_license.py @@ -1,6 +1,8 @@ # Copyright (c) 2015 Ansible, Inc. # All Rights Reserved +import json + from awx.main.utils import get_licenser from django.core.management.base import BaseCommand @@ -8,6 +10,15 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): """Returns license type, e.g., 'enterprise', 'open', 'none'""" + def add_arguments(self, parser): + parser.add_argument('--data', dest='data', action='store_true', + help='verbose, prints the actual (sanitized) license') + def handle(self, *args, **options): super(Command, self).__init__() - return get_licenser().validate().get('license_type', 'none') + license = get_licenser().validate() + if options.get('data'): + if license.get('license_key', '') != 'UNLICENSED': + license['license_key'] = '********' + return json.dumps(license) + return license.get('license_type', 'none') diff --git a/tools/sosreport/tower.py b/tools/sosreport/tower.py index 4827d76d65..0230da25a3 100644 --- a/tools/sosreport/tower.py +++ b/tools/sosreport/tower.py @@ -7,6 +7,7 @@ SOSREPORT_TOWER_COMMANDS = [ "awx-manage --version", # tower version "awx-manage list_instances", # tower cluster configuration "awx-manage run_dispatcher --status", # tower dispatch worker status + "awx-manage check_license --data", # tower license status "supervisorctl status", # tower process status "/var/lib/awx/venv/awx/bin/pip freeze", # pip package list "/var/lib/awx/venv/awx/bin/pip freeze -l", # pip package list without globally-installed packages