mirror of
https://github.com/ansible/awx.git
synced 2026-05-23 08:37:48 -02:30
Allow preserving schedules with prevent_teardown
This commit is contained in:
committed by
Alan Rominger
parent
d834519aae
commit
51f4a40cd4
@@ -2,7 +2,9 @@ from contextlib import suppress
|
||||
|
||||
from awxkit.api.pages import UnifiedJob
|
||||
from awxkit.api.resources import resources
|
||||
from awxkit.config import config
|
||||
import awxkit.exceptions as exc
|
||||
|
||||
from . import page
|
||||
from . import base
|
||||
|
||||
@@ -11,6 +13,17 @@ class Schedule(UnifiedJob):
|
||||
|
||||
NATURAL_KEY = ('unified_job_template', 'name')
|
||||
|
||||
def silent_delete(self):
|
||||
"""If we are told to prevent_teardown of schedules, then keep them
|
||||
but do not leave them activated, or system will be swamped quickly"""
|
||||
try:
|
||||
if not config.prevent_teardown:
|
||||
return self.delete()
|
||||
else:
|
||||
self.patch(enabled=False)
|
||||
except (exc.NoContent, exc.NotFound, exc.Forbidden):
|
||||
pass
|
||||
|
||||
|
||||
page.register_page([resources.schedule, resources.related_schedule], Schedule)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user