mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
Avoid waiting for deletion in error cases
This commit is contained in:
@@ -5,6 +5,7 @@ import json
|
|||||||
from awxkit.api.pages import Credential, Organization, Project, UnifiedJob, UnifiedJobTemplate
|
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.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.api.mixins import DSAdapter, HasCreate, HasInstanceGroups, HasNotifications, HasVariables, HasCopy
|
||||||
|
from awxkit.config import config
|
||||||
from awxkit.api.resources import resources
|
from awxkit.api.resources import resources
|
||||||
import awxkit.exceptions as exc
|
import awxkit.exceptions as exc
|
||||||
from . import base
|
from . import base
|
||||||
@@ -97,9 +98,18 @@ class Inventory(HasCopy, HasCreate, HasInstanceGroups, HasVariables, base.Base):
|
|||||||
poll_until(_wait, interval=1, timeout=60)
|
poll_until(_wait, interval=1, timeout=60)
|
||||||
|
|
||||||
def silent_delete(self):
|
def silent_delete(self):
|
||||||
r = super(Inventory, self).silent_delete()
|
try:
|
||||||
self.wait_until_deleted()
|
if not config.prevent_teardown:
|
||||||
return r
|
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):
|
def update_inventory_sources(self, wait=False):
|
||||||
response = self.related.update_inventory_sources.post()
|
response = self.related.update_inventory_sources.post()
|
||||||
|
|||||||
Reference in New Issue
Block a user