Avoid waiting for deletion in error cases

This commit is contained in:
Alan Rominger 2021-07-13 13:49:09 -04:00
parent 3e6cbd5114
commit 397fab793d
No known key found for this signature in database
GPG Key ID: C2D7EAAA12B63559

View File

@ -5,6 +5,7 @@ import json
from awxkit.api.pages import Credential, Organization, Project, UnifiedJob, UnifiedJobTemplate
from awxkit.utils import filter_by_class, random_title, update_payload, not_provided, PseudoNamespace, poll_until
from awxkit.api.mixins import DSAdapter, HasCreate, HasInstanceGroups, HasNotifications, HasVariables, HasCopy
from awxkit.config import config
from awxkit.api.resources import resources
import awxkit.exceptions as exc
from . import base
@ -97,9 +98,18 @@ class Inventory(HasCopy, HasCreate, HasInstanceGroups, HasVariables, base.Base):
poll_until(_wait, interval=1, timeout=60)
def silent_delete(self):
r = super(Inventory, self).silent_delete()
self.wait_until_deleted()
return r
try:
if not config.prevent_teardown:
r = self.delete()
self.wait_until_deleted()
return r
except (exc.NoContent, exc.NotFound, exc.Forbidden):
pass
except (exc.BadRequest, exc.Conflict) as e:
if 'Resource is being used' in e.msg:
pass
else:
raise e
def update_inventory_sources(self, wait=False):
response = self.related.update_inventory_sources.post()