Fix undesirable raw Python error

Using the manilaclient 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 `manila --os-cache`.
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.
This patch uses the same fix implemented in the
python-cinderclient.

Closes-Bug: #1902873
Change-Id: I5fcafd4bdfb40b2054e1205c14493c2f4be1f77a
This commit is contained in:
Eduardo Santos 2020-11-05 18:27:55 +00:00
parent 6673930aa4
commit aeb47213ea
2 changed files with 10 additions and 0 deletions

View File

@ -347,6 +347,9 @@ class OpenStackManilaShell(object):
parser.add_argument('--os_cert',
help=argparse.SUPPRESS)
parser.set_defaults(func=self.do_help)
parser.set_defaults(command='')
return parser
def get_subcommand_parser(self, version):

View File

@ -0,0 +1,7 @@
---
fixes:
- |
`Bug #1902873 <https://bugs.launchpad.net/python-manilaclient/+bug/1902873>`_:
Fixed raw Python error message when using ``manila`` without
a subcommand while passing an optional argument, such as
``--os-cache``.