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

Added test mode to states.dockerng. Resolves #33632. #33659

Merged
merged 1 commit into from
Jun 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions salt/states/dockerng.py
Original file line number Diff line number Diff line change
Expand Up @@ -2256,6 +2256,10 @@ def volume_present(name, driver=None, driver_opts=None, force=False):
driver_opts = salt.utils.repack_dictlist(driver_opts)
volume = _find_volume(name)
if not volume:
if __opts__['test']:
ret['result'] = None
ret['comment'] = ('The volume \'{0}\' will be created'.format(name))
return ret
try:
ret['changes']['created'] = __salt__['dockerng.create_volume'](
name, driver=driver, driver_opts=driver_opts)
Expand All @@ -2267,13 +2271,20 @@ def volume_present(name, driver=None, driver_opts=None, force=False):
result = True
ret['result'] = result
return ret
# volume exits, check if driver is the same.
# volume exists, check if driver is the same.
if driver is not None and volume['Driver'] != driver:
if not force:
ret['comment'] = "Driver for existing volume '{0}' ('{1}')" \
" does not match specified driver ('{2}')" \
" and force is False".format(
name, volume['Driver'], driver)
ret['result'] = None if __opts__['test'] else False
return ret
if __opts__['test']:
ret['result'] = None
ret['comment'] = "The volume '{0}' will be replaced with a" \
" new one using the driver '{1}'".format(
name, volume)
return ret
try:
ret['changes']['removed'] = __salt__['dockerng.remove_volume'](name)
Expand All @@ -2294,7 +2305,7 @@ def volume_present(name, driver=None, driver_opts=None, force=False):
ret['result'] = result
return ret

ret['result'] = True
ret['result'] = None if __opts__['test'] else True
ret['comment'] = 'Volume \'{0}\' already exists.'.format(name)
return ret

Expand Down