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:
parent
1d32c94962
commit
4327adc7e3
@ -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'])
|
||||
|
@ -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' %
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user