mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #25397 from GideonRed/2015.5
Introduce standard error output when cli exits with non-zero status
This commit is contained in:
commit
978d9f7117
1 changed files with 5 additions and 0 deletions
|
@ -74,6 +74,7 @@ class SaltCMD(parsers.SaltCMDOptionParser):
|
|||
if tok:
|
||||
eauth['token'] = tok.get('token', '')
|
||||
if not res:
|
||||
sys.stderr.write('ERROR: Authentication failed\n')
|
||||
sys.exit(2)
|
||||
eauth.update(res)
|
||||
eauth['eauth'] = self.options.eauth
|
||||
|
@ -100,6 +101,7 @@ class SaltCMD(parsers.SaltCMDOptionParser):
|
|||
for ret in res.itervalues():
|
||||
retcode = salt.utils.job.get_retcode(ret)
|
||||
if retcode != 0:
|
||||
sys.stderr.write('ERROR: Minions returned with non-zero exit code\n')
|
||||
sys.exit(retcode)
|
||||
|
||||
else:
|
||||
|
@ -150,6 +152,7 @@ class SaltCMD(parsers.SaltCMDOptionParser):
|
|||
if tok:
|
||||
kwargs['token'] = tok.get('token', '')
|
||||
if not res:
|
||||
sys.stderr.write('ERROR: Authentication failed\n')
|
||||
sys.exit(2)
|
||||
kwargs.update(res)
|
||||
kwargs['eauth'] = self.options.eauth
|
||||
|
@ -213,6 +216,7 @@ class SaltCMD(parsers.SaltCMDOptionParser):
|
|||
# This is the final point before the 'salt' cmd returns,
|
||||
# which is why we set the retcode here.
|
||||
if retcodes.count(0) < len(retcodes):
|
||||
sys.stderr.write('ERROR: Minions returned with non-zero exit code\n')
|
||||
sys.exit(11)
|
||||
|
||||
except (SaltInvocationError, EauthAuthenticationError, SaltClientError) as exc:
|
||||
|
@ -283,6 +287,7 @@ class SaltCMD(parsers.SaltCMDOptionParser):
|
|||
# Determine the proper output method and run it
|
||||
salt.output.display_output(ret, out, self.config)
|
||||
if not ret:
|
||||
sys.stderr.write('ERROR: No return received\n')
|
||||
sys.exit(2)
|
||||
|
||||
def _format_ret(self, full_ret):
|
||||
|
|
Loading…
Add table
Reference in a new issue