mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
One last cleanup.
This commit is contained in:
parent
11cb86e6eb
commit
727964ab55
1 changed files with 28 additions and 33 deletions
|
@ -1685,45 +1685,40 @@ def installed(
|
|||
# checks reinstall targets works.
|
||||
pkg_ret = {}
|
||||
|
||||
if 'pkg.hold' in __salt__:
|
||||
if 'hold' in kwargs:
|
||||
try:
|
||||
if kwargs['hold']:
|
||||
hold_ret = __salt__['pkg.hold'](
|
||||
name=name, pkgs=desired, sources=sources
|
||||
)
|
||||
else:
|
||||
hold_ret = __salt__['pkg.unhold'](
|
||||
name=name, pkgs=desired, sources=sources
|
||||
)
|
||||
except (CommandExecutionError, SaltInvocationError) as exc:
|
||||
comment.append(str(exc))
|
||||
if 'pkg.hold' in __salt__ and 'hold' in kwargs:
|
||||
try:
|
||||
action = 'pkg.hold' if kwargs['hold'] else 'pkg.unhold'
|
||||
hold_ret = __salt__[action](
|
||||
name=name, pkgs=desired, sources=sources
|
||||
)
|
||||
except (CommandExecutionError, SaltInvocationError) as exc:
|
||||
comment.append(str(exc))
|
||||
ret = {'name': name,
|
||||
'changes': changes,
|
||||
'result': False,
|
||||
'comment': '\n'.join(comment)}
|
||||
if warnings:
|
||||
ret.setdefault('warnings', []).extend(warnings)
|
||||
return ret
|
||||
else:
|
||||
if 'result' in hold_ret and not hold_ret['result']:
|
||||
ret = {'name': name,
|
||||
'changes': changes,
|
||||
'changes': {},
|
||||
'result': False,
|
||||
'comment': '\n'.join(comment)}
|
||||
'comment': 'An error was encountered while '
|
||||
'holding/unholding package(s): {0}'
|
||||
.format(hold_ret['comment'])}
|
||||
if warnings:
|
||||
ret.setdefault('warnings', []).extend(warnings)
|
||||
return ret
|
||||
else:
|
||||
if 'result' in hold_ret and not hold_ret['result']:
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': False,
|
||||
'comment': 'An error was encountered while '
|
||||
'holding/unholding package(s): {0}'
|
||||
.format(hold_ret['comment'])}
|
||||
if warnings:
|
||||
ret.setdefault('warnings', []).extend(warnings)
|
||||
return ret
|
||||
else:
|
||||
modified_hold = [hold_ret[x] for x in hold_ret
|
||||
if hold_ret[x]['changes']]
|
||||
not_modified_hold = [hold_ret[x] for x in hold_ret
|
||||
if not hold_ret[x]['changes']
|
||||
and hold_ret[x]['result']]
|
||||
failed_hold = [hold_ret[x] for x in hold_ret
|
||||
if not hold_ret[x]['result']]
|
||||
modified_hold = [hold_ret[x] for x in hold_ret
|
||||
if hold_ret[x]['changes']]
|
||||
not_modified_hold = [hold_ret[x] for x in hold_ret
|
||||
if not hold_ret[x]['changes']
|
||||
and hold_ret[x]['result']]
|
||||
failed_hold = [hold_ret[x] for x in hold_ret
|
||||
if not hold_ret[x]['result']]
|
||||
|
||||
if to_unpurge:
|
||||
changes['purge_desired'] = __salt__['lowpkg.unpurge'](*to_unpurge)
|
||||
|
|
Loading…
Add table
Reference in a new issue