diff --git a/nova/block_device.py b/nova/block_device.py index c6f1d1c773dd..a6ec93e3005e 100644 --- a/nova/block_device.py +++ b/nova/block_device.py @@ -17,7 +17,7 @@ import re from oslo_log import log as logging from oslo_utils import strutils -import six + import nova.conf from nova import exception @@ -89,11 +89,11 @@ class BlockDeviceDict(dict): bdm_dict.get('delete_on_termination')) # NOTE (ndipanov): Never default db fields self.update({field: None for field in self._fields - do_not_default}) - self.update(list(six.iteritems(bdm_dict))) + self.update(bdm_dict.items()) def _validate(self, bdm_dict): """Basic data format validations.""" - dict_fields = set(key for key, _ in six.iteritems(bdm_dict)) + dict_fields = set(key for key, _ in bdm_dict.items()) # Check that there are no bogus fields if not (dict_fields <= @@ -139,7 +139,7 @@ class BlockDeviceDict(dict): non_computable_fields = set(['boot_index', 'disk_bus', 'guest_format', 'device_type']) - new_bdm = {fld: val for fld, val in six.iteritems(legacy_bdm) + new_bdm = {fld: val for fld, val in legacy_bdm.items() if fld in copy_over_fields} virt_name = legacy_bdm.get('virtual_name') diff --git a/nova/cells/manager.py b/nova/cells/manager.py index 2f28fc44d42c..6b90244ace23 100644 --- a/nova/cells/manager.py +++ b/nova/cells/manager.py @@ -23,7 +23,7 @@ from oslo_log import log as logging import oslo_messaging from oslo_service import periodic_task from oslo_utils import timeutils -import six + from six.moves import range from nova.cells import messaging @@ -386,7 +386,7 @@ class CellsManager(manager.Manager): totals = {} for response in responses: data = response.value_or_raise() - for key, val in six.iteritems(data): + for key, val in data.items(): totals.setdefault(key, 0) totals[key] += val return totals diff --git a/nova/cells/messaging.py b/nova/cells/messaging.py index df85fa174c0f..d8463df9dce6 100644 --- a/nova/cells/messaging.py +++ b/nova/cells/messaging.py @@ -1116,7 +1116,7 @@ class _BroadcastMessageMethods(_BaseMessageMethods): services = objects.ServiceList.get_all(message.ctxt, disabled=disabled) ret_services = [] for service in services: - for key, val in six.iteritems(filters): + for key, val in filters.items(): if getattr(service, key) != val: break else: @@ -1259,7 +1259,7 @@ class MessageRunner(object): self.response_queues = {} self.methods_by_type = {} self.our_name = CONF.cells.name - for msg_type, cls in six.iteritems(_CELL_MESSAGE_TYPE_TO_METHODS_CLS): + for msg_type, cls in _CELL_MESSAGE_TYPE_TO_METHODS_CLS.items(): self.methods_by_type[msg_type] = cls(self) self.serializer = objects_base.NovaObjectSerializer() diff --git a/nova/cells/state.py b/nova/cells/state.py index eab5c6dd0808..3d680cec56e0 100644 --- a/nova/cells/state.py +++ b/nova/cells/state.py @@ -63,7 +63,7 @@ class CellState(object): def update_db_info(self, cell_db_info): """Update cell credentials from db.""" - self.db_info = {k: v for k, v in six.iteritems(cell_db_info) + self.db_info = {k: v for k, v in cell_db_info.items() if k != 'name'} def update_capabilities(self, cell_metadata): diff --git a/nova/cmd/manage.py b/nova/cmd/manage.py index ef28ccf38658..ec91bfae997a 100644 --- a/nova/cmd/manage.py +++ b/nova/cmd/manage.py @@ -68,7 +68,7 @@ import oslo_messaging as messaging from oslo_utils import importutils from oslo_utils import uuidutils import prettytable -import six + import six.moves.urllib.parse as urlparse from nova.api.ec2 import ec2utils @@ -263,7 +263,7 @@ class ProjectCommands(object): quota = QUOTAS.get_user_quotas(ctxt, project_id, user_id) else: quota = QUOTAS.get_project_quotas(ctxt, project_id) - for key, value in six.iteritems(quota): + for key, value in quota.items(): if value['limit'] is None or value['limit'] < 0: value['limit'] = 'unlimited' print(print_format % (key, value['limit'], value['in_use'], @@ -455,7 +455,7 @@ class NetworkCommands(object): if not (cidr or cidr_v6): raise exception.NetworkNotCreated(req="cidr or cidr_v6") - kwargs = {k: v for k, v in six.iteritems(locals()) + kwargs = {k: v for k, v in locals().items() if v and k != "self"} if multi_host is not None: kwargs['multi_host'] = multi_host == 'T' @@ -710,7 +710,7 @@ class DbCommands(object): """ hits = migration.db_null_instance_uuid_scan(delete) records_found = False - for table_name, records in six.iteritems(hits): + for table_name, records in hits.items(): # Don't print anything for 0 hits if records: records_found = True @@ -862,7 +862,7 @@ class AgentBuildCommands(object): buildlist.append(agent_build) - for key, buildlist in six.iteritems(by_hypervisor): + for key, buildlist in by_hypervisor.items(): if hypervisor and key != hypervisor: continue diff --git a/nova/compute/api.py b/nova/compute/api.py index f76af12285e7..3bc39c89784a 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -392,7 +392,7 @@ class API(base.Base): # as if this is quota-controlled for forwards compatibility. # Those are only used in V2 API, from V2.1 API, those checks are # validated at API layer schema validation. - for k, v in six.iteritems(metadata): + for k, v in metadata.items(): try: utils.check_string_length(v) utils.check_string_length(k, min_length=1) @@ -2350,7 +2350,7 @@ class API(base.Base): 'system_metadata': _remap_system_metadata_filter} # copy from search_opts, doing various remappings as necessary - for opt, value in six.iteritems(search_opts): + for opt, value in search_opts.items(): # Do remappings. # Values not in the filter_mapping table are copied as-is. # If remapping is None, option is not copied @@ -4115,7 +4115,7 @@ class HostAPI(base.Base): set_zones=set_zones) ret_services = [] for service in services: - for key, val in six.iteritems(filters): + for key, val in filters.items(): if service[key] != val: break else: diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index fb3dc9eedf26..a781b215592e 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -2742,7 +2742,7 @@ def _instance_update(context, instance_uuid, values, expected, original=None): else: # Coerce all single values to singleton lists expected = {k: [None] if v is None else sqlalchemyutils.to_list(v) - for (k, v) in six.iteritems(expected)} + for (k, v) in expected.items()} # Extract 'expected_' values from values dict, as these aren't actually # updates @@ -2798,7 +2798,7 @@ def _instance_update(context, instance_uuid, values, expected, original=None): conflicts_expected = {} conflicts_actual = {} - for (field, expected_values) in six.iteritems(expected): + for (field, expected_values) in expected.items(): actual = original[field] if actual not in expected_values: conflicts_expected[field] = expected_values diff --git a/nova/exception.py b/nova/exception.py index 34948258b18d..218b71b7630b 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -23,7 +23,7 @@ SHOULD include dedicated exception logging. """ from oslo_log import log as logging -import six + import webob.exc from webob import util as woutil @@ -89,7 +89,7 @@ class NovaException(Exception): # kwargs doesn't match a variable in the message # log the issue and the kwargs LOG.exception(_LE('Exception in string format operation')) - for name, value in six.iteritems(kwargs): + for name, value in kwargs.items(): LOG.error("%s: %s" % (name, value)) # noqa message = self.msg_fmt diff --git a/nova/exception_wrapper.py b/nova/exception_wrapper.py index 5b74c3b72ff4..9898898a05f0 100644 --- a/nova/exception_wrapper.py +++ b/nova/exception_wrapper.py @@ -14,7 +14,7 @@ import functools import inspect from oslo_utils import excutils -import six + import nova.conf from nova.notifications.objects import base @@ -91,4 +91,4 @@ def _get_call_dict(function, self, context, *args, **kw): def _cleanse_dict(original): """Strip all admin_password, new_pass, rescue_pass keys from a dict.""" - return {k: v for k, v in six.iteritems(original) if "_pass" not in k} + return {k: v for k, v in original.items() if "_pass" not in k} diff --git a/nova/hacking/checks.py b/nova/hacking/checks.py index 1607ec52b1ac..de9b49c88b24 100644 --- a/nova/hacking/checks.py +++ b/nova/hacking/checks.py @@ -731,7 +731,7 @@ def check_doubled_words(physical_line, filename): def check_python3_no_iteritems(logical_line): - msg = ("N344: Use six.iteritems() instead of dict.iteritems().") + msg = ("N344: Use items() instead of dict.iteritems().") if re.search(r".*\.iteritems\(\)", logical_line): yield(0, msg) diff --git a/nova/image/glance.py b/nova/image/glance.py index 7153f7ca389e..bfa35bb2baee 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -201,7 +201,7 @@ class GlanceImageService(object): self._download_handlers = {} download_modules = image_xfers.load_transfer_modules() - for scheme, mod in six.iteritems(download_modules): + for scheme, mod in download_modules.items(): if scheme not in CONF.glance.allowed_direct_url_schemes: continue @@ -436,7 +436,7 @@ class GlanceImageServiceV2(object): self._download_handlers = {} download_modules = image_xfers.load_transfer_modules() - for scheme, mod in six.iteritems(download_modules): + for scheme, mod in download_modules.items(): if scheme not in CONF.glance.allowed_direct_url_schemes: continue @@ -875,9 +875,9 @@ def _translate_to_glance(image_meta): def _convert_to_v2(image_meta): output = {} - for name, value in six.iteritems(image_meta): + for name, value in image_meta.items(): if name == 'properties': - for prop_name, prop_value in six.iteritems(value): + for prop_name, prop_value in value.items(): # if allow_additional_image_properties is disabled we can't # define kernel_id and ramdisk_id as None, so we have to omit # these properties if they are not set. @@ -1018,7 +1018,7 @@ def _extract_attributes_v2(image, include_locations=False): output = {'properties': {}, 'deleted': False, 'deleted_at': None, 'disk_format': None, 'container_format': None, 'name': None, 'checksum': None} - for name, value in six.iteritems(image): + for name, value in image.items(): if (name in omit_attrs or name in include_locations_attrs and not include_locations): continue diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index d9ba636f03f3..f803afb56464 100644 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -298,7 +298,7 @@ class IptablesManager(object): elif ip_version == 6: 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: tables[table].add_chain(chain) tables[table].add_rule(chain, '-j $%s' % (chain,), @@ -365,7 +365,7 @@ class IptablesManager(object): run_as_root=True, attempts=5) all_lines = all_tables.split('\n') - for table_name, table in six.iteritems(tables): + for table_name, table in tables.items(): start, end = self._find_table(all_lines, table_name) all_lines[start:end] = self._modify_rules( all_lines[start:end], table, table_name) diff --git a/nova/network/model.py b/nova/network/model.py index ba74b5fedf84..12c30d2073e0 100644 --- a/nova/network/model.py +++ b/nova/network/model.py @@ -26,7 +26,7 @@ from nova import utils def ensure_string_keys(d): # http://bugs.python.org/issue4978 - return {str(k): v for k, v in six.iteritems(d)} + return {str(k): v for k, v in d.items()} # Constants for the 'vif_type' field in VIF class VIF_TYPE_OVS = 'ovs' diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py index ee832f1f9b36..b05681fe33ca 100644 --- a/nova/network/neutronv2/api.py +++ b/nova/network/neutronv2/api.py @@ -1945,7 +1945,7 @@ class API(base_api.NetworkAPI): with excutils.save_and_reraise_exception(): LOG.exception(_LE('Unable to access floating IP for %s'), ', '.join(['%s %s' % (k, v) - for k, v in six.iteritems(kwargs)])) + for k, v in kwargs.items()])) def _get_floating_ip_by_address(self, client, address): """Get floating IP from floating IP address.""" diff --git a/nova/notifications/base.py b/nova/notifications/base.py index 5d37f03d45f1..482d74f5f9fc 100644 --- a/nova/notifications/base.py +++ b/nova/notifications/base.py @@ -384,7 +384,7 @@ def image_meta(system_metadata): system metadata. """ image_meta = {} - for md_key, md_value in six.iteritems(system_metadata): + for md_key, md_value in system_metadata.items(): if md_key.startswith('image_'): image_meta[md_key[6:]] = md_value diff --git a/nova/objects/base.py b/nova/objects/base.py index 862668af61c8..30fbe25627f2 100644 --- a/nova/objects/base.py +++ b/nova/objects/base.py @@ -228,7 +228,7 @@ class NovaObjectSerializer(messaging.NoOpSerializer): iterable = values.__class__ if issubclass(iterable, dict): return iterable(**{k: action_fn(context, v) - for k, v in six.iteritems(values)}) + for k, v in values.items()}) else: # NOTE(danms, gibi) A set can't have an unhashable value inside, # such as a dict. Convert the set to list, which is fine, since we @@ -306,7 +306,7 @@ def serialize_args(fn): def wrapper(obj, *args, **kwargs): args = [utils.strtime(arg) if isinstance(arg, datetime.datetime) else arg for arg in args] - for k, v in six.iteritems(kwargs): + for k, v in kwargs.items(): if k == 'exc_val' and v: kwargs[k] = six.text_type(v) elif k == 'exc_tb' and v and not isinstance(v, six.string_types): diff --git a/nova/objects/build_request.py b/nova/objects/build_request.py index 399cc9b77ed9..86a4de1d0f5a 100644 --- a/nova/objects/build_request.py +++ b/nova/objects/build_request.py @@ -168,7 +168,7 @@ class BuildRequest(base.NovaObject): def _get_update_primitives(self): updates = self.obj_get_changes() - for key, value in six.iteritems(updates): + for key, value in updates.items(): if isinstance(self.fields[key], fields.ObjectField): updates[key] = jsonutils.dumps(value.obj_to_primitive()) return updates diff --git a/nova/objects/pci_device_pool.py b/nova/objects/pci_device_pool.py index a8a0b129aaef..241f55edb720 100644 --- a/nova/objects/pci_device_pool.py +++ b/nova/objects/pci_device_pool.py @@ -63,7 +63,7 @@ class PciDevicePool(base.NovaObject): def to_dict(self): pci_pool = base.obj_to_primitive(self) tags = pci_pool.pop('tags', {}) - for k, v in six.iteritems(tags): + for k, v in tags.items(): pci_pool[k] = v return pci_pool diff --git a/nova/objects/request_spec.py b/nova/objects/request_spec.py index 9c592a4f68d6..6a5980bae433 100644 --- a/nova/objects/request_spec.py +++ b/nova/objects/request_spec.py @@ -14,7 +14,7 @@ from oslo_serialization import jsonutils from oslo_utils import versionutils -import six + from nova.db.sqlalchemy import api as db from nova.db.sqlalchemy import api_models @@ -215,7 +215,7 @@ class RequestSpec(base.NovaObject): return self.scheduler_hints = { hint: value if isinstance(value, list) else [value] - for hint, value in six.iteritems(hints_dict)} + for hint, value in hints_dict.items()} @classmethod def from_primitives(cls, context, request_spec, filter_properties): diff --git a/nova/objects/resource_provider.py b/nova/objects/resource_provider.py index e5b2b802252a..dc41ae568a9a 100644 --- a/nova/objects/resource_provider.py +++ b/nova/objects/resource_provider.py @@ -571,7 +571,7 @@ class ResourceProviderList(base.ObjectListBase, base.NovaObject): # NOTE(sbauza): We want to key the dict by the resource class IDs # and we want to make sure those class names aren't incorrect. resources = {_RC_CACHE.id_from_string(r_name): amount - for r_name, amount in six.iteritems(resources)} + for r_name, amount in resources.items()} query = context.session.query(models.ResourceProvider) if name: query = query.filter(models.ResourceProvider.name == name) @@ -665,7 +665,7 @@ class ResourceProviderList(base.ObjectListBase, base.NovaObject): _INV_TBL.c.max_unit >= amount, amount % _INV_TBL.c.step_size == 0 ) - for (r_idx, amount) in six.iteritems(resources)] + for (r_idx, amount) in resources.items()] query = query.filter(sa.or_(*where_clauses)) query = query.group_by(_RP_TBL.c.uuid) # NOTE(sbauza): Only RPs having all the asked resources can be provided diff --git a/nova/pci/stats.py b/nova/pci/stats.py index 82d366dcc40e..e18467a4af10 100644 --- a/nova/pci/stats.py +++ b/nova/pci/stats.py @@ -287,7 +287,7 @@ class PciDeviceStats(object): # 'devices' shouldn't be part of stats pools = [] for pool in self.pools: - tmp = {k: v for k, v in six.iteritems(pool) if k != 'devices'} + tmp = {k: v for k, v in pool.items() if k != 'devices'} pools.append(tmp) return iter(pools) diff --git a/nova/pci/utils.py b/nova/pci/utils.py index 3030b54bf8b6..c68eaf7deafe 100644 --- a/nova/pci/utils.py +++ b/nova/pci/utils.py @@ -20,7 +20,7 @@ import os import re from oslo_log import log as logging -import six + from nova import exception from nova.i18n import _LW @@ -49,7 +49,7 @@ def pci_device_prop_match(pci_dev, specs): """ def _matching_devices(spec): - return all(pci_dev.get(k) == v for k, v in six.iteritems(spec)) + return all(pci_dev.get(k) == v for k, v in spec.items()) return any(_matching_devices(spec) for spec in specs) diff --git a/nova/policy.py b/nova/policy.py index 6f81fddec972..843c4268988f 100644 --- a/nova/policy.py +++ b/nova/policy.py @@ -22,7 +22,7 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_policy import policy from oslo_utils import excutils -import six + from nova import exception from nova.i18n import _LE, _LW @@ -89,7 +89,7 @@ def _serialize_rules(rules): rules list. """ result = [(rule_name, str(rule)) - for rule_name, rule in six.iteritems(rules)] + for rule_name, rule in rules.items()] return sorted(result, key=lambda rule: rule[0]) diff --git a/nova/quota.py b/nova/quota.py index 361f93695051..984d912a614c 100644 --- a/nova/quota.py +++ b/nova/quota.py @@ -180,7 +180,7 @@ class DbQuotaDriver(object): # Use the project quota for default user quota. proj_quotas = project_quotas or db.quota_get_all_by_project( context, project_id) - for key, value in six.iteritems(proj_quotas): + for key, value in proj_quotas.items(): if key not in user_quotas.keys(): user_quotas[key] = value user_usages = None diff --git a/nova/scheduler/filters/aggregate_image_properties_isolation.py b/nova/scheduler/filters/aggregate_image_properties_isolation.py index 0dfb384d0e7f..600c8746fa8c 100644 --- a/nova/scheduler/filters/aggregate_image_properties_isolation.py +++ b/nova/scheduler/filters/aggregate_image_properties_isolation.py @@ -14,7 +14,7 @@ # under the License. from oslo_log import log as logging -import six + import nova.conf from nova.i18n import _LW @@ -44,7 +44,7 @@ class AggregateImagePropertiesIsolation(filters.BaseHostFilter): image_props = spec_obj.image.properties if spec_obj.image else {} metadata = utils.aggregate_metadata_get_by_host(host_state) - for key, options in six.iteritems(metadata): + for key, options in metadata.items(): if (cfg_namespace and not key.startswith(cfg_namespace + cfg_separator)): continue diff --git a/nova/scheduler/filters/aggregate_instance_extra_specs.py b/nova/scheduler/filters/aggregate_instance_extra_specs.py index b57bcaf1754f..e758bb2ae160 100644 --- a/nova/scheduler/filters/aggregate_instance_extra_specs.py +++ b/nova/scheduler/filters/aggregate_instance_extra_specs.py @@ -15,7 +15,7 @@ # under the License. from oslo_log import log as logging -import six + from nova.scheduler import filters from nova.scheduler.filters import extra_specs_ops @@ -48,7 +48,7 @@ class AggregateInstanceExtraSpecsFilter(filters.BaseHostFilter): metadata = utils.aggregate_metadata_get_by_host(host_state) - for key, req in six.iteritems(instance_type.extra_specs): + for key, req in instance_type.extra_specs.items(): # Either not scope format, or aggregate_instance_extra_specs scope scope = key.split(':', 1) if len(scope) > 1: diff --git a/nova/scheduler/filters/compute_capabilities_filter.py b/nova/scheduler/filters/compute_capabilities_filter.py index ed2b043dce13..24fd05ebd7a2 100644 --- a/nova/scheduler/filters/compute_capabilities_filter.py +++ b/nova/scheduler/filters/compute_capabilities_filter.py @@ -71,7 +71,7 @@ class ComputeCapabilitiesFilter(filters.BaseHostFilter): if 'extra_specs' not in instance_type: return True - for key, req in six.iteritems(instance_type.extra_specs): + for key, req in instance_type.extra_specs.items(): # Either not scope format, or in capabilities scope scope = key.split(':') # If key does not have a namespace, the scope's size is 1, check diff --git a/nova/test.py b/nova/test.py index 85ff0d1bd49e..d0d7eb305ce5 100644 --- a/nova/test.py +++ b/nova/test.py @@ -336,7 +336,7 @@ class TestCase(testtools.TestCase): def flags(self, **kw): """Override flag variables for a test.""" group = kw.pop('group', None) - for k, v in six.iteritems(kw): + for k, v in kw.items(): CONF.set_override(k, v, group, enforce_type=True) def start_service(self, name, host=None, **kwargs): diff --git a/nova/utils.py b/nova/utils.py index d775e579aa2f..56ab18d4a8a9 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -928,7 +928,7 @@ def metadata_to_dict(metadata, include_deleted=False): def dict_to_metadata(metadata): result = [] - for key, value in six.iteritems(metadata): + for key, value in metadata.items(): result.append(dict(key=key, value=value)) return result @@ -1133,7 +1133,7 @@ def get_system_metadata_from_image(image_meta, flavor=None): system_meta = {} prefix_format = SM_IMAGE_PROP_PREFIX + '%s' - for key, value in six.iteritems(image_meta.get('properties', {})): + for key, value in image_meta.get('properties', {}).items(): if key in SM_SKIP_KEYS: continue @@ -1164,7 +1164,7 @@ def get_image_from_system_metadata(system_meta): if not isinstance(system_meta, dict): system_meta = metadata_to_dict(system_meta, include_deleted=True) - for key, value in six.iteritems(system_meta): + for key, value in system_meta.items(): if value is None: continue @@ -1295,7 +1295,7 @@ def filter_and_format_resource_metadata(resource_type, resource_list, if ids and _get_id(resource) not in ids: return {} - for k, v in six.iteritems(input_metadata): + for k, v in input_metadata.items(): # Both keys and value defined -- AND if (keys_filter and values_filter and not _match_any(keys_filter, k) and diff --git a/nova/virt/block_device.py b/nova/virt/block_device.py index b68f61544ea8..1da9d0991247 100644 --- a/nova/virt/block_device.py +++ b/nova/virt/block_device.py @@ -18,7 +18,7 @@ import itertools from oslo_log import log as logging from oslo_serialization import jsonutils from oslo_utils import excutils -import six + from nova import block_device import nova.conf @@ -154,7 +154,7 @@ class DriverBlockDevice(dict): raise NotImplementedError() def save(self): - for attr_name, key_name in six.iteritems(self._update_on_save): + for attr_name, key_name in self._update_on_save.items(): lookup_name = key_name or attr_name if self[lookup_name] != getattr(self._bdm_obj, attr_name): setattr(self._bdm_obj, attr_name, self[lookup_name]) @@ -224,7 +224,7 @@ class DriverVolumeBlockDevice(DriverBlockDevice): raise _InvalidType self.update( - {k: v for k, v in six.iteritems(self._bdm_obj) + {k: v for k, v in self._bdm_obj.items() if k in self._new_fields | set(['delete_on_termination'])} ) self['mount_device'] = self._bdm_obj.device_name diff --git a/nova/virt/diagnostics.py b/nova/virt/diagnostics.py index 2538ad1c091f..3c630c49bfa3 100644 --- a/nova/virt/diagnostics.py +++ b/nova/virt/diagnostics.py @@ -13,7 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import six from nova import exception from nova.i18n import _ @@ -174,7 +173,7 @@ class Diagnostics(object): def serialize(self): s = {} - for k, v in six.iteritems(self.__dict__): + for k, v in self.__dict__.items(): # Treat case of CpuDiagnostics, NicDiagnostics and # DiskDiagnostics - these are lists if isinstance(v, list): diff --git a/nova/virt/ironic/patcher.py b/nova/virt/ironic/patcher.py index 62c5b999daf6..5b80809e9085 100644 --- a/nova/virt/ironic/patcher.py +++ b/nova/virt/ironic/patcher.py @@ -21,7 +21,7 @@ Helper classes for Ironic HTTP PATCH creation. """ from oslo_serialization import jsonutils -import six + import nova.conf @@ -91,7 +91,7 @@ class GenericDriverFields(object): # scan through the extra_specs values and ignore the keys # not starting with keyword 'capabilities'. - for key, val in six.iteritems(extra_specs): + for key, val in extra_specs.items(): if not key.startswith('capabilities:'): continue diff --git a/nova/virt/libvirt/blockinfo.py b/nova/virt/libvirt/blockinfo.py index d93db7384688..c94943f03880 100644 --- a/nova/virt/libvirt/blockinfo.py +++ b/nova/virt/libvirt/blockinfo.py @@ -73,7 +73,7 @@ import itertools import operator from oslo_config import cfg -import six + from nova import block_device from nova import exception @@ -646,7 +646,7 @@ def get_disk_info(virt_type, instance, image_meta, def get_boot_order(disk_info): - boot_mapping = (info for name, info in six.iteritems(disk_info['mapping']) + boot_mapping = (info for name, info in disk_info['mapping'].items() if name != 'root' and info.get('boot_index') is not None) boot_devs_dup = (BOOT_DEV_FOR_TYPE[dev['type']] for dev in sorted(boot_mapping, diff --git a/nova/virt/libvirt/designer.py b/nova/virt/libvirt/designer.py index df22f02fd616..f1040b74310c 100644 --- a/nova/virt/libvirt/designer.py +++ b/nova/virt/libvirt/designer.py @@ -19,7 +19,6 @@ This module provides helper APIs for populating the config.py classes based on common operational needs / policies """ -import six from nova.pci import utils as pci_utils @@ -157,7 +156,7 @@ def set_vif_bandwidth_config(conf, inst_type): bandwidth_items = ['vif_inbound_average', 'vif_inbound_peak', 'vif_inbound_burst', 'vif_outbound_average', 'vif_outbound_peak', 'vif_outbound_burst'] - for key, value in six.iteritems(inst_type.get('extra_specs', {})): + for key, value in inst_type.get('extra_specs', {}).items(): scope = key.split(':') if len(scope) > 1 and scope[0] == 'quota': if scope[1] in bandwidth_items: diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py index 06c739b0e0b9..086b5084d9d8 100644 --- a/nova/virt/libvirt/imagebackend.py +++ b/nova/virt/libvirt/imagebackend.py @@ -152,7 +152,7 @@ class Image(object): tune_items = ['disk_read_bytes_sec', 'disk_read_iops_sec', 'disk_write_bytes_sec', 'disk_write_iops_sec', 'disk_total_bytes_sec', 'disk_total_iops_sec'] - for key, value in six.iteritems(extra_specs): + for key, value in extra_specs.items(): scope = key.split(':') if len(scope) > 1 and scope[0] == 'quota': if scope[1] in tune_items: @@ -337,7 +337,7 @@ class Image(object): with open(self.disk_info_path) as disk_info_file: line = disk_info_file.read().rstrip() dct = _dict_from_line(line) - for path, driver_format in six.iteritems(dct): + for path, driver_format in dct.items(): if path == self.path: return driver_format driver_format = self._get_driver_format() diff --git a/nova/virt/libvirt/volume/volume.py b/nova/virt/libvirt/volume/volume.py index fff56c7931ac..d4f0307bb321 100644 --- a/nova/virt/libvirt/volume/volume.py +++ b/nova/virt/libvirt/volume/volume.py @@ -17,7 +17,7 @@ """Volume drivers for libvirt.""" from oslo_log import log as logging -import six + import nova.conf from nova import exception @@ -72,7 +72,7 @@ class LibvirtBaseVolumeDriver(object): 'read_iops_sec', 'write_iops_sec'] specs = data['qos_specs'] if isinstance(specs, dict): - for k, v in six.iteritems(specs): + for k, v in specs.items(): if k in tune_opts: new_key = 'disk_' + k setattr(conf, new_key, v) diff --git a/nova/virt/vmwareapi/images.py b/nova/virt/vmwareapi/images.py index 99beeaab8923..6e1f28e81a1b 100644 --- a/nova/virt/vmwareapi/images.py +++ b/nova/virt/vmwareapi/images.py @@ -28,7 +28,7 @@ from oslo_utils import encodeutils from oslo_utils import strutils from oslo_utils import units from oslo_vmware import rw_handles -import six + from nova import exception from nova.i18n import _, _LI @@ -173,7 +173,7 @@ class VMwareImage(object): 'hw_vif_model': 'vif_model' } - for k, v in six.iteritems(props_map): + for k, v in props_map.items(): if properties.obj_attr_is_set(k): props[v] = properties.get(k) diff --git a/nova/virt/vmwareapi/vim_util.py b/nova/virt/vmwareapi/vim_util.py index 673e293da353..30340eee9295 100644 --- a/nova/virt/vmwareapi/vim_util.py +++ b/nova/virt/vmwareapi/vim_util.py @@ -18,7 +18,7 @@ The VMware API utility module. """ from oslo_vmware import vim_util as vutil -import six + import nova.conf @@ -32,7 +32,7 @@ def object_to_dict(obj, list_depth=1): are converted. """ d = {} - for k, v in six.iteritems(dict(obj)): + for k, v in dict(obj).items(): if hasattr(v, '__keylist__'): d[k] = object_to_dict(v, list_depth=list_depth) elif isinstance(v, list): diff --git a/nova/virt/vmwareapi/vm_util.py b/nova/virt/vmwareapi/vm_util.py index bfad62e9805d..067b91617842 100644 --- a/nova/virt/vmwareapi/vm_util.py +++ b/nova/virt/vmwareapi/vm_util.py @@ -29,7 +29,7 @@ from oslo_vmware import exceptions as vexc from oslo_vmware.objects import datastore as ds_obj from oslo_vmware import pbm from oslo_vmware import vim_util as vutil -import six + import nova.conf from nova import exception @@ -592,7 +592,7 @@ def get_vm_extra_config_spec(client_factory, extra_opts): config_spec = client_factory.create('ns0:VirtualMachineConfigSpec') # add the key value pairs extra_config = [] - for key, value in six.iteritems(extra_opts): + for key, value in extra_opts.items(): opt = client_factory.create('ns0:OptionValue') opt.key = key opt.value = value diff --git a/nova/virt/xenapi/driver.py b/nova/virt/xenapi/driver.py index 5db72a0f7348..1de9e03dae3d 100644 --- a/nova/virt/xenapi/driver.py +++ b/nova/virt/xenapi/driver.py @@ -29,7 +29,7 @@ from oslo_log import log as logging from oslo_serialization import jsonutils from oslo_utils import units from oslo_utils import versionutils -import six + import six.moves.urllib.parse as urlparse import nova.conf @@ -330,7 +330,7 @@ class XenAPIDriver(driver.ComputeDriver): # of mac addresses with values that are the bw counters: # e.g. {'instance-001' : { 12:34:56:78:90:12 : {'bw_in': 0, ....}} all_counters = self._vmops.get_all_bw_counters() - for instance_name, counters in six.iteritems(all_counters): + for instance_name, counters in all_counters.items(): if instance_name in imap: # yes these are stats for a nova-managed vm # correlate the stats with the nova instance uuid: diff --git a/nova/virt/xenapi/fake.py b/nova/virt/xenapi/fake.py index bc2a0870cdad..8e548d4076ef 100644 --- a/nova/virt/xenapi/fake.py +++ b/nova/virt/xenapi/fake.py @@ -59,7 +59,7 @@ from oslo_serialization import jsonutils from oslo_utils import timeutils from oslo_utils import units from oslo_utils import uuidutils -import six + from nova import exception from nova.i18n import _ @@ -560,7 +560,7 @@ class SessionBase(object): def SR_introduce(self, _1, sr_uuid, label, desc, type, content_type, shared, sm_config): - for ref, rec in six.iteritems(_db_content['SR']): + for ref, rec in _db_content['SR'].items(): if rec.get('uuid') == sr_uuid: # make forgotten = 0 and return ref _db_content['SR'][ref]['forgotten'] = 0 @@ -1079,7 +1079,7 @@ class SessionBase(object): def _get_by_field(self, recs, k, v, return_singleton): result = [] - for ref, rec in six.iteritems(recs): + for ref, rec in recs.items(): if rec.get(k) == v: result.append(ref) diff --git a/nova/virt/xenapi/host.py b/nova/virt/xenapi/host.py index 5e74f08a315b..7ff5e9b5116d 100644 --- a/nova/virt/xenapi/host.py +++ b/nova/virt/xenapi/host.py @@ -22,7 +22,7 @@ import re from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils -import six + from nova.compute import task_states from nova.compute import vm_states @@ -388,7 +388,7 @@ def _host_find(context, session, src_aggregate, host_ref): # CONF.host in the XenServer host's other-config map. # TODO(armando-migliaccio): improve according the note above uuid = session.host.get_uuid(host_ref) - for compute_host, host_uuid in six.iteritems(src_aggregate.metadetails): + for compute_host, host_uuid in src_aggregate.metadetails.items(): if host_uuid == uuid: return compute_host raise exception.NoValidHost(reason='Host %(host_uuid)s could not be found ' diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 543e7e25bb8e..b8c1f49ad484 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -537,7 +537,7 @@ def _set_vdi_info(session, vdi_ref, vdi_type, name_label, description, session.call_xenapi('VDI.set_name_description', vdi_ref, description) other_config = _get_vdi_other_config(vdi_type, instance=instance) - for key, value in six.iteritems(other_config): + for key, value in other_config.items(): if key not in existing_other_config: session.call_xenapi( "VDI.add_to_other_config", vdi_ref, key, value) @@ -1306,7 +1306,7 @@ def create_image(context, session, instance, name_label, image_id, {'image_id': image_id, 'cache': cache, 'downloaded': downloaded, 'duration': duration}) - for vdi_type, vdi in six.iteritems(vdis): + for vdi_type, vdi in vdis.items(): vdi_ref = session.call_xenapi('VDI.get_by_uuid', vdi['uuid']) _set_vdi_info(session, vdi_ref, vdi_type, name_label, vdi_type, instance) @@ -1330,7 +1330,7 @@ def _fetch_image(context, session, instance, name_label, image_id, image_type): vdis = _fetch_disk_image(context, session, instance, name_label, image_id, image_type) - for vdi_type, vdi in six.iteritems(vdis): + for vdi_type, vdi in vdis.items(): vdi_uuid = vdi['uuid'] LOG.debug("Fetched VDIs of type '%(vdi_type)s' with UUID" " '%(vdi_uuid)s'", diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 9054051e4cb6..a8d4f2fc2f30 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -664,7 +664,7 @@ class VMOps(object): vbd_refs.append(vbd_ref) # Attach original ephemeral disks - for userdevice, vdi_ref in six.iteritems(orig_vdi_refs): + for userdevice, vdi_ref in orig_vdi_refs.items(): if userdevice >= DEVICE_EPHEMERAL: vbd_ref = vm_utils.create_vbd(self._session, vm_ref, vdi_ref, userdevice, bootable=False) @@ -789,7 +789,7 @@ class VMOps(object): ephemeral_vdis = vdis.get('ephemerals') if ephemeral_vdis: # attach existing (migrated) ephemeral disks - for userdevice, ephemeral_vdi in six.iteritems(ephemeral_vdis): + for userdevice, ephemeral_vdi in ephemeral_vdis.items(): vm_utils.create_vbd(self._session, vm_ref, ephemeral_vdi['ref'], userdevice, bootable=False) @@ -1796,7 +1796,7 @@ class VMOps(object): if dom is None or dom not in counters: continue vifs_bw = bw.setdefault(name, {}) - for vif_num, vif_data in six.iteritems(counters[dom]): + for vif_num, vif_data in counters[dom].items(): mac = vif_map[vif_num] vif_data['mac_address'] = mac vifs_bw[mac] = vif_data diff --git a/nova/wsgi.py b/nova/wsgi.py index a15cae67eac9..c841b2060b56 100644 --- a/nova/wsgi.py +++ b/nova/wsgi.py @@ -386,7 +386,7 @@ class Debug(Middleware): resp = req.get_response(self.application) print(('*' * 40) + ' RESPONSE HEADERS') - for (key, value) in six.iteritems(resp.headers): + for (key, value) in resp.headers.items(): print(key, '=', value) print()