From 36515b38b2ab990aa16e14e9a410b710df661652 Mon Sep 17 00:00:00 2001 From: Pavlo Shchelokovskyy Date: Thu, 18 Apr 2019 10:08:44 +0300 Subject: [PATCH] Do not try to access sets by index code in neutron api in some circumstances tries to access a set or a frozenset by index, which does not work. In particular it may manifest as Unable to connect to Neutron: 'frozenset' object has no attribute '__getitem__' error in the horizon.log when opening an empty instances list page. Convert to list instead, and skip conversion for `collections.Sequence` objects only that support all the methods used for this object further in this method. Closes-bug: #1825961 Change-Id: I141a28d96f71c06a1ebe44d7067ccf4609e22db6 --- openstack_dashboard/api/neutron.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py index 1edc038c38..c495876e95 100644 --- a/openstack_dashboard/api/neutron.py +++ b/openstack_dashboard/api/neutron.py @@ -851,8 +851,16 @@ def list_resources_with_long_filters(list_method, # We consider only the filter condition from (filter_attr, # filter_values) and do not consider other filter conditions # which may be specified in **params. - if not isinstance(filter_values, (list, tuple, set, frozenset)): + + # NOTE(pas-ha) this will produce a deprecation warning in Py37 + # and will not work in Py38, and six.moves also does not support it + # (see https://github.com/benjaminp/six/issues/155). + # TODO(pas-ha) replace with collections.abc.Sequence + # after dropping py27 support in U release + if isinstance(filter_values, six.string_types): filter_values = [filter_values] + elif not isinstance(filter_values, collections.Sequence): + filter_values = list(filter_values) # Length of each query filter is: # =& (e.g., id=)