From c9bd767fbd59ee2666ae4844ea198f15311f2199 Mon Sep 17 00:00:00 2001 From: Jerry Sun Date: Tue, 20 Sep 2022 12:54:15 -0400 Subject: [PATCH] Better error message for sysinv forbidden error This commit catches the forbidden error raised for a user trying to run sysinv commands without enough privileges. The forbidden exception used to not be caught, resulting in sysinv CLI returning a "None" to the user. With this commit, a more useful error message is shown to the user. Test Cases: PASS: Create a reader user and run "system modify --description". Ensure a meaningful error is returned since readers are not allowed to run system modify. Ensure no changes are made by checking "system show" Change-Id: I11c407f06196962ba445c6d8a9f7591cc8a5cf05 Story: 2010149 Task: 46360 Signed-off-by: Jerry Sun --- sysinv/cgts-client/cgts-client/cgtsclient/shell.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sysinv/cgts-client/cgts-client/cgtsclient/shell.py b/sysinv/cgts-client/cgts-client/cgtsclient/shell.py index cb0620abfc..e29e6ec2e9 100644 --- a/sysinv/cgts-client/cgts-client/cgtsclient/shell.py +++ b/sysinv/cgts-client/cgts-client/cgtsclient/shell.py @@ -303,6 +303,8 @@ class CgtsShell(object): args.func(client, args) except exc.Unauthorized: raise exc.CommandError("Invalid Identity credentials.") + except exc.HTTPForbidden: + raise exc.CommandError("Error: Forbidden") def do_bash_completion(self, args): """Prints all of the commands and options to stdout.