Wrap iterators and 'dict_items' for py34 compatibitity
Change iterators and 'dict_items' objects to list with additional 'list()' method to avoid versions incompatibility Partially-Implements: bp py3-compatibility Change-Id: Ic6b437cd0d57ca3d4b343b590d11c4e53492d223
This commit is contained in:
parent
88aade204a
commit
c8f0a75398
|
@ -441,7 +441,7 @@ def action_peek_json(body):
|
|||
raise exception.MalformedRequestBody(reason=msg)
|
||||
|
||||
# Return the action and the decoded body...
|
||||
return decoded.keys()[0]
|
||||
return list(decoded.keys())[0]
|
||||
|
||||
|
||||
class ResourceExceptionHandler(object):
|
||||
|
|
|
@ -79,7 +79,7 @@ class ShareTypesController(wsgi.Controller):
|
|||
filters['is_public'] = True
|
||||
limited_types = share_types.get_all_types(
|
||||
context, search_opts=filters).values()
|
||||
return limited_types
|
||||
return list(limited_types)
|
||||
|
||||
@staticmethod
|
||||
def _parse_is_public(is_public):
|
||||
|
|
|
@ -69,7 +69,7 @@ class GaneshaNASHelper(NASHelperBase):
|
|||
raise
|
||||
dirlist = []
|
||||
LOG.info(_LI('Loading Ganesha config from %s.'), dirpath)
|
||||
conf_files = filter(self.confrx.search, dirlist)
|
||||
conf_files = list(filter(self.confrx.search, dirlist))
|
||||
conf_files.sort()
|
||||
export_template = {}
|
||||
for conf_file in conf_files:
|
||||
|
|
|
@ -523,6 +523,7 @@ class GlusterfsNativeShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||
else:
|
||||
ignored_dirs = map(lambda x: os.path.join(tmpdir, *x),
|
||||
[('.trashcan', ), ('.trashcan', 'internal_op')])
|
||||
ignored_dirs = list(ignored_dirs)
|
||||
cmd = ['find', tmpdir, '-mindepth', '1', '!', '-path',
|
||||
ignored_dirs[0], '!', '-path', ignored_dirs[1], '-delete']
|
||||
|
||||
|
@ -679,7 +680,7 @@ class GlusterfsNativeShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||
LOG.error(_LE("Error retrieving snapshot list: %s"), exc.stderr)
|
||||
raise exception.GlusterfsException(_("gluster %s failed") %
|
||||
' '.join(args))
|
||||
snapgrep = filter(lambda x: snapshot['id'] in x, out.split("\n"))
|
||||
snapgrep = list(filter(lambda x: snapshot['id'] in x, out.split("\n")))
|
||||
if len(snapgrep) != 1:
|
||||
msg = (_("Failed to identify backing GlusterFS object "
|
||||
"for snapshot %(snap_id)s of share %(share_id)s: "
|
||||
|
|
|
@ -352,7 +352,7 @@ class NetAppCmodeClient(client_base.NetAppBaseClient):
|
|||
|
||||
This must be called against a Vserver LIF.
|
||||
"""
|
||||
return self.get_vserver_aggregate_capacities().keys()
|
||||
return list(self.get_vserver_aggregate_capacities().keys())
|
||||
|
||||
@na_utils.trace
|
||||
def create_network_interface(self, ip, netmask, vlan, node, port,
|
||||
|
|
|
@ -39,10 +39,10 @@ class LimiterTest(test.TestCase):
|
|||
def setUp(self):
|
||||
"""Run before each test."""
|
||||
super(LimiterTest, self).setUp()
|
||||
self.tiny = range(1)
|
||||
self.small = range(10)
|
||||
self.medium = range(1000)
|
||||
self.large = range(10000)
|
||||
self.tiny = list(range(1))
|
||||
self.small = list(range(10))
|
||||
self.medium = list(range(1000))
|
||||
self.large = list(range(10000))
|
||||
|
||||
def test_limiter_offset_zero(self):
|
||||
"""Test offset key works with 0."""
|
||||
|
@ -115,7 +115,7 @@ class LimiterTest(test.TestCase):
|
|||
|
||||
def test_limiter_limit_and_offset(self):
|
||||
"""Test request with both limit and offset."""
|
||||
items = range(2000)
|
||||
items = list(range(2000))
|
||||
req = webob.Request.blank('/?offset=1&limit=3')
|
||||
self.assertEqual(common.limited(items, req), items[1:4])
|
||||
req = webob.Request.blank('/?offset=3&limit=0')
|
||||
|
@ -127,7 +127,7 @@ class LimiterTest(test.TestCase):
|
|||
|
||||
def test_limiter_custom_max_limit(self):
|
||||
"""Test a max_limit other than 1000."""
|
||||
items = range(2000)
|
||||
items = list(range(2000))
|
||||
req = webob.Request.blank('/?offset=1&limit=3')
|
||||
self.assertEqual(
|
||||
common.limited(items, req, max_limit=2000), items[1:4])
|
||||
|
|
|
@ -89,6 +89,7 @@ class GaneshaConfigTests(test.TestCase):
|
|||
# ";"-s that might have crept in due to "sandwiching")
|
||||
conf = map(lambda x: x, conf)
|
||||
# handle the non-deterministic order of confs
|
||||
conf = list(conf)
|
||||
conf.sort()
|
||||
return conf
|
||||
|
||||
|
|
|
@ -572,7 +572,7 @@ class NetAppClientCmodeTestCase(test.TestCase):
|
|||
|
||||
result = self.vserver_client.list_vserver_aggregates()
|
||||
|
||||
self.assertListEqual(fake.VSERVER_AGGREGATES.keys(), result)
|
||||
self.assertListEqual(list(fake.VSERVER_AGGREGATES.keys()), result)
|
||||
|
||||
def test_list_vserver_aggregates_none_found(self):
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ class GlusterfsNativeShareDriverTestCase(test.TestCase):
|
|||
self._driver._fetch_gluster_volumes = mock.Mock(return_value=voldict)
|
||||
self._driver.gluster_used_vols_dict = used_vols
|
||||
self._driver._setup_gluster_vol = mock.Mock(return_value=gmgr1)
|
||||
self._driver.volume_pattern_keys = voldict.values()[0].keys()
|
||||
self._driver.volume_pattern_keys = list(voldict.values())[0].keys()
|
||||
|
||||
result = self._driver._pop_gluster_vol(size=size)
|
||||
|
||||
|
@ -395,7 +395,7 @@ class GlusterfsNativeShareDriverTestCase(test.TestCase):
|
|||
def test_pop_gluster_vol_excp(self, voldict, used_vols, size):
|
||||
self._driver._fetch_gluster_volumes = mock.Mock(return_value=voldict)
|
||||
self._driver.gluster_used_vols_dict = used_vols
|
||||
self._driver.volume_pattern_keys = voldict.values()[0].keys()
|
||||
self._driver.volume_pattern_keys = list(voldict.values())[0].keys()
|
||||
self._driver._setup_gluster_vol = mock.Mock()
|
||||
|
||||
self.assertRaises(exception.GlusterfsException,
|
||||
|
|
Loading…
Reference in New Issue