Fix undesirable raw Python error
Using the novaclient without a subcommand while passing an optional argument triggers the raw Python error `ERROR: 'Namespace' object has no attribute 'func'`. This bug can be reproduced by issuing the command `nova --os-compute-api-version 2.87`. Added a default value to `func` and an empty value to `command` as placeholders so that a help message is shown instead of the Python error. Change-Id: Ic3e87b67f6d27d40b03d7d8e520fa0f79a4d09e5 Closes-Bug: #1903727 Signed-off-by: Takashi Natsume <takanattie@gmail.com>
This commit is contained in:
parent
1b5f29a3a4
commit
e85d845b1a
@ -365,6 +365,9 @@ class OpenStackComputeShell(object):
|
|||||||
help=_("Use this API endpoint instead of the Service Catalog. "
|
help=_("Use this API endpoint instead of the Service Catalog. "
|
||||||
"Defaults to env[OS_ENDPOINT_OVERRIDE]."))
|
"Defaults to env[OS_ENDPOINT_OVERRIDE]."))
|
||||||
|
|
||||||
|
parser.set_defaults(func=self.do_help)
|
||||||
|
parser.set_defaults(command='')
|
||||||
|
|
||||||
if osprofiler_profiler:
|
if osprofiler_profiler:
|
||||||
parser.add_argument('--profile',
|
parser.add_argument('--profile',
|
||||||
metavar='HMAC_KEY',
|
metavar='HMAC_KEY',
|
||||||
|
@ -451,6 +451,9 @@ class ShellTest(utils.TestCase):
|
|||||||
def test_help_no_options(self):
|
def test_help_no_options(self):
|
||||||
self._test_help('')
|
self._test_help('')
|
||||||
|
|
||||||
|
def test_help_no_subcommand(self):
|
||||||
|
self._test_help('--os-compute-api-version 2.87')
|
||||||
|
|
||||||
def test_help_on_subcommand(self):
|
def test_help_on_subcommand(self):
|
||||||
required = [
|
required = [
|
||||||
'.*?^usage: nova set-password',
|
'.*?^usage: nova set-password',
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
`Bug #1903727 <https://bugs.launchpad.net/python-novaclient/+bug/1903727>`_:
|
||||||
|
Fixed raw Python error message when using ``nova`` without
|
||||||
|
a subcommand while passing an optional argument, such as
|
||||||
|
``--os-compute-api-version 2.87``.
|
Loading…
Reference in New Issue
Block a user