mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Make dict updates more dense
This commit is contained in:
parent
ace22d3b6c
commit
eb39ec4207
@ -14,36 +14,26 @@ def held(name):
|
||||
name
|
||||
The name of the package, e.g., 'tmux'
|
||||
'''
|
||||
ret = {'name': name}
|
||||
ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}
|
||||
state = __salt__['pkg.get_selections'](
|
||||
pattern=name,
|
||||
)
|
||||
if not state:
|
||||
ret.update({'changes': {},
|
||||
'result': False,
|
||||
'comment': 'Package {0} does not have a state'.format(
|
||||
name
|
||||
)})
|
||||
ret.update(comment='Package {0} does not have a state'.format(name))
|
||||
return ret
|
||||
if not salt.utils.is_true(state.get('hold', False)):
|
||||
if not __opts__['test']:
|
||||
result = __salt__['pkg.set_selections'](
|
||||
selection={'hold': [name]}
|
||||
)
|
||||
ret.update({'changes': result[name],
|
||||
'result': True,
|
||||
'comment': 'Package {0} is now being held'.format(
|
||||
name
|
||||
)})
|
||||
ret.update(changes=result[name],
|
||||
result=True,
|
||||
comment='Package {0} is now being held'.format(name))
|
||||
else:
|
||||
ret.update({'changes': {},
|
||||
'result': None,
|
||||
'comment': 'Package {0} is set to be held'.format(
|
||||
name
|
||||
)})
|
||||
ret.update(result=None,
|
||||
comment='Package {0} is set to be held'.format(name))
|
||||
else:
|
||||
ret.update({'changes': {},
|
||||
'result': True,
|
||||
'comment': 'Package {0} is already held'.format(name)})
|
||||
ret.update(result= True,
|
||||
comment='Package {0} is already held'.format(name))
|
||||
|
||||
return ret
|
||||
|
Loading…
Reference in New Issue
Block a user