Replace dict.items() with list(dict.items())

Python 3 dict.items() returns an iterator instead
of list, so typecasting is required where necessary.

Partially-Implements: blueprint designate-py3

Change-Id: Ief4c48639fc7b8f562527640b641cf201826dd4a
This commit is contained in:
Pradeep Kumar Singh 2015-06-30 23:22:40 +05:30
parent 1d32c94962
commit 4327adc7e3
3 changed files with 8 additions and 8 deletions

View File

@ -1715,7 +1715,7 @@ class Service(service.RPCService, service.Service):
elevated_context.all_tenants = True
elevated_context.edit_managed_records = True
if records > 0:
if len(records) > 0:
for r in records:
msg = 'Deleting record %s for FIP %s'
LOG.debug(msg, r['id'], r['managed_resource_id'])

View File

@ -54,7 +54,7 @@ def deallocate_floatingip(id_):
Deallocate a floatingip
"""
LOG.debug('De-allocating %s' % id_)
for tenant_id, allocated in ALLOCATIONS.items():
for tenant_id, allocated in list(ALLOCATIONS.items()):
if id_ in allocated:
POOL[id_] = allocated.pop(id_)
break
@ -64,8 +64,8 @@ def deallocate_floatingip(id_):
def reset_floatingips():
LOG.debug('Resetting any allocations.')
for tenant_id, allocated in ALLOCATIONS.items():
for key, value in allocated.items():
for tenant_id, allocated in list(ALLOCATIONS.items()):
for key, value in list(allocated.items()):
POOL[key] = allocated.pop(key)
@ -75,10 +75,10 @@ class FakeNetworkAPI(NetworkAPI):
def list_floatingips(self, context, region=None):
if context.is_admin:
data = []
for tenant_id, allocated in ALLOCATIONS.items():
data.extend(allocated.items())
for tenant_id, allocated in list(ALLOCATIONS.items()):
data.extend(list(allocated.items()))
else:
data = ALLOCATIONS.get(context.tenant, {}).items()
data = list(ALLOCATIONS.get(context.tenant, {}).items())
formatted = [_format_floatingip(k, v) for k, v in data]
LOG.debug('Returning %i FloatingIPs: %s' %

View File

@ -79,7 +79,7 @@ class Schema(object):
filtered = {}
for name, subschema in properties.items():
for name, subschema in list(properties.items()):
if 'type' in subschema and subschema['type'] == 'array':
subinstance = instance.get(name, None)
filtered[name] = self._filter_array(subinstance, subschema)