diff --git a/nova/api/openstack/compute/contrib/aggregates.py b/nova/api/openstack/compute/contrib/aggregates.py index d4c46abff..28839af74 100644 --- a/nova/api/openstack/compute/contrib/aggregates.py +++ b/nova/api/openstack/compute/contrib/aggregates.py @@ -17,6 +17,7 @@ import datetime +import six from webob import exc from nova.api.openstack import extensions @@ -171,7 +172,7 @@ class AggregateController(object): 'remove_host': self._remove_host, 'set_metadata': self._set_metadata, } - for action, data in body.iteritems(): + for action, data in six.iteritems(body): if action not in _actions.keys(): msg = _('Aggregates does not have %s action') % action raise exc.HTTPBadRequest(explanation=msg) diff --git a/nova/scheduler/filters/aggregate_image_properties_isolation.py b/nova/scheduler/filters/aggregate_image_properties_isolation.py index 36a35624f..c56ecb822 100644 --- a/nova/scheduler/filters/aggregate_image_properties_isolation.py +++ b/nova/scheduler/filters/aggregate_image_properties_isolation.py @@ -15,6 +15,7 @@ from oslo_config import cfg from oslo_log import log as logging +import six from nova.scheduler import filters from nova.scheduler.filters import utils @@ -50,7 +51,7 @@ class AggregateImagePropertiesIsolation(filters.BaseHostFilter): image_props = spec.get('image', {}).get('properties', {}) metadata = utils.aggregate_metadata_get_by_host(host_state) - for key, options in metadata.iteritems(): + for key, options in six.iteritems(metadata): 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 bce8a8235..b7181393a 100644 --- a/nova/scheduler/filters/aggregate_instance_extra_specs.py +++ b/nova/scheduler/filters/aggregate_instance_extra_specs.py @@ -15,6 +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 @@ -44,7 +45,7 @@ class AggregateInstanceExtraSpecsFilter(filters.BaseHostFilter): metadata = utils.aggregate_metadata_get_by_host(host_state) - for key, req in instance_type['extra_specs'].iteritems(): + for key, req in six.iteritems(instance_type['extra_specs']): # Either not scope format, or aggregate_instance_extra_specs scope scope = key.split(':', 1) if len(scope) > 1: diff --git a/nova/test.py b/nova/test.py index 5be7925d8..a7455e013 100644 --- a/nova/test.py +++ b/nova/test.py @@ -269,7 +269,7 @@ class TestCase(testtools.TestCase): def flags(self, **kw): """Override flag variables for a test.""" group = kw.pop('group', None) - for k, v in kw.iteritems(): + for k, v in six.iteritems(kw): CONF.set_override(k, v, group) def start_service(self, name, host=None, **kwargs): diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index 64fb1add6..88c258678 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -25,6 +25,7 @@ import warnings import fixtures from oslo_config import cfg from oslo_messaging import conffixture as messaging_conffixture +import six from nova.db import migration from nova.db.sqlalchemy import api as session @@ -282,7 +283,7 @@ class ConfPatcher(fixtures.Fixture): def setUp(self): super(ConfPatcher, self).setUp() - for k, v in self.args.iteritems(): + for k, v in six.iteritems(self.args): self.addCleanup(CONF.clear_override, k, self.group) CONF.set_override(k, v, self.group) diff --git a/nova/tests/unit/policy_fixture.py b/nova/tests/unit/policy_fixture.py index d3f833e44..6b815319b 100644 --- a/nova/tests/unit/policy_fixture.py +++ b/nova/tests/unit/policy_fixture.py @@ -17,6 +17,7 @@ import os import fixtures from oslo_config import cfg from oslo_serialization import jsonutils +import six from nova.openstack.common import policy as common_policy from nova import paths @@ -103,7 +104,7 @@ class RoleBasedPolicyFixture(RealPolicyFixture): policy = jsonutils.load(open(CONF.policy_file)) # Convert all actions to require specified role - for action, rule in policy.iteritems(): + for action, rule in six.iteritems(policy): policy[action] = 'role:%s' % self.role self.policy_dir = self.useFixture(fixtures.TempDir()) diff --git a/nova/utils.py b/nova/utils.py index 11dcf1eda..de414ad4e 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -837,7 +837,7 @@ def metadata_to_dict(metadata): def dict_to_metadata(metadata): result = [] - for key, value in metadata.iteritems(): + for key, value in six.iteritems(metadata): result.append(dict(key=key, value=value)) return result @@ -1076,7 +1076,7 @@ def get_system_metadata_from_image(image_meta, flavor=None): system_meta = {} prefix_format = SM_IMAGE_PROP_PREFIX + '%s' - for key, value in image_meta.get('properties', {}).iteritems(): + for key, value in six.iteritems(image_meta.get('properties', {})): new_value = safe_truncate(six.text_type(value), 255) system_meta[prefix_format % key] = new_value @@ -1104,7 +1104,7 @@ def get_image_from_system_metadata(system_meta): if not isinstance(system_meta, dict): system_meta = metadata_to_dict(system_meta) - for key, value in system_meta.iteritems(): + for key, value in six.iteritems(system_meta): if value is None: continue