mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Return failure when package path does not exist
This commit is contained in:
parent
9de08af950
commit
a7d5118262
1 changed files with 19 additions and 0 deletions
|
@ -17,6 +17,7 @@ from __future__ import absolute_import
|
|||
|
||||
# Import python libs
|
||||
import logging
|
||||
import os
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
@ -319,6 +320,15 @@ def package_installed(name,
|
|||
'comment': '',
|
||||
'changes': {}}
|
||||
|
||||
# Fail if using a non-existent package path
|
||||
if '~' not in name and not os.path.exists(name):
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
else:
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'Package path {0} does not exist'.format(name)
|
||||
return ret
|
||||
|
||||
old = __salt__['dism.installed_packages']()
|
||||
|
||||
# Get package info so we can see if it's already installed
|
||||
|
@ -387,6 +397,15 @@ def package_removed(name, image=None, restart=False):
|
|||
'comment': '',
|
||||
'changes': {}}
|
||||
|
||||
# Fail if using a non-existent package path
|
||||
if '~' not in name and not os.path.exists(name):
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
else:
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'Package path {0} does not exist'.format(name)
|
||||
return ret
|
||||
|
||||
old = __salt__['dism.installed_packages']()
|
||||
|
||||
# Get package info so we can see if it's already removed
|
||||
|
|
Loading…
Add table
Reference in a new issue