mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add error handling
This commit is contained in:
parent
2ec5cec8a4
commit
1bdbaac658
1 changed files with 8 additions and 13 deletions
|
@ -725,19 +725,14 @@ def install(name=None,
|
|||
while targets:
|
||||
cmd = cmd_install + targets[:500]
|
||||
targets = targets[500:]
|
||||
|
||||
out = __salt__['cmd.run'](
|
||||
cmd,
|
||||
output_loglevel='trace',
|
||||
python_shell=False
|
||||
)
|
||||
for line in out.splitlines():
|
||||
match = re.match(
|
||||
"^The selected package '([^']+)'.+has lower version",
|
||||
line
|
||||
)
|
||||
if match:
|
||||
downgrades.append(match.group(1))
|
||||
call = __salt__['cmd.run_all'](cmd, output_loglevel='trace', python_shell=False)
|
||||
if call['retcode'] != 0:
|
||||
raise CommandExecutionError(call['stderr']) # Fixme: This needs a proper report mechanism.
|
||||
else:
|
||||
for line in call['stdout'].splitlines():
|
||||
match = re.match(r"^The selected package '([^']+)'.+has lower version", line)
|
||||
if match:
|
||||
downgrades.append(match.group(1))
|
||||
|
||||
while downgrades:
|
||||
cmd = cmd_install + ['--force'] + downgrades[:500]
|
||||
|
|
Loading…
Add table
Reference in a new issue