mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Throw an error when running an inventory update against an inventory
script that has been deleted
This commit is contained in:
@@ -1471,6 +1471,8 @@ class CustomInventoryScriptAccess(BaseAccess):
|
|||||||
def can_read(self, obj):
|
def can_read(self, obj):
|
||||||
if self.user.is_superuser:
|
if self.user.is_superuser:
|
||||||
return True
|
return True
|
||||||
|
if not self.active:
|
||||||
|
return Flase
|
||||||
return bool(obj.organization in self.user.organizations.all() or obj.organization in self.user.admin_of_organizations.all())
|
return bool(obj.organization in self.user.organizations.all() or obj.organization in self.user.admin_of_organizations.all())
|
||||||
|
|
||||||
def can_add(self, data):
|
def can_add(self, data):
|
||||||
|
|||||||
@@ -1134,7 +1134,8 @@ class RunInventoryUpdate(BaseTask):
|
|||||||
runpath = tempfile.mkdtemp(prefix='ansible_tower_launch_')
|
runpath = tempfile.mkdtemp(prefix='ansible_tower_launch_')
|
||||||
handle, path = tempfile.mkstemp(dir=runpath)
|
handle, path = tempfile.mkstemp(dir=runpath)
|
||||||
f = os.fdopen(handle, 'w')
|
f = os.fdopen(handle, 'w')
|
||||||
# Check that source_script is not none and exists and that .script is not an empty string
|
if inventory_update.source_script is None or not inventory_update.source_script.active:
|
||||||
|
raise RuntimeError('Inventory Script does not exist')
|
||||||
f.write(inventory_update.source_script.script.encode('utf-8'))
|
f.write(inventory_update.source_script.script.encode('utf-8'))
|
||||||
f.close()
|
f.close()
|
||||||
os.chmod(path, stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR)
|
os.chmod(path, stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR)
|
||||||
|
|||||||
Reference in New Issue
Block a user