Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_dism: Return failure when package path does not exist #39426

Merged
merged 1 commit into from
Feb 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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