label cleanup periodic job

This commit is contained in:
Chris Meyers
2016-04-05 12:24:13 -04:00
parent 2d9e34162c
commit 68c14976db
7 changed files with 85 additions and 1 deletions

View File

@@ -46,6 +46,7 @@ from django.contrib.auth.models import User
from awx.lib.metrics import task_timer
from awx.main.constants import CLOUD_PROVIDERS
from awx.main.models import * # noqa
from awx.main.models.label import Label
from awx.main.queue import FifoQueue
from awx.main.conf import tower_settings
from awx.main.task_engine import TaskSerializer, TASK_TIMEOUT_INTERVAL
@@ -109,6 +110,13 @@ def run_administrative_checks(self):
tower_admin_emails,
fail_silently=True)
@task(bind=True)
def run_label_cleanup(self):
qs = Label.get_orphaned_labels()
labels_count = qs.count()
qs.delete()
return labels_count
@task(bind=True)
def tower_periodic_scheduler(self):
def get_last_run():