Merge "Remove six.iteritems/itervalues/iterkeys"

This commit is contained in:
Zuul 2020-11-09 16:34:13 +00:00 committed by Gerrit Code Review
commit 6898cf2765
12 changed files with 14 additions and 21 deletions

View File

@ -16,7 +16,6 @@
"""The hosts admin extension."""
from oslo_log import log as logging
import six
import webob.exc
from nova.api.openstack import common
@ -287,6 +286,6 @@ class HostController(wsgi.Controller):
instances))
by_proj_resources = self._get_resources_by_project(host_name,
instances)
for resource in six.itervalues(by_proj_resources):
for resource in by_proj_resources.values():
resources.append({'resource': resource})
return {'host': resources}

View File

@ -2584,8 +2584,7 @@ class PlacementCommands(object):
raise
# Verify every allocations for each consumer UUID
for consumer_uuid, consumer_resources in six.iteritems(
pallocs.allocations):
for consumer_uuid, consumer_resources in pallocs.allocations.items():
consumer_allocs = consumer_resources['resources']
if any(rc in NOVA_RCS
for rc in consumer_allocs):

View File

@ -25,7 +25,6 @@ import os_traits
from oslo_concurrency import lockutils
from oslo_log import log as logging
from oslo_utils import uuidutils
import six
from nova.i18n import _
@ -255,7 +254,7 @@ class ProviderTree(object):
@property
def roots(self):
return six.itervalues(self.roots_by_uuid)
return self.roots_by_uuid.values()
def get_provider_uuids(self, name_or_uuid=None):
"""Return a list, in top-down traversable order, of the UUIDs of all

View File

@ -29,7 +29,6 @@ except ImportError:
import iso8601
from oslo_log import log as logging
from oslo_utils import timeutils
import six
import nova.conf
from nova import context as context_module
@ -600,7 +599,7 @@ class HostManager(object):
return name_to_cls_map.values()
else:
return []
hosts = six.itervalues(name_to_cls_map)
hosts = name_to_cls_map.values()
return self.filter_handler.get_filtered_objects(self.enabled_filters,
hosts, spec_obj, index)

View File

@ -549,7 +549,7 @@ class TestCase(base.BaseTestCase):
self.assertEqual(
expected_keys, observed_keys,
'path: %s. Dict keys are not equal' % path)
for key in list(six.iterkeys(expected)):
for key in expected:
inner(expected[key], observed[key], path + '.%s' % key)
elif (isinstance(expected, (list, tuple, set)) and
isinstance(observed, (list, tuple, set))):

View File

@ -14,7 +14,6 @@
# under the License.
from oslo_serialization import jsonutils
import six
from nova import objects
from nova import test
@ -120,7 +119,7 @@ class ExtendedIpsTestV21(test.TestCase):
return jsonutils.loads(body).get('servers')
def _get_ips(self, server):
for network in six.itervalues(server['addresses']):
for network in server['addresses'].values():
for ip in network:
yield ip

View File

@ -14,7 +14,6 @@
# under the License.
from oslo_serialization import jsonutils
import six
from nova import objects
from nova import test
@ -125,7 +124,7 @@ class ExtendedIpsMacTestV21(test.TestCase):
return jsonutils.loads(body).get('servers')
def _get_ips(self, server):
for network in six.itervalues(server['addresses']):
for network in server['addresses'].values():
for ip in network:
yield ip

View File

@ -129,7 +129,7 @@ class InstanceActionsTestV21(test.NoDBTestCase):
def fake_get_actions(context, uuid, limit=None, marker=None,
filters=None):
actions = []
for act in six.itervalues(self.fake_actions[uuid]):
for act in self.fake_actions[uuid].values():
action = models.InstanceAction()
action.update(act)
actions.append(action)

View File

@ -12,7 +12,6 @@
import mock
from oslo_serialization import jsonutils
import six
import testscenarios
import webob
@ -747,7 +746,7 @@ class ResourceTest(MicroversionedTest):
req = webob.Request.blank('/tests')
app = fakes.TestRouter(Controller())
response = req.get_response(app)
for val in six.itervalues(response.headers):
for val in response.headers.values():
# All headers must be utf8
self.assertThat(val, matchers.EncodedByUTF8())
self.assertEqual('1', response.headers['x-header1'])

View File

@ -6327,7 +6327,7 @@ class ArchiveTestCase(test.TestCase, ModelsObjectComparatorMixin):
def test_archive_deleted_rows_for_every_uuid_table(self):
tablenames = []
for model_class in six.itervalues(models.__dict__):
for model_class in models.__dict__.values():
if hasattr(model_class, "__tablename__"):
tablenames.append(model_class.__tablename__)
tablenames.sort()

View File

@ -956,11 +956,11 @@ class TestObjectSerializer(_BaseTestCase):
thing = {'key': obj}
primitive = ser.serialize_entity(self.context, thing)
self.assertEqual(1, len(primitive))
for item in six.itervalues(primitive):
for item in primitive.values():
self.assertNotIsInstance(item, base.NovaObject)
thing2 = ser.deserialize_entity(self.context, primitive)
self.assertEqual(1, len(thing2))
for item in six.itervalues(thing2):
for item in thing2.values():
self.assertIsInstance(item, MyObj)
# object-action updates dict case

View File

@ -804,7 +804,7 @@ class LibvirtDriver(driver.ComputeDriver):
# devices by looking up existing guest XMLs and doesn't use
# the Placement API so it works with or without a vGPU reshape.
mdevs = self._get_all_assigned_mediated_devices()
for (mdev_uuid, instance_uuid) in six.iteritems(mdevs):
for (mdev_uuid, instance_uuid) in mdevs.items():
if not self._is_existing_mdev(mdev_uuid):
dev_name = libvirt_utils.mdev_uuid2name(mdev_uuid)
dev_info = self._get_mediated_device_information(dev_name)
@ -7353,7 +7353,7 @@ class LibvirtDriver(driver.ComputeDriver):
LOG.warning('More than one allocation was passed over to libvirt '
'while at the moment libvirt only supports one. Only '
'the first allocation will be looked up.')
rp_uuid, alloc = six.next(six.iteritems(vgpu_allocations))
rp_uuid, alloc = next(iter(vgpu_allocations.items()))
vgpus_asked = alloc['resources'][orc.VGPU]
# Find if we allocated against a specific pGPU (and then the allocation