From f38c8c5df83b50fd3ef38f3db2456b54294ee0aa Mon Sep 17 00:00:00 2001 From: Chaynika Saikia <csaikia@asu.edu> Date: Wed, 21 Jun 2017 16:33:49 -0400 Subject: [PATCH] UnboundLocalError on message-list This bug for 'cinder message-list' has been fixed such that now if the user gives wrong filters, then the command properly prints WARNING message saying it is ignoring that filter. Previously, for wrong filters which were not passed in the correct usage format, the 'cinder message-list --filters' command was giving UnboundLocalError exception. The extract_filters() method was previously assuming that all the message filters passed were in the format "<filter_name>=<value>", because of which if the user passed something like: 'cinder message-list --filters event_id:VOLUME_000002' an UnboundLocalError was thrown. The changes are made to the method such that if the user passes a filter in invalid format, the cinder CLI ignores that filter while providing the output. Closes-Bug: #1696556 Change-Id: I545b3f28e545b380842ea003dc38ad70cb413aee --- cinderclient/shell_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cinderclient/shell_utils.py b/cinderclient/shell_utils.py index 4cb676bb1..0bfecae8c 100644 --- a/cinderclient/shell_utils.py +++ b/cinderclient/shell_utils.py @@ -151,7 +151,9 @@ def extract_filters(args): (key, value) = f.split('=', 1) if value.startswith('{') and value.endswith('}'): value = _build_internal_dict(value[1:-1]) - filters[key] = value + filters[key] = value + else: + print("WARNING: Ignoring the filter %s while showing result." % f) return filters