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
This commit is contained in:
Chaynika Saikia 2017-06-21 16:33:49 -04:00
parent 71dfec6743
commit f38c8c5df8
1 changed files with 3 additions and 1 deletions

View File

@ -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