Skip to content

Commit

Permalink
Merge pull request #39426 from morganwillcock/dism
Browse files Browse the repository at this point in the history
win_dism: Return failure when package path does not exist
  • Loading branch information
Mike Place committed Feb 16, 2017
2 parents 5616270 + a7d5118 commit 9dbfba9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions salt/states/win_dism.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

# Import python libs
import logging
import os

# Import salt libs
import salt.utils
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9dbfba9

Please sign in to comment.