Merge "[1/3]Replace six.iteritems() with .items()"

This commit is contained in:
Jenkins 2017-01-04 16:23:03 +00:00 committed by Gerrit Code Review
commit 08653a53a6
14 changed files with 22 additions and 25 deletions

View File

@ -615,7 +615,7 @@ class InstanceMetadata(object):
path = 'openstack/%s/%s' % (version, VD2_JSON_NAME)
yield (path, self.lookup(path))
for (cid, content) in six.iteritems(self.content):
for (cid, content) in self.content.items():
yield ('%s/%s/%s' % ("openstack", CONTENT_DIR, cid), content)

View File

@ -132,8 +132,8 @@ def task_and_vm_state_from_status(statuses):
vm_states = set()
task_states = set()
lower_statuses = [status.lower() for status in statuses]
for state, task_map in six.iteritems(_STATE_MAP):
for task_state, mapped_state in six.iteritems(task_map):
for state, task_map in _STATE_MAP.items():
for task_state, mapped_state in task_map.items():
status_string = mapped_state
if status_string.lower() in lower_statuses:
vm_states.add(state)

View File

@ -43,7 +43,7 @@ def _filter_keys(item, keys):
"""Filters all model attributes except for keys
item is a dict
"""
return {k: v for k, v in six.iteritems(item) if k in keys}
return {k: v for k, v in item.items() if k in keys}
def _fixup_cell_info(cell_info, keys):

View File

@ -15,7 +15,7 @@
import copy
from oslo_log import log as logging
import six
import webob.exc
from nova.api.openstack import extensions
@ -220,7 +220,7 @@ class ExtensionInfoController(wsgi.Controller):
item['description']
)
for alias, ext in six.iteritems(self.extension_info.get_extensions()):
for alias, ext in self.extension_info.get_extensions().items():
action = ':'.join([
base_policies.COMPUTE_API, alias, 'discoverable'])
if context.can(action, fatal=False):
@ -268,7 +268,7 @@ class ExtensionInfoController(wsgi.Controller):
if req.is_legacy_v2():
self._add_vif_extension(discoverable_extensions)
sorted_ext_list = sorted(
six.iteritems(discoverable_extensions))
discoverable_extensions.items())
extensions = []
for _alias, ext in sorted_ext_list:

View File

@ -38,7 +38,7 @@ class FlavorExtraSpecsController(wsgi.Controller):
# NOTE(gmann): Max length for numeric value is being checked
# explicitly as json schema cannot have max length check for numeric value
def _check_extra_specs_value(self, specs):
for key, value in six.iteritems(specs):
for key, value in specs.items():
try:
if isinstance(value, (six.integer_types, float)):
value = six.text_type(value)

View File

@ -17,7 +17,7 @@
import itertools
import os
import six
from webob import exc
from nova.api.openstack.api_version_request \
@ -112,7 +112,7 @@ class FpingController(wsgi.Controller):
ip_list += ips
alive_ips = self.fping(ip_list)
res = []
for instance_uuid, ips in six.iteritems(instance_ips):
for instance_uuid, ips in instance_ips.items():
res.append({
"id": instance_uuid,
"project_id": instance_projects[instance_uuid],

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from webob import exc
from nova.api.openstack.api_version_request import \
@ -69,7 +69,7 @@ class ImageMetadataController(wsgi.Controller):
def create(self, req, image_id, body):
context = req.environ['nova.context']
image = self._get_image(context, image_id)
for key, value in six.iteritems(body['metadata']):
for key, value in body['metadata'].items():
image['properties'][key] = value
common.check_img_metadata_properties_quota(context,
image['properties'])

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
import webob
from nova.api.openstack.compute.schemas import quota_classes
@ -81,7 +81,7 @@ class QuotaClassSetsController(wsgi.Controller):
quota_class = id
for key, value in six.iteritems(body['quota_class_set']):
for key, value in body['quota_class_set'].items():
try:
db.quota_class_update(context, quota_class, key, value)
except exception.QuotaClassNotFound:

View File

@ -14,7 +14,7 @@
# under the License.
from oslo_utils import strutils
import six
import six.moves.urllib.parse as urlparse
import webob
@ -159,7 +159,7 @@ class QuotaSetsController(wsgi.Controller):
# NOTE(dims): Pass #1 - In this loop for quota_set.items(), we validate
# min/max values and bail out if any of the items in the set is bad.
valid_quotas = {}
for key, value in six.iteritems(body['quota_set']):
for key, value in body['quota_set'].items():
if key == 'force' or (not value and value != 0):
continue
# validate whether already used and reserved exceeds the new

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from webob import exc
from nova.api.openstack import common
@ -47,7 +47,7 @@ class ServerMetadataController(wsgi.Controller):
msg = _('Server does not exist')
raise exc.HTTPNotFound(explanation=msg)
meta_dict = {}
for key, value in six.iteritems(meta):
for key, value in meta.items():
meta_dict[key] = value
return meta_dict

View File

@ -73,7 +73,7 @@ class TenantNetworkController(wsgi.Controller):
networks = {}
for n in self.network_api.get_all(ctx):
networks[n['id']] = n['label']
return [{'id': k, 'label': v} for k, v in six.iteritems(networks)]
return [{'id': k, 'label': v} for k, v in networks.items()]
@wsgi.Controller.api_version("2.1", MAX_PROXY_API_SUPPORT_VERSION)
@extensions.expected_errors(())

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from nova.api.openstack import api_version_request
from nova.api.openstack.api_version_request \
@ -63,7 +62,7 @@ class UsedLimitsController(wsgi.Controller):
}
used_limits = {}
for display_name, key in six.iteritems(quota_map):
for display_name, key in quota_map.items():
if key in quotas:
reserved = (quotas[key]['reserved']
if self._reserved(req) else 0)

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
# This is a list of limits which needs to filter out from the API response.
# This is due to the deprecation of network related proxy APIs, the related
@ -69,7 +67,7 @@ class ViewBuilder(object):
if filter_result:
filtered_limits = FILTERED_LIMITS
limits = {}
for name, value in six.iteritems(absolute_limits):
for name, value in absolute_limits.items():
if (name in self.limit_names and
value is not None and name not in filtered_limits):
for limit_name in self.limit_names[name]:

View File

@ -137,7 +137,7 @@ class ExtensionManager(object):
"""
def sorted_extensions(self):
if self.sorted_ext_list is None:
self.sorted_ext_list = sorted(six.iteritems(self.extensions))
self.sorted_ext_list = sorted(self.extensions.items())
for _alias, ext in self.sorted_ext_list:
yield ext