return 130 for keyboard interrupt
when keyboard interrupt is received by novaclient, the return code as of now is 1. But since the client was terminated by an keyboard interrupt, the return code should be 130. (http://tldp.org/LDP/abs/html/exitcodes.html) It is useful when people are writing automation test cases and want to validate based on the return code. I have also changed the message that is printed on shell to match other clients. Change-Id: If544ade154c53b1f18518773f4d49cd335a394d0 Closes-Bug: #1373231
This commit is contained in:
parent
58b539e398
commit
09f97e9ee4
|
@ -807,8 +807,8 @@ def main():
|
|||
file=sys.stderr)
|
||||
sys.exit(1)
|
||||
except KeyboardInterrupt as e:
|
||||
print("Shutting down novaclient", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
print("... terminating nova client", file=sys.stderr)
|
||||
sys.exit(130)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -273,3 +273,12 @@ class ShellTest(utils.TestCase):
|
|||
# We expect the normal usage as a result
|
||||
self.assertIn('Command-line interface to the OpenStack Nova API',
|
||||
sys.stdout.getvalue())
|
||||
|
||||
@mock.patch.object(novaclient.shell.OpenStackComputeShell, 'main')
|
||||
def test_main_keyboard_interrupt(self, mock_compute_shell):
|
||||
# Ensure that exit code is 130 for KeyboardInterrupt
|
||||
mock_compute_shell.side_effect = KeyboardInterrupt()
|
||||
try:
|
||||
novaclient.shell.main()
|
||||
except SystemExit as ex:
|
||||
self.assertEqual(ex.code, 130)
|
||||
|
|
Loading…
Reference in New Issue