From aeb47213eaa8f27bea43bb6b915d6be255a9e246 Mon Sep 17 00:00:00 2001 From: Eduardo Santos Date: Thu, 5 Nov 2020 18:27:55 +0000 Subject: [PATCH] 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 --- manilaclient/shell.py | 3 +++ .../bug-1902873-fix-py-raw-error-msg-a839fee2ac7b9d3d.yaml | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 releasenotes/notes/bug-1902873-fix-py-raw-error-msg-a839fee2ac7b9d3d.yaml diff --git a/manilaclient/shell.py b/manilaclient/shell.py index 0123ff70f..a4419110a 100644 --- a/manilaclient/shell.py +++ b/manilaclient/shell.py @@ -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): diff --git a/releasenotes/notes/bug-1902873-fix-py-raw-error-msg-a839fee2ac7b9d3d.yaml b/releasenotes/notes/bug-1902873-fix-py-raw-error-msg-a839fee2ac7b9d3d.yaml new file mode 100644 index 000000000..c037cdea3 --- /dev/null +++ b/releasenotes/notes/bug-1902873-fix-py-raw-error-msg-a839fee2ac7b9d3d.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + `Bug #1902873 `_: + Fixed raw Python error message when using ``manila`` without + a subcommand while passing an optional argument, such as + ``--os-cache``.