From b35f84b4018a2f9c3bddcb94dd4c217e924dff0f Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 25 Jan 2016 15:53:17 -0500 Subject: [PATCH] Bypass license database check for cleanup schedule We pre-create some cleanup jobs if a license is already present, this doesn't work with the database config as-is. These can be removed at some point in the future once the 2.4 migration path is not needed --- awx/api/license.py | 8 +++++--- awx/main/migrations/0071_v240_changes.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/awx/api/license.py b/awx/api/license.py index c380df5a56..55706364f8 100644 --- a/awx/api/license.py +++ b/awx/api/license.py @@ -11,19 +11,21 @@ class LicenseForbids(APIException): default_detail = 'Your Tower license does not allow that.' -def get_license(show_key=False): +def get_license(show_key=False, bypass_database=False): """Return a dictionary representing the license currently in place on this Tower instance. """ license_reader = TaskSerializer() + if bypass_database: + return license_reader.from_file(show_key=show_key) return license_reader.from_database(show_key=show_key) -def feature_enabled(name): +def feature_enabled(name, bypass_database=False): """Return True if the requested feature is enabled, False otherwise. If the feature does not exist, raise KeyError. """ - license = get_license() + license = get_license(bypass_database=bypass_database) # Sanity check: If there is no license, the feature is considered # to be off. diff --git a/awx/main/migrations/0071_v240_changes.py b/awx/main/migrations/0071_v240_changes.py index b36060b725..cae03ef27a 100644 --- a/awx/main/migrations/0071_v240_changes.py +++ b/awx/main/migrations/0071_v240_changes.py @@ -22,7 +22,7 @@ class Migration(DataMigration): elif stj.name == "Cleanup Activity Stream": sched = orm.Schedule(name="Cleanup Activity Schedule", rrule="DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU" % nowtime, description="Automatically Generated Schedule", enabled=True, extra_data={"days": "355"}) - elif stj.name == "Cleanup Fact Details" and feature_enabled('system_tracking'): + elif stj.name == "Cleanup Fact Details" and feature_enabled('system_tracking', bypass_database=True): sched = orm.Schedule(name="Cleanup Fact Schedule", rrule="DTSTART:%s RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=1" % nowtime, description="Automatically Generated Schedule", enabled=True, extra_data={'older_than': '120d', 'granularity': '1w'}) else: