Replace six.iteritems with dict.items(Part-2)

according to https://wiki.openstack.org/wiki/Python3, now we should avoid
using six.iteritems and replace it with dict.items.

Change-Id: I58a399baa2275f280acc0e6d649f81838648ce5c
Closes-Bug: #1680761
This commit is contained in:
fpxie 2017-04-18 16:21:31 +08:00
parent 4bffb7defb
commit 574312165b
31 changed files with 46 additions and 68 deletions

View File

@ -737,7 +737,7 @@ def _build_flow_expr_str(flow_dict, cmd):
raise exceptions.InvalidInput(error_message=msg) raise exceptions.InvalidInput(error_message=msg)
actions = "actions=%s" % flow_dict.pop('actions') actions = "actions=%s" % flow_dict.pop('actions')
for key, value in six.iteritems(flow_dict): for key, value in flow_dict.items():
if key == 'proto': if key == 'proto':
flow_expr_arr.append(value) flow_expr_arr.append(value)
else: else:

View File

@ -18,8 +18,6 @@ from neutron_lib import constants as lib_constants
from neutron_lib.utils import helpers from neutron_lib.utils import helpers
from oslo_log import log as logging from oslo_log import log as logging
import six
from neutron._i18n import _, _LE, _LW from neutron._i18n import _, _LE, _LW
from neutron.agent.l3 import namespaces from neutron.agent.l3 import namespaces
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
@ -1027,7 +1025,7 @@ class RouterInfo(object):
iptables['filter'].add_rule( iptables['filter'].add_rule(
'scope', 'scope',
self.address_scope_filter_rule(device_name, mark)) self.address_scope_filter_rule(device_name, mark))
for subnet_id, prefix in six.iteritems(self.pd_subnets): for subnet_id, prefix in self.pd_subnets.items():
if prefix != n_const.PROVISIONAL_IPV6_PD_PREFIX: if prefix != n_const.PROVISIONAL_IPV6_PD_PREFIX:
self._process_pd_iptables_rules(prefix, subnet_id) self._process_pd_iptables_rules(prefix, subnet_id)

View File

@ -78,7 +78,7 @@ class DictModel(dict):
else: else:
return item return item
for key, value in six.iteritems(self): for key, value in self.items():
if isinstance(value, (list, tuple)): if isinstance(value, (list, tuple)):
# Keep the same type but convert dicts to DictModels # Keep the same type but convert dicts to DictModels
self[key] = type(value)( self[key] = type(value)(

View File

@ -20,7 +20,6 @@ from neutron_lib import constants
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import netutils from oslo_utils import netutils
import six
from neutron._i18n import _LI from neutron._i18n import _LI
from neutron.agent import firewall from neutron.agent import firewall
@ -714,7 +713,7 @@ class IptablesFirewallDriver(firewall.FirewallDriver):
remote_sgs_to_remove = self._determine_remote_sgs_to_remove( remote_sgs_to_remove = self._determine_remote_sgs_to_remove(
filtered_ports) filtered_ports)
for ip_version, remote_sg_ids in six.iteritems(remote_sgs_to_remove): for ip_version, remote_sg_ids in remote_sgs_to_remove.items():
if self.enable_ipset: if self.enable_ipset:
self._remove_ipsets_for_remote_sgs(ip_version, remote_sg_ids) self._remove_ipsets_for_remote_sgs(ip_version, remote_sg_ids)
@ -734,8 +733,7 @@ class IptablesFirewallDriver(firewall.FirewallDriver):
constants.IPv6: set()} constants.IPv6: set()}
remote_group_id_sets = self._get_remote_sg_ids_sets_by_ipversion( remote_group_id_sets = self._get_remote_sg_ids_sets_by_ipversion(
filtered_ports) filtered_ports)
for ip_version, remote_group_id_set in ( for ip_version, remote_group_id_set in remote_group_id_sets.items():
six.iteritems(remote_group_id_sets)):
sgs_to_remove_per_ipversion[ip_version].update( sgs_to_remove_per_ipversion[ip_version].update(
set(self.pre_sg_members) - remote_group_id_set) set(self.pre_sg_members) - remote_group_id_set)
return sgs_to_remove_per_ipversion return sgs_to_remove_per_ipversion

View File

@ -29,7 +29,6 @@ from oslo_concurrency import lockutils
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
import six
from neutron._i18n import _, _LE, _LW from neutron._i18n import _, _LE, _LW
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
@ -355,7 +354,7 @@ class IptablesManager(object):
elif ip_version == 6: elif ip_version == 6:
tables = self.ipv6 tables = self.ipv6
for table, chains in six.iteritems(builtin_chains[ip_version]): for table, chains in builtin_chains[ip_version].items():
for chain in chains: for chain in chains:
tables[table].add_chain(chain) tables[table].add_chain(chain)
tables[table].add_rule(chain, '-j $%s' % tables[table].add_rule(chain, '-j $%s' %

View File

@ -15,7 +15,6 @@
import errno import errno
import itertools import itertools
import os import os
import six
import netaddr import netaddr
from neutron_lib import exceptions from neutron_lib import exceptions
@ -425,7 +424,7 @@ class KeepalivedManager(object):
def spawn(self): def spawn(self):
config_path = self._output_config_file() config_path = self._output_config_file()
for key, instance in six.iteritems(self.config.instances): for key, instance in self.config.instances.items():
if instance.track_script: if instance.track_script:
instance.track_script.write_check_script() instance.track_script.write_check_script()

View File

@ -153,7 +153,7 @@ class PrefixDelegation(object):
if not self._is_pd_master_router(router): if not self._is_pd_master_router(router):
return return
prefix_update = {} prefix_update = {}
for subnet_id, pd_info in six.iteritems(router['subnets']): for subnet_id, pd_info in router['subnets'].items():
self._delete_lla(router, pd_info.get_bind_lla_with_mask()) self._delete_lla(router, pd_info.get_bind_lla_with_mask())
if pd_info.client_started: if pd_info.client_started:
pd_info.driver.disable(self.pmon, router['ns_name']) pd_info.driver.disable(self.pmon, router['ns_name'])
@ -289,13 +289,13 @@ class PrefixDelegation(object):
LOG.debug("Processing IPv6 PD Prefix Update") LOG.debug("Processing IPv6 PD Prefix Update")
prefix_update = {} prefix_update = {}
for router_id, router in six.iteritems(self.routers): for router_id, router in self.routers.items():
if not (self._is_pd_master_router(router) and if not (self._is_pd_master_router(router) and
router['gw_interface']): router['gw_interface']):
continue continue
llas = None llas = None
for subnet_id, pd_info in six.iteritems(router['subnets']): for subnet_id, pd_info in router['subnets'].items():
if pd_info.client_started: if pd_info.client_started:
prefix = pd_info.driver.get_prefix() prefix = pd_info.driver.get_prefix()
if prefix != pd_info.prefix: if prefix != pd_info.prefix:

View File

@ -243,7 +243,7 @@ class OvsdbVsctl(ovsdb.API):
for value in values: for value in values:
if isinstance(value, collections.Mapping): if isinstance(value, collections.Mapping):
args += ["{}={}".format(ovsdb.py_to_val(k), ovsdb.py_to_val(v)) args += ["{}={}".format(ovsdb.py_to_val(k), ovsdb.py_to_val(v))
for k, v in six.iteritems(value)] for k, v in value.items()]
else: else:
args.append(ovsdb.py_to_val(value)) args.append(ovsdb.py_to_val(value))
return BaseCommand(self.context, 'add', args=args) return BaseCommand(self.context, 'add', args=args)

View File

@ -16,7 +16,6 @@ import collections
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
import six
from neutron._i18n import _, _LE from neutron._i18n import _, _LE
from neutron.agent.ovsdb import api from neutron.agent.ovsdb import api
@ -284,7 +283,7 @@ class DbAddCommand(BaseCommand):
# Since this operation depends on the previous value, verify() # Since this operation depends on the previous value, verify()
# must be called. # must be called.
field = getattr(record, self.column, {}) field = getattr(record, self.column, {})
for k, v in six.iteritems(value): for k, v in value.items():
if k in field: if k in field:
continue continue
field[k] = v field[k] = v

View File

@ -268,7 +268,7 @@ def db_replace_record(obj):
api.Command object. api.Command object.
""" """
if isinstance(obj, collections.Mapping): if isinstance(obj, collections.Mapping):
for k, v in six.iteritems(obj): for k, v in obj.items():
if isinstance(v, api.Command): if isinstance(v, api.Command):
obj[k] = v.result obj[k] = v.result
elif (isinstance(obj, collections.Sequence) elif (isinstance(obj, collections.Sequence)

View File

@ -23,7 +23,6 @@ from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_middleware import base from oslo_middleware import base
import routes import routes
import six
import webob.dec import webob.dec
import webob.exc import webob.exc
@ -71,7 +70,7 @@ class ActionExtensionController(wsgi.Controller):
def action(self, request, id): def action(self, request, id):
input_dict = self._deserialize(request.body, input_dict = self._deserialize(request.body,
request.get_content_type()) request.get_content_type())
for action_name, handler in six.iteritems(self.action_handlers): for action_name, handler in self.action_handlers.items():
if action_name in input_dict: if action_name in input_dict:
return handler(input_dict, request, id) return handler(input_dict, request, id)
# no action handler found (bump to downstream application) # no action handler found (bump to downstream application)
@ -113,7 +112,7 @@ class ExtensionController(wsgi.Controller):
def index(self, request): def index(self, request):
extensions = [] extensions = []
for _alias, ext in six.iteritems(self.extension_manager.extensions): for _alias, ext in self.extension_manager.extensions.items():
extensions.append(self._translate(ext)) extensions.append(self._translate(ext))
return dict(extensions=extensions) return dict(extensions=extensions)
@ -154,7 +153,7 @@ class ExtensionMiddleware(base.ConfigurableMiddleware):
LOG.debug('Extended resource: %s', LOG.debug('Extended resource: %s',
resource.collection) resource.collection)
for action, method in six.iteritems(resource.collection_actions): for action, method in resource.collection_actions.items():
conditions = dict(method=[method]) conditions = dict(method=[method])
path = "/%s/%s" % (resource.collection, action) path = "/%s/%s" % (resource.collection, action)
with mapper.submapper(controller=resource.controller, with mapper.submapper(controller=resource.controller,
@ -345,7 +344,7 @@ class ExtensionManager(object):
if check_optionals and optional_exts_set - set(processed_exts): if check_optionals and optional_exts_set - set(processed_exts):
continue continue
extended_attrs = ext.get_extended_resources(version) extended_attrs = ext.get_extended_resources(version)
for res, resource_attrs in six.iteritems(extended_attrs): for res, resource_attrs in extended_attrs.items():
attr_map.setdefault(res, {}).update(resource_attrs) attr_map.setdefault(res, {}).update(resource_attrs)
processed_exts[ext_name] = ext processed_exts[ext_name] = ext
del exts_to_process[ext_name] del exts_to_process[ext_name]

View File

@ -16,7 +16,6 @@ from neutron_lib import constants
from neutron_lib.plugins import directory from neutron_lib.plugins import directory
from oslo_log import log as logging from oslo_log import log as logging
import oslo_messaging import oslo_messaging
import six
from neutron.common import rpc as n_rpc from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
@ -57,7 +56,7 @@ class MeteringAgentNotifyAPI(object):
l3_router.append(router) l3_router.append(router)
l3_routers[l3_agent.host] = l3_router l3_routers[l3_agent.host] = l3_router
for host, routers in six.iteritems(l3_routers): for host, routers in l3_routers.items():
cctxt = self.client.prepare(server=host) cctxt = self.client.prepare(server=host)
cctxt.cast(context, method, routers=routers) cctxt.cast(context, method, routers=routers)

View File

@ -21,7 +21,6 @@ from neutron_lib.plugins import directory
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import oslo_messaging import oslo_messaging
import six
from neutron.common import constants as n_const from neutron.common import constants as n_const
from neutron.common import utils from neutron.common import utils
@ -214,7 +213,7 @@ class L3RpcCallback(object):
def update_floatingip_statuses(self, context, router_id, fip_statuses): def update_floatingip_statuses(self, context, router_id, fip_statuses):
"""Update operational status for a floating IP.""" """Update operational status for a floating IP."""
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
for (floatingip_id, status) in six.iteritems(fip_statuses): for (floatingip_id, status) in fip_statuses.items():
LOG.debug("New status for floating IP %(floatingip_id)s: " LOG.debug("New status for floating IP %(floatingip_id)s: "
"%(status)s", {'floatingip_id': floatingip_id, "%(status)s", {'floatingip_id': floatingip_id,
'status': status}) 'status': status})

View File

@ -17,7 +17,6 @@ from neutron_lib.api import converters as lib_converters
from neutron_lib.api import validators as lib_validators from neutron_lib.api import validators as lib_validators
from neutron_lib import constants from neutron_lib import constants
from neutron_lib.db import constants as db_const from neutron_lib.db import constants as db_const
import six
import webob.exc import webob.exc
from neutron._i18n import _ from neutron._i18n import _
@ -305,7 +304,7 @@ def get_collection_info(collection):
def fill_default_value(attr_info, res_dict, def fill_default_value(attr_info, res_dict,
exc_cls=ValueError, exc_cls=ValueError,
check_allow_post=True): check_allow_post=True):
for attr, attr_vals in six.iteritems(attr_info): for attr, attr_vals in attr_info.items():
if attr_vals['allow_post']: if attr_vals['allow_post']:
if 'default' not in attr_vals and attr not in res_dict: if 'default' not in attr_vals and attr not in res_dict:
msg = _("Failed to parse request. Required " msg = _("Failed to parse request. Required "
@ -320,7 +319,7 @@ def fill_default_value(attr_info, res_dict,
def convert_value(attr_info, res_dict, exc_cls=ValueError): def convert_value(attr_info, res_dict, exc_cls=ValueError):
for attr, attr_vals in six.iteritems(attr_info): for attr, attr_vals in attr_info.items():
if (attr not in res_dict or if (attr not in res_dict or
res_dict[attr] is constants.ATTR_NOT_SPECIFIED): res_dict[attr] is constants.ATTR_NOT_SPECIFIED):
continue continue

View File

@ -21,7 +21,6 @@ from neutron_lib import exceptions
from oslo_log import log as logging from oslo_log import log as logging
from oslo_policy import policy as oslo_policy from oslo_policy import policy as oslo_policy
from oslo_utils import excutils from oslo_utils import excutils
import six
import webob.exc import webob.exc
from neutron._i18n import _, _LE, _LI from neutron._i18n import _, _LE, _LI
@ -145,7 +144,7 @@ class Controller(object):
self._resource) self._resource)
def _get_primary_key(self, default_primary_key='id'): def _get_primary_key(self, default_primary_key='id'):
for key, value in six.iteritems(self._attr_info): for key, value in self._attr_info.items():
if value.get('primary_key', False): if value.get('primary_key', False):
return key return key
return default_primary_key return default_primary_key
@ -215,7 +214,7 @@ class Controller(object):
def _filter_attributes(self, data, fields_to_strip=None): def _filter_attributes(self, data, fields_to_strip=None):
if not fields_to_strip: if not fields_to_strip:
return data return data
return dict(item for item in six.iteritems(data) return dict(item for item in data.items()
if (item[0] not in fields_to_strip)) if (item[0] not in fields_to_strip))
def _do_field_list(self, original_fields): def _do_field_list(self, original_fields):
@ -625,7 +624,7 @@ class Controller(object):
# Load object to check authz # Load object to check authz
# but pass only attributes in the original body and required # but pass only attributes in the original body and required
# by the policy engine to the policy 'brain' # by the policy engine to the policy 'brain'
field_list = [name for (name, value) in six.iteritems(self._attr_info) field_list = [name for (name, value) in self._attr_info.items()
if (value.get('required_by_policy') or if (value.get('required_by_policy') or
value.get('primary_key') or value.get('primary_key') or
'default' not in value)] 'default' not in value)]
@ -723,7 +722,7 @@ class Controller(object):
attributes.fill_default_value(attr_info, res_dict, attributes.fill_default_value(attr_info, res_dict,
webob.exc.HTTPBadRequest) webob.exc.HTTPBadRequest)
else: # PUT else: # PUT
for attr, attr_vals in six.iteritems(attr_info): for attr, attr_vals in attr_info.items():
if attr in res_dict and not attr_vals['allow_put']: if attr in res_dict and not attr_vals['allow_put']:
msg = _("Cannot update read-only attribute %s") % attr msg = _("Cannot update read-only attribute %s") % attr
raise webob.exc.HTTPBadRequest(msg) raise webob.exc.HTTPBadRequest(msg)

View File

@ -18,7 +18,6 @@ from neutron_lib.plugins import directory
from oslo_config import cfg from oslo_config import cfg
from oslo_service import wsgi as base_wsgi from oslo_service import wsgi as base_wsgi
import routes as routes_mapper import routes as routes_mapper
import six
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
import webob import webob
import webob.dec import webob.dec
@ -50,7 +49,7 @@ class Index(wsgi.Application):
metadata = {} metadata = {}
layout = [] layout = []
for name, collection in six.iteritems(self.resources): for name, collection in self.resources.items():
href = urlparse.urljoin(req.path_url, collection) href = urlparse.urljoin(req.path_url, collection)
resource = {'name': name, resource = {'name': name,
'collection': collection, 'collection': collection,

View File

@ -19,7 +19,6 @@ import contextlib
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
import six
from sqlalchemy.ext import associationproxy from sqlalchemy.ext import associationproxy
from neutron._i18n import _LE from neutron._i18n import _LE
@ -118,6 +117,6 @@ def filter_non_model_columns(data, model):
""" """
columns = [c.name for c in model.__table__.columns] columns = [c.name for c in model.__table__.columns]
return dict((k, v) for (k, v) in return dict((k, v) for (k, v) in
six.iteritems(data) if k in columns or data.items() if k in columns or
isinstance(getattr(model, k, None), isinstance(getattr(model, k, None),
associationproxy.AssociationProxy)) associationproxy.AssociationProxy))

View File

@ -27,7 +27,6 @@ import oslo_messaging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import importutils from oslo_utils import importutils
from oslo_utils import timeutils from oslo_utils import timeutils
import six
from sqlalchemy.orm import exc from sqlalchemy.orm import exc
from sqlalchemy import sql from sqlalchemy import sql
@ -111,8 +110,8 @@ class AgentAvailabilityZoneMixin(az_ext.AvailabilityZonePluginBase):
return [{'state': 'available' if v else 'unavailable', return [{'state': 'available' if v else 'unavailable',
'name': k[0], 'resource': k[1], 'name': k[0], 'resource': k[1],
'tenant_id': context.tenant_id} 'tenant_id': context.tenant_id}
for k, v in six.iteritems(self._list_availability_zones( for k, v in self._list_availability_zones(
context, filters))] context, filters).items()]
@db_api.retry_if_session_inactive() @db_api.retry_if_session_inactive()
def validate_availability_zones(self, context, resource_type, def validate_availability_zones(self, context, resource_type,

View File

@ -109,7 +109,7 @@ class CommonDbMixin(object):
def _apply_filters_to_query(self, query, model, filters, context=None): def _apply_filters_to_query(self, query, model, filters, context=None):
if filters: if filters:
for key, value in six.iteritems(filters): for key, value in filters.items():
column = getattr(model, key, None) column = getattr(model, key, None)
# NOTE(kevinbenton): if column is a hybrid property that # NOTE(kevinbenton): if column is a hybrid property that
# references another expression, attempting to convert to # references another expression, attempting to convert to

View File

@ -19,7 +19,6 @@ from oslo_config import cfg
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_log import log as logging from oslo_log import log as logging
import oslo_messaging import oslo_messaging
import six
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import func from sqlalchemy import func
from sqlalchemy import or_ from sqlalchemy import or_
@ -415,7 +414,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
if active is not None: if active is not None:
query = (query.filter(agent_model.Agent.admin_state_up == active)) query = (query.filter(agent_model.Agent.admin_state_up == active))
if filters: if filters:
for key, value in six.iteritems(filters): for key, value in filters.items():
column = getattr(agent_model.Agent, key, None) column = getattr(agent_model.Agent, key, None)
if column: if column:
if not value: if not value:

View File

@ -1378,7 +1378,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
marker_obj = self._get_marker_obj(context, 'floatingip', limit, marker_obj = self._get_marker_obj(context, 'floatingip', limit,
marker) marker)
if filters is not None: if filters is not None:
for key, val in six.iteritems(API_TO_DB_COLUMN_MAP): for key, val in API_TO_DB_COLUMN_MAP.items():
if key in filters: if key in filters:
filters[val] = filters.pop(key) filters[val] = filters.pop(key)

View File

@ -18,7 +18,6 @@ from oslo_config import cfg
from oslo_log import log from oslo_log import log
import pecan import pecan
from pecan import request from pecan import request
import six
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
from neutron._i18n import _LW from neutron._i18n import _LW
@ -90,7 +89,7 @@ class V2Controller(object):
pecan.abort(404) pecan.abort(404)
layout = [] layout = []
for name, collection in six.iteritems(attributes.CORE_RESOURCES): for name, collection in attributes.CORE_RESOURCES.items():
href = urlparse.urljoin(pecan.request.path_url, collection) href = urlparse.urljoin(pecan.request.path_url, collection)
resource = {'name': name, resource = {'name': name,
'collection': collection, 'collection': collection,

View File

@ -18,7 +18,6 @@ import re
from neutron_lib.utils import helpers from neutron_lib.utils import helpers
from oslo_log import log as logging from oslo_log import log as logging
import six
from neutron._i18n import _, _LE, _LW from neutron._i18n import _, _LE, _LW
from neutron.agent.linux import ip_link_support from neutron.agent.linux import ip_link_support
@ -389,7 +388,7 @@ class ESwitchManager(object):
""" """
if exclude_devices is None: if exclude_devices is None:
exclude_devices = {} exclude_devices = {}
for phys_net, dev_names in six.iteritems(device_mappings): for phys_net, dev_names in device_mappings.items():
for dev_name in dev_names: for dev_name in dev_names:
self._process_emb_switch_map(phys_net, dev_name, self._process_emb_switch_map(phys_net, dev_name,
exclude_devices) exclude_devices)

View File

@ -276,7 +276,7 @@ class SriovNicSwitchAgent(object):
"device": mac_pci_slot}) "device": mac_pci_slot})
def _clean_network_ports(self, mac_pci_slot): def _clean_network_ports(self, mac_pci_slot):
for netid, ports_list in six.iteritems(self.network_ports): for netid, ports_list in self.network_ports.items():
for port_data in ports_list: for port_data in ports_list:
if mac_pci_slot == port_data['device']: if mac_pci_slot == port_data['device']:
ports_list.remove(port_data) ports_list.remove(port_data)

View File

@ -33,7 +33,6 @@ from oslo_service import loopingcall
from oslo_service import systemd from oslo_service import systemd
from oslo_utils import netutils from oslo_utils import netutils
from osprofiler import profiler from osprofiler import profiler
import six
from six import moves from six import moves
from neutron._i18n import _, _LE, _LI, _LW from neutron._i18n import _, _LE, _LI, _LW
@ -1082,7 +1081,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
ip_wrapper = ip_lib.IPWrapper() ip_wrapper = ip_lib.IPWrapper()
ovs = ovs_lib.BaseOVS() ovs = ovs_lib.BaseOVS()
ovs_bridges = ovs.get_bridges() ovs_bridges = ovs.get_bridges()
for physical_network, bridge in six.iteritems(bridge_mappings): for physical_network, bridge in bridge_mappings.items():
LOG.info(_LI("Mapping physical network %(physical_network)s to " LOG.info(_LI("Mapping physical network %(physical_network)s to "
"bridge %(bridge)s"), "bridge %(bridge)s"),
{'physical_network': physical_network, {'physical_network': physical_network,

View File

@ -21,7 +21,6 @@ from neutron_lib import exceptions as exc
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log from oslo_log import log
from oslo_utils import excutils from oslo_utils import excutils
import six
import stevedore import stevedore
from neutron._i18n import _, _LC, _LE, _LI, _LW from neutron._i18n import _, _LC, _LE, _LI, _LW
@ -178,7 +177,7 @@ class TypeManager(stevedore.named.NamedExtensionManager):
network[provider.SEGMENTATION_ID] = segment[api.SEGMENTATION_ID] network[provider.SEGMENTATION_ID] = segment[api.SEGMENTATION_ID]
def initialize(self): def initialize(self):
for network_type, driver in six.iteritems(self.drivers): for network_type, driver in self.drivers.items():
LOG.info(_LI("Initializing driver for type '%s'"), network_type) LOG.info(_LI("Initializing driver for type '%s'"), network_type)
driver.obj.initialize() driver.obj.initialize()

View File

@ -105,7 +105,7 @@ def _should_validate_sub_attributes(attribute, sub_attr):
validate = attribute.get('validate') validate = attribute.get('validate')
return (validate and isinstance(sub_attr, collections.Iterable) and return (validate and isinstance(sub_attr, collections.Iterable) and
any([k.startswith('type:dict') and any([k.startswith('type:dict') and
v for (k, v) in six.iteritems(validate)])) v for (k, v) in validate.items()]))
def _build_subattr_match_rule(attr_name, attr, action, target): def _build_subattr_match_rule(attr_name, attr, action, target):

View File

@ -16,7 +16,6 @@ from oslo_config import cfg
from oslo_log import helpers as log_helpers from oslo_log import helpers as log_helpers
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import importutils from oslo_utils import importutils
import six
from neutron._i18n import _, _LE, _LI from neutron._i18n import _, _LE, _LI
from neutron.agent.l3 import dvr_snat_ns from neutron.agent.l3 import dvr_snat_ns
@ -129,7 +128,7 @@ class IptablesMeteringDriver(abstract_driver.MeteringAbstractDriver):
def update_routers(self, context, routers): def update_routers(self, context, routers):
# disassociate removed routers # disassociate removed routers
router_ids = set(router['id'] for router in routers) router_ids = set(router['id'] for router in routers)
for router_id, rm in six.iteritems(self.routers): for router_id, rm in self.routers.items():
if router_id not in router_ids: if router_id not in router_ids:
self._process_disassociate_metering_label(rm.router) self._process_disassociate_metering_label(rm.router)

View File

@ -90,7 +90,7 @@ def setup_test_logging(config_opts, log_dir, log_file_path_template):
def sanitize_log_path(path): def sanitize_log_path(path):
# Sanitize the string so that its log path is shell friendly # Sanitize the string so that its log path is shell friendly
replace_map = {' ': '-', '(': '_', ')': '_'} replace_map = {' ': '-', '(': '_', ')': '_'}
for s, r in six.iteritems(replace_map): for s, r in replace_map.items():
path = path.replace(s, r) path = path.replace(s, r)
return path return path
@ -212,7 +212,7 @@ class DietTestCase(base.BaseTestCase):
self.assertEqual(expect_val, actual_val) self.assertEqual(expect_val, actual_val)
def sort_dict_lists(self, dic): def sort_dict_lists(self, dic):
for key, value in six.iteritems(dic): for key, value in dic.items():
if isinstance(value, list): if isinstance(value, list):
dic[key] = sorted(value) dic[key] = sorted(value)
elif isinstance(value, dict): elif isinstance(value, dict):
@ -387,7 +387,7 @@ class BaseTestCase(DietTestCase):
test by the fixtures cleanup process. test by the fixtures cleanup process.
""" """
group = kw.pop('group', None) group = kw.pop('group', None)
for k, v in six.iteritems(kw): for k, v in kw.items():
CONF.set_override(k, v, group) CONF.set_override(k, v, group)
def setup_coreplugin(self, core_plugin=None, load_plugins=True): def setup_coreplugin(self, core_plugin=None, load_plugins=True):

View File

@ -30,7 +30,7 @@ class ConfigDict(base.AttributeDict):
:param other: dictionary to be directly modified. :param other: dictionary to be directly modified.
""" """
for key, value in six.iteritems(other): for key, value in other.items():
if isinstance(value, dict): if isinstance(value, dict):
if not isinstance(value, base.AttributeDict): if not isinstance(value, base.AttributeDict):
other[key] = base.AttributeDict(value) other[key] = base.AttributeDict(value)
@ -61,9 +61,9 @@ class ConfigFileFixture(fixtures.Fixture):
def dict_to_config_parser(self, config_dict): def dict_to_config_parser(self, config_dict):
config_parser = six.moves.configparser.ConfigParser() config_parser = six.moves.configparser.ConfigParser()
for section, section_dict in six.iteritems(config_dict): for section, section_dict in config_dict.items():
if section != 'DEFAULT': if section != 'DEFAULT':
config_parser.add_section(section) config_parser.add_section(section)
for option, value in six.iteritems(section_dict): for option, value in section_dict.items():
config_parser.set(section, option, value) config_parser.set(section, option, value)
return config_parser return config_parser

View File

@ -17,7 +17,6 @@
import mock import mock
from neutron_lib import constants from neutron_lib import constants
from neutron_lib import context from neutron_lib import context
import six
from neutron.callbacks import events from neutron.callbacks import events
from neutron.db.db_base_plugin_v2 import NeutronDbPluginV2 as db_plugin_v2 from neutron.db.db_base_plugin_v2 import NeutronDbPluginV2 as db_plugin_v2
@ -68,7 +67,7 @@ class NetworkRbacTestcase(test_plugin.NeutronDbPluginV2TestCase):
update_policy) update_policy)
policy['rbac_policy']['target_tenant'] = new_target policy['rbac_policy']['target_tenant'] = new_target
for k, v in six.iteritems(policy['rbac_policy']): for k, v in policy['rbac_policy'].items():
self.assertEqual(netrbac2[k], v) self.assertEqual(netrbac2[k], v)
def test_delete_networkrbac_in_use_fail(self): def test_delete_networkrbac_in_use_fail(self):