Using dict.items() is better than six.iteritems(dict)
Replacing dict.iteritems()/.itervalues() with six.iteritems(dict)/six.itervalues(dict) was preferred in the past, but there was a discussion suggesting to avoid six for this[1]. The overhead of creating a temporary list on Python 2 is negligible. [1]http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html Partially-implements blueprint py3-compatibility Change-Id: Ia2298733188b3d964d43a547504ede2ebeaba9bd
This commit is contained in:
parent
33b3183672
commit
2bc625399f
@ -18,7 +18,6 @@ import re
|
|||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import six
|
|
||||||
from six.moves.urllib import parse
|
from six.moves.urllib import parse
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
@ -193,7 +192,7 @@ def dict_to_query_str(params):
|
|||||||
# TODO(throughnothing): we should just use urllib.urlencode instead of this
|
# TODO(throughnothing): we should just use urllib.urlencode instead of this
|
||||||
# But currently we don't work with urlencoded url's
|
# But currently we don't work with urlencoded url's
|
||||||
param_str = ""
|
param_str = ""
|
||||||
for key, val in six.iteritems(params):
|
for key, val in params.items():
|
||||||
param_str = param_str + '='.join([str(key), str(val)]) + '&'
|
param_str = param_str + '='.join([str(key), str(val)]) + '&'
|
||||||
|
|
||||||
return param_str.rstrip('&')
|
return param_str.rstrip('&')
|
||||||
|
@ -96,7 +96,7 @@ class ExtensionsResource(wsgi.Resource):
|
|||||||
|
|
||||||
def index(self, req):
|
def index(self, req):
|
||||||
extensions = []
|
extensions = []
|
||||||
for _alias, ext in six.iteritems(self.extension_manager.extensions):
|
for _alias, ext in self.extension_manager.extensions.items():
|
||||||
extensions.append(self._translate(ext))
|
extensions.append(self._translate(ext))
|
||||||
return dict(extensions=extensions)
|
return dict(extensions=extensions)
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
"""The security service api."""
|
"""The security service api."""
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import six
|
|
||||||
import webob
|
import webob
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
@ -124,7 +123,7 @@ class SecurityServiceController(wsgi.Controller):
|
|||||||
not_found = object()
|
not_found = object()
|
||||||
for ss in security_services:
|
for ss in security_services:
|
||||||
if all(ss.get(opt, not_found) == value for opt, value in
|
if all(ss.get(opt, not_found) == value for opt, value in
|
||||||
six.iteritems(search_opts)):
|
search_opts.items()):
|
||||||
results.append(ss)
|
results.append(ss)
|
||||||
security_services = results
|
security_services = results
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ class ShareNetworkController(wsgi.Controller):
|
|||||||
for opt in opts_to_remove:
|
for opt in opts_to_remove:
|
||||||
search_opts.pop(opt, None)
|
search_opts.pop(opt, None)
|
||||||
if search_opts:
|
if search_opts:
|
||||||
for key, value in six.iteritems(search_opts):
|
for key, value in search_opts.items():
|
||||||
if key in ['ip_version', 'segmentation_id']:
|
if key in ['ip_version', 'segmentation_id']:
|
||||||
value = int(value)
|
value = int(value)
|
||||||
networks = [network for network in networks
|
networks = [network for network in networks
|
||||||
@ -284,7 +284,7 @@ class ShareNetworkController(wsgi.Controller):
|
|||||||
'add_security_service': self._add_security_service,
|
'add_security_service': self._add_security_service,
|
||||||
'remove_security_service': self._remove_security_service
|
'remove_security_service': self._remove_security_service
|
||||||
}
|
}
|
||||||
for action, data in six.iteritems(body):
|
for action, data in body.items():
|
||||||
try:
|
try:
|
||||||
return _actions[action](req, id, data)
|
return _actions[action](req, id, data)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -55,7 +55,7 @@ class ShareServerController(wsgi.Controller):
|
|||||||
else:
|
else:
|
||||||
s.share_network_name = s.share_network_id
|
s.share_network_name = s.share_network_id
|
||||||
if search_opts:
|
if search_opts:
|
||||||
for k, v in six.iteritems(search_opts):
|
for k, v in search_opts.items():
|
||||||
share_servers = [s for s in share_servers if
|
share_servers = [s for s in share_servers if
|
||||||
(hasattr(s, k) and
|
(hasattr(s, k) and
|
||||||
s[k] == v or k == 'share_network' and
|
s[k] == v or k == 'share_network' and
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
"""The share snapshots api."""
|
"""The share snapshots api."""
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import six
|
|
||||||
import webob
|
import webob
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
@ -208,7 +207,7 @@ class ShareSnapshotsController(wsgi.Controller, wsgi.AdminActionsMixin):
|
|||||||
snapshot.get('display_name'),
|
snapshot.get('display_name'),
|
||||||
snapshot.get('display_description'))
|
snapshot.get('display_description'))
|
||||||
return self._view_builder.detail(
|
return self._view_builder.detail(
|
||||||
req, dict(six.iteritems(new_snapshot)))
|
req, dict(new_snapshot.items()))
|
||||||
|
|
||||||
|
|
||||||
def create_resource():
|
def create_resource():
|
||||||
|
@ -33,7 +33,7 @@ class ShareTypeExtraSpecsController(wsgi.Controller):
|
|||||||
def _get_extra_specs(self, context, type_id):
|
def _get_extra_specs(self, context, type_id):
|
||||||
extra_specs = db.share_type_extra_specs_get(context, type_id)
|
extra_specs = db.share_type_extra_specs_get(context, type_id)
|
||||||
specs_dict = {}
|
specs_dict = {}
|
||||||
for key, value in six.iteritems(extra_specs):
|
for key, value in extra_specs.items():
|
||||||
specs_dict[key] = value
|
specs_dict[key] = value
|
||||||
return dict(extra_specs=specs_dict)
|
return dict(extra_specs=specs_dict)
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ class ShareTypeExtraSpecsController(wsgi.Controller):
|
|||||||
and valid_type
|
and valid_type
|
||||||
and valid_required_extra_spec)
|
and valid_required_extra_spec)
|
||||||
|
|
||||||
for k, v in six.iteritems(extra_specs):
|
for k, v in extra_specs.items():
|
||||||
if is_valid_string(k) and isinstance(v, dict):
|
if is_valid_string(k) and isinstance(v, dict):
|
||||||
self._verify_extra_specs(v)
|
self._verify_extra_specs(v)
|
||||||
elif not is_valid_extra_spec(k, v):
|
elif not is_valid_extra_spec(k, v):
|
||||||
|
@ -324,7 +324,7 @@ class ShareMixin(object):
|
|||||||
display_description,
|
display_description,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
return self._view_builder.detail(req, dict(six.iteritems(new_share)))
|
return self._view_builder.detail(req, dict(new_share.items()))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _validate_common_name(access):
|
def _validate_common_name(access):
|
||||||
|
@ -179,8 +179,7 @@ class CGSnapshotController(wsgi.Controller, wsgi.AdminActionsMixin):
|
|||||||
except exception.InvalidConsistencyGroup as e:
|
except exception.InvalidConsistencyGroup as e:
|
||||||
raise exc.HTTPConflict(explanation=six.text_type(e))
|
raise exc.HTTPConflict(explanation=six.text_type(e))
|
||||||
|
|
||||||
return self._view_builder.detail(req, dict(six.iteritems(
|
return self._view_builder.detail(req, dict(new_snapshot.items()))
|
||||||
new_snapshot)))
|
|
||||||
|
|
||||||
@wsgi.Controller.api_version('2.4', experimental=True)
|
@wsgi.Controller.api_version('2.4', experimental=True)
|
||||||
@wsgi.Controller.authorize('get_cgsnapshot')
|
@wsgi.Controller.authorize('get_cgsnapshot')
|
||||||
|
@ -213,7 +213,7 @@ class CGController(wsgi.Controller, wsgi.AdminActionsMixin):
|
|||||||
except (exception.CGSnapshotNotFound, exception.InvalidInput) as e:
|
except (exception.CGSnapshotNotFound, exception.InvalidInput) as e:
|
||||||
raise exc.HTTPBadRequest(explanation=six.text_type(e))
|
raise exc.HTTPBadRequest(explanation=six.text_type(e))
|
||||||
|
|
||||||
return self._view_builder.detail(req, dict(six.iteritems(new_cg)))
|
return self._view_builder.detail(req, dict(new_cg.items()))
|
||||||
|
|
||||||
def _update(self, *args, **kwargs):
|
def _update(self, *args, **kwargs):
|
||||||
db.consistency_group_update(*args, **kwargs)
|
db.consistency_group_update(*args, **kwargs)
|
||||||
|
@ -64,7 +64,6 @@ i18n.enable_lazy()
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from manila.common import config # Need to register global_opts # noqa
|
from manila.common import config # Need to register global_opts # noqa
|
||||||
from manila import context
|
from manila import context
|
||||||
@ -256,7 +255,7 @@ class ConfigCommands(object):
|
|||||||
"""Class for exposing the flags defined by flag_file(s)."""
|
"""Class for exposing the flags defined by flag_file(s)."""
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
for key, value in six.iteritems(CONF):
|
for key, value in CONF.items():
|
||||||
if value is not None:
|
if value is not None:
|
||||||
print('%s = %s' % (key, value))
|
print('%s = %s' % (key, value))
|
||||||
|
|
||||||
|
@ -1292,7 +1292,7 @@ def _share_get_query(context, session=None):
|
|||||||
def _metadata_refs(metadata_dict, meta_class):
|
def _metadata_refs(metadata_dict, meta_class):
|
||||||
metadata_refs = []
|
metadata_refs = []
|
||||||
if metadata_dict:
|
if metadata_dict:
|
||||||
for k, v in six.iteritems(metadata_dict):
|
for k, v in metadata_dict.items():
|
||||||
value = six.text_type(v) if isinstance(v, bool) else v
|
value = six.text_type(v) if isinstance(v, bool) else v
|
||||||
|
|
||||||
metadata_ref = meta_class()
|
metadata_ref = meta_class()
|
||||||
@ -1978,7 +1978,7 @@ def _share_metadata_update(context, share_id, metadata, delete, session=None):
|
|||||||
if delete:
|
if delete:
|
||||||
original_metadata = _share_metadata_get(context, share_id,
|
original_metadata = _share_metadata_get(context, share_id,
|
||||||
session=session)
|
session=session)
|
||||||
for meta_key, meta_value in six.iteritems(original_metadata):
|
for meta_key, meta_value in original_metadata.items():
|
||||||
if meta_key not in metadata:
|
if meta_key not in metadata:
|
||||||
meta_ref = _share_metadata_get_item(context, share_id,
|
meta_ref = _share_metadata_get_item(context, share_id,
|
||||||
meta_key,
|
meta_key,
|
||||||
@ -2900,7 +2900,7 @@ def share_type_extra_specs_update_or_create(context, share_type_id, specs):
|
|||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
spec_ref = None
|
spec_ref = None
|
||||||
for key, value in six.iteritems(specs):
|
for key, value in specs.items():
|
||||||
try:
|
try:
|
||||||
spec_ref = _share_type_extra_specs_get_item(
|
spec_ref = _share_type_extra_specs_get_item(
|
||||||
context, share_type_id, key, session)
|
context, share_type_id, key, session)
|
||||||
|
@ -22,7 +22,6 @@ SQLAlchemy models for Manila data.
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_db.sqlalchemy import models
|
from oslo_db.sqlalchemy import models
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import six
|
|
||||||
from sqlalchemy import Column, Integer, String, schema
|
from sqlalchemy import Column, Integer, String, schema
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
@ -45,7 +44,7 @@ class ManilaBase(models.ModelBase,
|
|||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
model_dict = {}
|
model_dict = {}
|
||||||
for k, v in six.iteritems(self):
|
for k, v in self.items():
|
||||||
if not issubclass(type(v), ManilaBase):
|
if not issubclass(type(v), ManilaBase):
|
||||||
model_dict[k] = v
|
model_dict[k] = v
|
||||||
return model_dict
|
return model_dict
|
||||||
|
@ -81,7 +81,7 @@ class ManilaException(Exception):
|
|||||||
self.kwargs['code'] = self.code
|
self.kwargs['code'] = self.code
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
for k, v in six.iteritems(self.kwargs):
|
for k, v in self.kwargs.items():
|
||||||
if isinstance(v, Exception):
|
if isinstance(v, Exception):
|
||||||
self.kwargs[k] = six.text_type(v)
|
self.kwargs[k] = six.text_type(v)
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ class ManilaException(Exception):
|
|||||||
# kwargs doesn't match a variable in the message
|
# kwargs doesn't match a variable in the message
|
||||||
# log the issue and the kwargs
|
# log the issue and the kwargs
|
||||||
LOG.exception(_LE('Exception in string format operation.'))
|
LOG.exception(_LE('Exception in string format operation.'))
|
||||||
for name, value in six.iteritems(kwargs):
|
for name, value in kwargs.items():
|
||||||
LOG.error(_LE("%(name)s: %(value)s"), {
|
LOG.error(_LE("%(name)s: %(value)s"), {
|
||||||
'name': name, 'value': value})
|
'name': name, 'value': value})
|
||||||
if CONF.fatal_exception_format_errors:
|
if CONF.fatal_exception_format_errors:
|
||||||
|
@ -237,7 +237,7 @@ class DbQuotaDriver(object):
|
|||||||
project_id, user_id)
|
project_id, user_id)
|
||||||
# Use the project quota for default user quota.
|
# Use the project quota for default user quota.
|
||||||
proj_quotas = db.quota_get_all_by_project(context, project_id)
|
proj_quotas = 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():
|
if key not in user_quotas.keys():
|
||||||
user_quotas[key] = value
|
user_quotas[key] = value
|
||||||
user_usages = None
|
user_usages = None
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from manila.scheduler.filters import base_host
|
from manila.scheduler.filters import base_host
|
||||||
from manila.scheduler.filters import extra_specs_ops
|
from manila.scheduler.filters import extra_specs_ops
|
||||||
|
|
||||||
@ -36,7 +34,7 @@ class CapabilitiesFilter(base_host.BaseHostFilter):
|
|||||||
if not extra_specs:
|
if not extra_specs:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
for key, req in six.iteritems(extra_specs):
|
for key, req in extra_specs.items():
|
||||||
|
|
||||||
# Either not scoped format, or in capabilities scope
|
# Either not scoped format, or in capabilities scope
|
||||||
scope = key.split(':')
|
scope = key.split(':')
|
||||||
|
@ -505,12 +505,12 @@ class HostManager(object):
|
|||||||
host_state = self.host_state_cls(
|
host_state = self.host_state_cls(
|
||||||
host,
|
host,
|
||||||
capabilities=capabilities,
|
capabilities=capabilities,
|
||||||
service=dict(six.iteritems(service)))
|
service=dict(service.items()))
|
||||||
self.host_state_map[host] = host_state
|
self.host_state_map[host] = host_state
|
||||||
|
|
||||||
# Update capabilities and attributes in host_state
|
# Update capabilities and attributes in host_state
|
||||||
host_state.update_from_share_capability(
|
host_state.update_from_share_capability(
|
||||||
capabilities, service=dict(six.iteritems(service)))
|
capabilities, service=dict(service.items()))
|
||||||
|
|
||||||
def get_all_host_states_share(self, context):
|
def get_all_host_states_share(self, context):
|
||||||
"""Returns a dict of all the hosts the HostManager knows about.
|
"""Returns a dict of all the hosts the HostManager knows about.
|
||||||
@ -579,7 +579,7 @@ class HostManager(object):
|
|||||||
if not filter_dict:
|
if not filter_dict:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
for filter_key, filter_value in six.iteritems(filter_dict):
|
for filter_key, filter_value in filter_dict.items():
|
||||||
if filter_key not in dict_to_check:
|
if filter_key not in dict_to_check:
|
||||||
return False
|
return False
|
||||||
if not re.match(filter_value, dict_to_check.get(filter_key)):
|
if not re.match(filter_value, dict_to_check.get(filter_key)):
|
||||||
|
@ -715,7 +715,7 @@ class API(base.Base):
|
|||||||
def get_snapshot(self, context, snapshot_id):
|
def get_snapshot(self, context, snapshot_id):
|
||||||
policy.check_policy(context, 'share_snapshot', 'get_snapshot')
|
policy.check_policy(context, 'share_snapshot', 'get_snapshot')
|
||||||
rv = self.db.share_snapshot_get(context, snapshot_id)
|
rv = self.db.share_snapshot_get(context, snapshot_id)
|
||||||
return dict(six.iteritems(rv))
|
return dict(rv.items())
|
||||||
|
|
||||||
def get_all_snapshots(self, context, search_opts=None,
|
def get_all_snapshots(self, context, search_opts=None,
|
||||||
sort_key='share_id', sort_dir='desc'):
|
sort_key='share_id', sort_dir='desc'):
|
||||||
@ -751,7 +751,7 @@ class API(base.Base):
|
|||||||
results = []
|
results = []
|
||||||
not_found = object()
|
not_found = object()
|
||||||
for snapshot in snapshots:
|
for snapshot in snapshots:
|
||||||
for opt, value in six.iteritems(search_opts):
|
for opt, value in search_opts.items():
|
||||||
if snapshot.get(opt, not_found) != value:
|
if snapshot.get(opt, not_found) != value:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@ -872,7 +872,7 @@ class API(base.Base):
|
|||||||
def get_share_metadata(self, context, share):
|
def get_share_metadata(self, context, share):
|
||||||
"""Get all metadata associated with a share."""
|
"""Get all metadata associated with a share."""
|
||||||
rv = self.db.share_metadata_get(context, share['id'])
|
rv = self.db.share_metadata_get(context, share['id'])
|
||||||
return dict(six.iteritems(rv))
|
return dict(rv.items())
|
||||||
|
|
||||||
@policy.wrap_check_policy('share')
|
@policy.wrap_check_policy('share')
|
||||||
def delete_share_metadata(self, context, share, key):
|
def delete_share_metadata(self, context, share, key):
|
||||||
@ -893,7 +893,7 @@ class API(base.Base):
|
|||||||
if not metadata:
|
if not metadata:
|
||||||
metadata = {}
|
metadata = {}
|
||||||
|
|
||||||
for k, v in six.iteritems(metadata):
|
for k, v in metadata.items():
|
||||||
if not k:
|
if not k:
|
||||||
msg = _("Metadata property key is blank.")
|
msg = _("Metadata property key is blank.")
|
||||||
LOG.warning(msg)
|
LOG.warning(msg)
|
||||||
|
@ -128,7 +128,7 @@ def _conf2json(conf):
|
|||||||
def _dump_to_conf(confdict, out=sys.stdout, indent=0):
|
def _dump_to_conf(confdict, out=sys.stdout, indent=0):
|
||||||
"""Output confdict in Ganesha config format."""
|
"""Output confdict in Ganesha config format."""
|
||||||
if isinstance(confdict, dict):
|
if isinstance(confdict, dict):
|
||||||
for k, v in six.iteritems(confdict):
|
for k, v in confdict.items():
|
||||||
if v is None:
|
if v is None:
|
||||||
continue
|
continue
|
||||||
out.write(' ' * (indent * IWIDTH) + k + ' ')
|
out.write(' ' * (indent * IWIDTH) + k + ' ')
|
||||||
|
@ -17,7 +17,6 @@ import os
|
|||||||
import pipes
|
import pipes
|
||||||
|
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
import six
|
|
||||||
|
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ from manila import utils
|
|||||||
def patch(base, *overlays):
|
def patch(base, *overlays):
|
||||||
"""Recursive dictionary patching."""
|
"""Recursive dictionary patching."""
|
||||||
for ovl in overlays:
|
for ovl in overlays:
|
||||||
for k, v in six.iteritems(ovl):
|
for k, v in ovl.items():
|
||||||
if isinstance(v, dict) and isinstance(base.get(k), dict):
|
if isinstance(v, dict) and isinstance(base.get(k), dict):
|
||||||
patch(base[k], v)
|
patch(base[k], v)
|
||||||
else:
|
else:
|
||||||
@ -35,7 +34,7 @@ def patch(base, *overlays):
|
|||||||
|
|
||||||
def walk(dct):
|
def walk(dct):
|
||||||
"""Recursive iteration over dictionary."""
|
"""Recursive iteration over dictionary."""
|
||||||
for k, v in six.iteritems(dct):
|
for k, v in dct.items():
|
||||||
if isinstance(v, dict):
|
if isinstance(v, dict):
|
||||||
for w in walk(v):
|
for w in walk(v):
|
||||||
yield w
|
yield w
|
||||||
|
@ -91,7 +91,7 @@ class GlusterManager(object):
|
|||||||
|
|
||||||
self.components = (address if isinstance(address, dict) else
|
self.components = (address if isinstance(address, dict) else
|
||||||
self.parse(address))
|
self.parse(address))
|
||||||
for k, v in six.iteritems(requires):
|
for k, v in requires.items():
|
||||||
if v is None:
|
if v is None:
|
||||||
continue
|
continue
|
||||||
if (self.components.get(k) is not None) != v:
|
if (self.components.get(k) is not None) != v:
|
||||||
|
@ -109,7 +109,7 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
subdict = {}
|
subdict = {}
|
||||||
for key, val in six.iteritems(PATTERN_DICT):
|
for key, val in PATTERN_DICT.items():
|
||||||
subdict[key] = val['pattern']
|
subdict[key] = val['pattern']
|
||||||
|
|
||||||
# Using templates with placeholder syntax #{<var>}
|
# Using templates with placeholder syntax #{<var>}
|
||||||
@ -131,7 +131,7 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
|
|||||||
except exception.GlusterfsException as exc:
|
except exception.GlusterfsException as exc:
|
||||||
exceptions[srvaddr] = six.text_type(exc)
|
exceptions[srvaddr] = six.text_type(exc)
|
||||||
if exceptions:
|
if exceptions:
|
||||||
for srvaddr, excmsg in six.iteritems(exceptions):
|
for srvaddr, excmsg in exceptions.items():
|
||||||
LOG.error(_LE("'gluster version' failed on server "
|
LOG.error(_LE("'gluster version' failed on server "
|
||||||
"%(server)s with: %(message)s"),
|
"%(server)s with: %(message)s"),
|
||||||
{'server': srvaddr, 'message': excmsg})
|
{'server': srvaddr, 'message': excmsg})
|
||||||
@ -139,7 +139,7 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
|
|||||||
"'gluster version' failed on servers %s") % (
|
"'gluster version' failed on servers %s") % (
|
||||||
','.join(exceptions.keys())))
|
','.join(exceptions.keys())))
|
||||||
notsupp_servers = []
|
notsupp_servers = []
|
||||||
for srvaddr, vers in six.iteritems(glusterfs_versions):
|
for srvaddr, vers in glusterfs_versions.items():
|
||||||
if common.GlusterManager.numreduct(
|
if common.GlusterManager.numreduct(
|
||||||
vers) < self.driver.GLUSTERFS_VERSION_MIN:
|
vers) < self.driver.GLUSTERFS_VERSION_MIN:
|
||||||
notsupp_servers.append(srvaddr)
|
notsupp_servers.append(srvaddr)
|
||||||
|
@ -1020,9 +1020,9 @@ class NetAppCmodeFileStorageLibrary(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
raid_types = self._client.get_aggregate_raid_types(aggregate_names)
|
raid_types = self._client.get_aggregate_raid_types(aggregate_names)
|
||||||
for aggregate_name, raid_type in six.iteritems(raid_types):
|
for aggregate_name, raid_type in raid_types.items():
|
||||||
ssc_stats[aggregate_name]['netapp_raid_type'] = raid_type
|
ssc_stats[aggregate_name]['netapp_raid_type'] = raid_type
|
||||||
|
|
||||||
disk_types = self._client.get_aggregate_disk_types(aggregate_names)
|
disk_types = self._client.get_aggregate_disk_types(aggregate_names)
|
||||||
for aggregate_name, disk_type in six.iteritems(disk_types):
|
for aggregate_name, disk_type in disk_types.items():
|
||||||
ssc_stats[aggregate_name]['netapp_disk_type'] = disk_type
|
ssc_stats[aggregate_name]['netapp_disk_type'] = disk_type
|
||||||
|
@ -873,7 +873,7 @@ class ShareManager(manager.SchedulerDependentManager):
|
|||||||
|
|
||||||
def _update_quota_usages(self, context, project_id, usages):
|
def _update_quota_usages(self, context, project_id, usages):
|
||||||
user_id = context.user_id
|
user_id = context.user_id
|
||||||
for resource, usage in six.iteritems(usages):
|
for resource, usage in usages.items():
|
||||||
try:
|
try:
|
||||||
current_usage = self.db.quota_usage_get(
|
current_usage = self.db.quota_usage_get(
|
||||||
context, project_id, resource, user_id)
|
context, project_id, resource, user_id)
|
||||||
|
@ -82,7 +82,7 @@ def get_all_types(context, inactive=0, search_opts=None):
|
|||||||
|
|
||||||
share_types = db.share_type_get_all(context, inactive, filters=filters)
|
share_types = db.share_type_get_all(context, inactive, filters=filters)
|
||||||
|
|
||||||
for type_name, type_args in six.iteritems(share_types):
|
for type_name, type_args in share_types.items():
|
||||||
required_extra_specs = {}
|
required_extra_specs = {}
|
||||||
try:
|
try:
|
||||||
required_extra_specs = get_valid_required_extra_specs(
|
required_extra_specs = get_valid_required_extra_specs(
|
||||||
@ -101,7 +101,7 @@ def get_all_types(context, inactive=0, search_opts=None):
|
|||||||
LOG.debug("Searching by: %s", search_opts)
|
LOG.debug("Searching by: %s", search_opts)
|
||||||
|
|
||||||
def _check_extra_specs_match(share_type, searchdict):
|
def _check_extra_specs_match(share_type, searchdict):
|
||||||
for k, v in six.iteritems(searchdict):
|
for k, v in searchdict.items():
|
||||||
if (k not in share_type['extra_specs'].keys()
|
if (k not in share_type['extra_specs'].keys()
|
||||||
or share_type['extra_specs'][k] != v):
|
or share_type['extra_specs'][k] != v):
|
||||||
return False
|
return False
|
||||||
@ -111,9 +111,9 @@ def get_all_types(context, inactive=0, search_opts=None):
|
|||||||
filter_mapping = {'extra_specs': _check_extra_specs_match}
|
filter_mapping = {'extra_specs': _check_extra_specs_match}
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
for type_name, type_args in six.iteritems(share_types):
|
for type_name, type_args in share_types.items():
|
||||||
# go over all filters in the list
|
# go over all filters in the list
|
||||||
for opt, values in six.iteritems(search_opts):
|
for opt, values in search_opts.items():
|
||||||
try:
|
try:
|
||||||
filter_func = filter_mapping[opt]
|
filter_func = filter_mapping[opt]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -292,11 +292,11 @@ def share_types_diff(context, share_type_id1, share_type_id2):
|
|||||||
dict1 = {}
|
dict1 = {}
|
||||||
if dict2 is None:
|
if dict2 is None:
|
||||||
dict2 = {}
|
dict2 = {}
|
||||||
for k, v in six.iteritems(dict1):
|
for k, v in dict1.items():
|
||||||
res[k] = (v, dict2.get(k))
|
res[k] = (v, dict2.get(k))
|
||||||
if k not in dict2 or res[k][0] != res[k][1]:
|
if k not in dict2 or res[k][0] != res[k][1]:
|
||||||
equal = False
|
equal = False
|
||||||
for k, v in six.iteritems(dict2):
|
for k, v in dict2.items():
|
||||||
res[k] = (dict1.get(k), v)
|
res[k] = (dict1.get(k), v)
|
||||||
if k not in dict1 or res[k][0] != res[k][1]:
|
if k not in dict1 or res[k][0] != res[k][1]:
|
||||||
equal = False
|
equal = False
|
||||||
|
@ -33,7 +33,6 @@ from oslo_config import fixture as config_fixture
|
|||||||
import oslo_i18n
|
import oslo_i18n
|
||||||
from oslo_messaging import conffixture as messaging_conffixture
|
from oslo_messaging import conffixture as messaging_conffixture
|
||||||
import oslotest.base as base_test
|
import oslotest.base as base_test
|
||||||
import six
|
|
||||||
|
|
||||||
from manila.db import migration
|
from manila.db import migration
|
||||||
from manila.db.sqlalchemy import api as db_api
|
from manila.db.sqlalchemy import api as db_api
|
||||||
@ -171,7 +170,7 @@ class TestCase(base_test.BaseTestCase):
|
|||||||
|
|
||||||
def flags(self, **kw):
|
def flags(self, **kw):
|
||||||
"""Override flag variables for a test."""
|
"""Override flag variables for a test."""
|
||||||
for k, v in six.iteritems(kw):
|
for k, v in kw.items():
|
||||||
CONF.set_override(k, v)
|
CONF.set_override(k, v)
|
||||||
|
|
||||||
def start_service(self, name, host=None, **kwargs):
|
def start_service(self, name, host=None, **kwargs):
|
||||||
|
@ -17,7 +17,6 @@ import uuid
|
|||||||
|
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import routes
|
import routes
|
||||||
import six
|
|
||||||
import webob
|
import webob
|
||||||
import webob.dec
|
import webob.dec
|
||||||
import webob.request
|
import webob.request
|
||||||
@ -96,7 +95,7 @@ class FakeToken(object):
|
|||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
FakeToken.id_count += 1
|
FakeToken.id_count += 1
|
||||||
self.id = FakeToken.id_count
|
self.id = FakeToken.id_count
|
||||||
for k, v in six.iteritems(kwargs):
|
for k, v in kwargs.items():
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import datetime
|
|||||||
import ddt
|
import ddt
|
||||||
import mock
|
import mock
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
from manila.api.v2 import share_types as types
|
from manila.api.v2 import share_types as types
|
||||||
@ -406,7 +405,7 @@ def fake_share_type_get_all(context, inactive=False, filters=None):
|
|||||||
if filters is None or filters.get('is_public', None) is None:
|
if filters is None or filters.get('is_public', None) is None:
|
||||||
return SHARE_TYPES
|
return SHARE_TYPES
|
||||||
res = {}
|
res = {}
|
||||||
for k, v in six.iteritems(SHARE_TYPES):
|
for k, v in SHARE_TYPES.items():
|
||||||
if filters['is_public'] and _has_type_access(k, context.project_id):
|
if filters['is_public'] and _has_type_access(k, context.project_id):
|
||||||
res.update({k: v})
|
res.update({k: v})
|
||||||
continue
|
continue
|
||||||
|
@ -859,8 +859,8 @@ class ShareNetworkDatabaseAPITestCase(BaseDatabaseAPITestCase):
|
|||||||
self.share_nw_dict['id'])
|
self.share_nw_dict['id'])
|
||||||
|
|
||||||
self.assertEqual(new_name, result_update['name'])
|
self.assertEqual(new_name, result_update['name'])
|
||||||
self._check_fields(expected=dict(six.iteritems(result_update)),
|
self._check_fields(expected=dict(result_update.items()),
|
||||||
actual=dict(six.iteritems(result_get)))
|
actual=dict(result_get.items()))
|
||||||
|
|
||||||
def test_update_not_found(self):
|
def test_update_not_found(self):
|
||||||
self.assertRaises(exception.ShareNetworkNotFound,
|
self.assertRaises(exception.ShareNetworkNotFound,
|
||||||
|
@ -17,7 +17,6 @@ Fakes For Scheduler tests.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
|
||||||
|
|
||||||
from manila.scheduler.drivers import filter
|
from manila.scheduler.drivers import filter
|
||||||
from manila.scheduler import host_manager
|
from manila.scheduler import host_manager
|
||||||
@ -237,7 +236,7 @@ class FakeHostManager(host_manager.HostManager):
|
|||||||
class FakeHostState(host_manager.HostState):
|
class FakeHostState(host_manager.HostState):
|
||||||
def __init__(self, host, attribute_dict):
|
def __init__(self, host, attribute_dict):
|
||||||
super(FakeHostState, self).__init__(host)
|
super(FakeHostState, self).__init__(host)
|
||||||
for (key, val) in six.iteritems(attribute_dict):
|
for (key, val) in attribute_dict.items():
|
||||||
setattr(self, key, val)
|
setattr(self, key, val)
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import tempfile
|
|||||||
import ddt
|
import ddt
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import six
|
|
||||||
|
|
||||||
from manila.common import constants
|
from manila.common import constants
|
||||||
from manila import context
|
from manila import context
|
||||||
@ -185,7 +184,7 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
|
|||||||
self.mock_object(self._layout, '_glustermanager',
|
self.mock_object(self._layout, '_glustermanager',
|
||||||
mock.Mock(side_effect=_glustermanager_calls))
|
mock.Mock(side_effect=_glustermanager_calls))
|
||||||
expected_output = {}
|
expected_output = {}
|
||||||
for q, d in six.iteritems(self.glusterfs_volumes_dict):
|
for q, d in self.glusterfs_volumes_dict.items():
|
||||||
if sharemark[q] not in (FAKE_UUID1, FAKE_UUID2):
|
if sharemark[q] not in (FAKE_UUID1, FAKE_UUID2):
|
||||||
expected_output[q] = d
|
expected_output[q] = d
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ Mock unit tests for the NetApp file share driver interfaces
|
|||||||
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import six
|
|
||||||
|
|
||||||
from manila.share.drivers.netapp.dataontap.cluster_mode import drv_multi_svm
|
from manila.share.drivers.netapp.dataontap.cluster_mode import drv_multi_svm
|
||||||
from manila.share.drivers.netapp.dataontap.cluster_mode import drv_single_svm
|
from manila.share.drivers.netapp.dataontap.cluster_mode import drv_single_svm
|
||||||
@ -59,5 +58,5 @@ class NetAppFileStorageDriverInterfaceTestCase(test.TestCase):
|
|||||||
|
|
||||||
def _get_local_functions(self, obj):
|
def _get_local_functions(self, obj):
|
||||||
"""Get function names of an object without superclass functions."""
|
"""Get function names of an object without superclass functions."""
|
||||||
return set([key for key, value in six.iteritems(type(obj).__dict__)
|
return set([key for key, value in type(obj).__dict__.items()
|
||||||
if callable(value)])
|
if callable(value)])
|
||||||
|
@ -116,7 +116,7 @@ class NetAppDriverFactoryTestCase(test.TestCase):
|
|||||||
registry = na_common.NETAPP_UNIFIED_DRIVER_REGISTRY
|
registry = na_common.NETAPP_UNIFIED_DRIVER_REGISTRY
|
||||||
|
|
||||||
for family in six.iterkeys(registry):
|
for family in six.iterkeys(registry):
|
||||||
for mode, full_class_name in six.iteritems(registry[family]):
|
for mode, full_class_name in registry[family].items():
|
||||||
|
|
||||||
config = na_fakes.create_configuration()
|
config = na_fakes.create_configuration()
|
||||||
config.local_conf.set_override('driver_handles_share_servers',
|
config.local_conf.set_override('driver_handles_share_servers',
|
||||||
|
@ -20,7 +20,6 @@ import copy
|
|||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import six
|
|
||||||
|
|
||||||
from manila.common import constants
|
from manila.common import constants
|
||||||
from manila import context
|
from manila import context
|
||||||
@ -132,7 +131,7 @@ class ShareRpcAPITestCase(test.TestCase):
|
|||||||
for arg, expected_arg in zip(self.fake_args, expected_args):
|
for arg, expected_arg in zip(self.fake_args, expected_args):
|
||||||
self.assertEqual(expected_arg, arg)
|
self.assertEqual(expected_arg, arg)
|
||||||
|
|
||||||
for kwarg, value in six.iteritems(self.fake_kwargs):
|
for kwarg, value in self.fake_kwargs.items():
|
||||||
self.assertEqual(expected_msg[kwarg], value)
|
self.assertEqual(expected_msg[kwarg], value)
|
||||||
|
|
||||||
def test_create_share_instance(self):
|
def test_create_share_instance(self):
|
||||||
|
@ -273,7 +273,7 @@ class ExceptionTest(test.TestCase):
|
|||||||
self.assertEqual(exception_type.code, resp.status_int, resp.body)
|
self.assertEqual(exception_type.code, resp.status_int, resp.body)
|
||||||
|
|
||||||
if hasattr(exception_type, 'headers'):
|
if hasattr(exception_type, 'headers'):
|
||||||
for (key, value) in six.iteritems(exception_type.headers):
|
for (key, value) in exception_type.headers.items():
|
||||||
self.assertTrue(key in resp.headers)
|
self.assertTrue(key in resp.headers)
|
||||||
self.assertEqual(value, resp.headers[key])
|
self.assertEqual(value, resp.headers[key])
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ from oslo_service import service
|
|||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from paste import deploy
|
from paste import deploy
|
||||||
import routes.middleware
|
import routes.middleware
|
||||||
import six
|
|
||||||
import webob.dec
|
import webob.dec
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
@ -440,7 +439,7 @@ class Debug(Middleware):
|
|||||||
resp = req.get_response(self.application)
|
resp = req.get_response(self.application)
|
||||||
|
|
||||||
print(('*' * 40) + ' RESPONSE HEADERS')
|
print(('*' * 40) + ' RESPONSE HEADERS')
|
||||||
for (key, value) in six.iteritems(resp.headers):
|
for (key, value) in resp.headers.items():
|
||||||
print(key, '=', value)
|
print(key, '=', value)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user