Replace dict.iteritems() with six.iteritems(dict)
This patch was generated by the sixer tool version 0.2 using the "iteritems" operation: https://pypi.python.org/pypi/sixer Manual changes: - Don't change get_instance_metadata() in nova/compute/api.py: fixed by the change Ifd455e70002eb9636b87f83788384127ba6edeeb. - Don't change sqlalchemy code and nova/tests/unit/db/test_db_api.py. sqlalchemy objects cannot be converted to a dictionary using dict(obj) directly yet. It will be possible with the change I702be362a58155a28482e733e60539d36c039509. - Revert change in a comment in nova/objects/instance.py; the sixer tool is limited and don't understand comments - Reformat nova/virt/vmwareapi/driver.py to respect the 80 columns contraint Blueprint nova-python3 Change-Id: I81465661cb8a74778d70ba9b6641073f1effa49b
This commit is contained in:
parent
f56662c8ea
commit
8e93725ae6
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
import six
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
from nova.api.openstack import extensions
|
from nova.api.openstack import extensions
|
||||||
@ -171,7 +172,7 @@ class AggregateController(object):
|
|||||||
'remove_host': self._remove_host,
|
'remove_host': self._remove_host,
|
||||||
'set_metadata': self._set_metadata,
|
'set_metadata': self._set_metadata,
|
||||||
}
|
}
|
||||||
for action, data in body.iteritems():
|
for action, data in six.iteritems(body):
|
||||||
if action not in _actions.keys():
|
if action not in _actions.keys():
|
||||||
msg = _('Aggregates does not have %s action') % action
|
msg = _('Aggregates does not have %s action') % action
|
||||||
raise exc.HTTPBadRequest(explanation=msg)
|
raise exc.HTTPBadRequest(explanation=msg)
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
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 six
|
||||||
|
|
||||||
from nova.scheduler import filters
|
from nova.scheduler import filters
|
||||||
from nova.scheduler.filters import utils
|
from nova.scheduler.filters import utils
|
||||||
@ -50,7 +51,7 @@ class AggregateImagePropertiesIsolation(filters.BaseHostFilter):
|
|||||||
image_props = spec.get('image', {}).get('properties', {})
|
image_props = spec.get('image', {}).get('properties', {})
|
||||||
metadata = utils.aggregate_metadata_get_by_host(host_state)
|
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
|
if (cfg_namespace and
|
||||||
not key.startswith(cfg_namespace + cfg_separator)):
|
not key.startswith(cfg_namespace + cfg_separator)):
|
||||||
continue
|
continue
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
import six
|
||||||
|
|
||||||
from nova.scheduler import filters
|
from nova.scheduler import filters
|
||||||
from nova.scheduler.filters import extra_specs_ops
|
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)
|
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
|
# Either not scope format, or aggregate_instance_extra_specs scope
|
||||||
scope = key.split(':', 1)
|
scope = key.split(':', 1)
|
||||||
if len(scope) > 1:
|
if len(scope) > 1:
|
||||||
|
@ -269,7 +269,7 @@ class TestCase(testtools.TestCase):
|
|||||||
def flags(self, **kw):
|
def flags(self, **kw):
|
||||||
"""Override flag variables for a test."""
|
"""Override flag variables for a test."""
|
||||||
group = kw.pop('group', None)
|
group = kw.pop('group', None)
|
||||||
for k, v in kw.iteritems():
|
for k, v in six.iteritems(kw):
|
||||||
CONF.set_override(k, v, group)
|
CONF.set_override(k, v, group)
|
||||||
|
|
||||||
def start_service(self, name, host=None, **kwargs):
|
def start_service(self, name, host=None, **kwargs):
|
||||||
|
@ -25,6 +25,7 @@ import warnings
|
|||||||
import fixtures
|
import fixtures
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_messaging import conffixture as messaging_conffixture
|
from oslo_messaging import conffixture as messaging_conffixture
|
||||||
|
import six
|
||||||
|
|
||||||
from nova.db import migration
|
from nova.db import migration
|
||||||
from nova.db.sqlalchemy import api as session
|
from nova.db.sqlalchemy import api as session
|
||||||
@ -282,7 +283,7 @@ class ConfPatcher(fixtures.Fixture):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ConfPatcher, self).setUp()
|
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)
|
self.addCleanup(CONF.clear_override, k, self.group)
|
||||||
CONF.set_override(k, v, self.group)
|
CONF.set_override(k, v, self.group)
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import os
|
|||||||
import fixtures
|
import fixtures
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
|
import six
|
||||||
|
|
||||||
from nova.openstack.common import policy as common_policy
|
from nova.openstack.common import policy as common_policy
|
||||||
from nova import paths
|
from nova import paths
|
||||||
@ -103,7 +104,7 @@ class RoleBasedPolicyFixture(RealPolicyFixture):
|
|||||||
policy = jsonutils.load(open(CONF.policy_file))
|
policy = jsonutils.load(open(CONF.policy_file))
|
||||||
|
|
||||||
# Convert all actions to require specified role
|
# 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
|
policy[action] = 'role:%s' % self.role
|
||||||
|
|
||||||
self.policy_dir = self.useFixture(fixtures.TempDir())
|
self.policy_dir = self.useFixture(fixtures.TempDir())
|
||||||
|
@ -837,7 +837,7 @@ def metadata_to_dict(metadata):
|
|||||||
|
|
||||||
def dict_to_metadata(metadata):
|
def dict_to_metadata(metadata):
|
||||||
result = []
|
result = []
|
||||||
for key, value in metadata.iteritems():
|
for key, value in six.iteritems(metadata):
|
||||||
result.append(dict(key=key, value=value))
|
result.append(dict(key=key, value=value))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -1076,7 +1076,7 @@ def get_system_metadata_from_image(image_meta, flavor=None):
|
|||||||
system_meta = {}
|
system_meta = {}
|
||||||
prefix_format = SM_IMAGE_PROP_PREFIX + '%s'
|
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)
|
new_value = safe_truncate(six.text_type(value), 255)
|
||||||
system_meta[prefix_format % key] = new_value
|
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):
|
if not isinstance(system_meta, dict):
|
||||||
system_meta = metadata_to_dict(system_meta)
|
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:
|
if value is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user