py33: use six.iteritems for item iterations (part1)
Partially-implements blueprint py3-compatibility Change-Id: I0c3356cbaefeb77b6543711d79c370b3f1032683
This commit is contained in:
parent
8bec38c4b2
commit
ed197a5f10
|
@ -1,5 +1,3 @@
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
||||||
|
|
||||||
# Copyright 2010 OpenStack LLC.
|
# Copyright 2010 OpenStack LLC.
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
#
|
#
|
||||||
|
@ -19,19 +17,17 @@ import os
|
||||||
import re
|
import re
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
import six
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
from manila.api.openstack import wsgi
|
from manila.api.openstack import wsgi
|
||||||
from manila.api import xmlutil
|
from manila.api import xmlutil
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import utils
|
from manila import utils
|
||||||
from oslo.config import cfg
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
XML_NS_V1 = 'http://docs.openstack.org/volume/api/v1'
|
XML_NS_V1 = 'http://docs.openstack.org/volume/api/v1'
|
||||||
|
|
||||||
|
|
||||||
|
@ -186,7 +182,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 params.iteritems():
|
for key, val in six.iteritems(params):
|
||||||
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('&')
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
||||||
|
|
||||||
# Copyright 2011 OpenStack LLC.
|
# Copyright 2011 OpenStack LLC.
|
||||||
# Copyright 2011 Justin Santa Barbara
|
# Copyright 2011 Justin Santa Barbara
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
|
@ -18,6 +16,8 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
import six
|
||||||
import webob.dec
|
import webob.dec
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
|
@ -25,15 +25,12 @@ import manila.api.openstack
|
||||||
from manila.api.openstack import wsgi
|
from manila.api.openstack import wsgi
|
||||||
from manila.api import xmlutil
|
from manila.api import xmlutil
|
||||||
from manila import exception
|
from manila import exception
|
||||||
|
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
import manila.policy
|
import manila.policy
|
||||||
from oslo.config import cfg
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ExtensionDescriptor(object):
|
class ExtensionDescriptor(object):
|
||||||
|
@ -152,7 +149,7 @@ class ExtensionsResource(wsgi.Resource):
|
||||||
@wsgi.serializers(xml=ExtensionsTemplate)
|
@wsgi.serializers(xml=ExtensionsTemplate)
|
||||||
def index(self, req):
|
def index(self, req):
|
||||||
extensions = []
|
extensions = []
|
||||||
for _alias, ext in self.extension_manager.extensions.iteritems():
|
for _alias, ext in six.iteritems(self.extension_manager.extensions):
|
||||||
extensions.append(self._translate(ext))
|
extensions.append(self._translate(ext))
|
||||||
return dict(extensions=extensions)
|
return dict(extensions=extensions)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
||||||
|
|
||||||
# Copyright 2014 Mirantis Inc.
|
# Copyright 2014 Mirantis Inc.
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
#
|
#
|
||||||
|
@ -17,6 +15,7 @@
|
||||||
|
|
||||||
"""The security service api."""
|
"""The security service api."""
|
||||||
|
|
||||||
|
import six
|
||||||
import webob
|
import webob
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
|
@ -141,7 +140,7 @@ class SecurityServiceController(wsgi.Controller):
|
||||||
results = []
|
results = []
|
||||||
not_found = object()
|
not_found = object()
|
||||||
for service in security_services:
|
for service in security_services:
|
||||||
for opt, value in search_opts.iteritems():
|
for opt, value in six.iteritems(search_opts):
|
||||||
if service.get(opt, not_found) != value:
|
if service.get(opt, not_found) != value:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
"""The shares api."""
|
"""The shares api."""
|
||||||
|
|
||||||
|
import six
|
||||||
import webob
|
import webob
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
|
@ -141,7 +142,7 @@ class ShareNetworkController(wsgi.Controller):
|
||||||
context.project_id)
|
context.project_id)
|
||||||
|
|
||||||
if search_opts:
|
if search_opts:
|
||||||
for key, value in search_opts.iteritems():
|
for key, value in six.iteritems(search_opts):
|
||||||
networks = [network for network in networks
|
networks = [network for network in networks
|
||||||
if network[key] == value]
|
if network[key] == value]
|
||||||
return self._view_builder.build_share_networks(networks, is_detail)
|
return self._view_builder.build_share_networks(networks, is_detail)
|
||||||
|
@ -235,7 +236,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 body.iteritems():
|
for action, data in six.iteritems(body):
|
||||||
try:
|
try:
|
||||||
return _actions[action](req, id, data)
|
return _actions[action](req, id, data)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
"""The shares api."""
|
"""The shares api."""
|
||||||
|
|
||||||
|
import six
|
||||||
import webob
|
import webob
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
|
@ -256,7 +257,7 @@ class ShareController(wsgi.Controller):
|
||||||
# TODO(vish): Instance should be None at db layer instead of
|
# TODO(vish): Instance should be None at db layer instead of
|
||||||
# trying to lazy load, but for now we turn it into
|
# trying to lazy load, but for now we turn it into
|
||||||
# a dict to avoid an error.
|
# a dict to avoid an error.
|
||||||
return self._view_builder.summary(req, dict(new_share.iteritems()))
|
return self._view_builder.summary(req, dict(six.iteritems(new_share)))
|
||||||
|
|
||||||
|
|
||||||
def create_resource():
|
def create_resource():
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
||||||
|
|
||||||
# Copyright 2010-2011 OpenStack LLC.
|
# Copyright 2010-2011 OpenStack LLC.
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
#
|
#
|
||||||
|
@ -17,6 +15,8 @@
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class ViewBuilder(object):
|
||||||
"share_networks": ["maxTotalShareNetworks"],
|
"share_networks": ["maxTotalShareNetworks"],
|
||||||
}
|
}
|
||||||
limits = {}
|
limits = {}
|
||||||
for name, value in absolute_limits.iteritems():
|
for name, value in six.iteritems(absolute_limits):
|
||||||
if name in limit_names and value is not None:
|
if name in limit_names and value is not None:
|
||||||
for name in limit_names[name]:
|
for name in limit_names[name]:
|
||||||
limits[name] = value
|
limits[name] = value
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
||||||
|
|
||||||
# Copyright 2010 United States Government as represented by the
|
# Copyright 2010 United States Government as represented by the
|
||||||
# Administrator of the National Aeronautics and Space Administration.
|
# Administrator of the National Aeronautics and Space Administration.
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
|
@ -21,6 +19,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
import six
|
||||||
|
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import exception
|
from manila import exception
|
||||||
|
@ -230,7 +229,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 proj_quotas.iteritems():
|
for key, value in six.iteritems(proj_quotas):
|
||||||
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
|
||||||
|
|
|
@ -20,10 +20,10 @@ Manage hosts in the current zone.
|
||||||
import UserDict
|
import UserDict
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
import six
|
||||||
|
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import exception
|
from manila import exception
|
||||||
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.openstack.common.scheduler import filters
|
from manila.openstack.common.scheduler import filters
|
||||||
from manila.openstack.common.scheduler import weights
|
from manila.openstack.common.scheduler import weights
|
||||||
|
@ -267,12 +267,12 @@ class HostManager(object):
|
||||||
if host_state:
|
if host_state:
|
||||||
# copy capabilities to host_state.capabilities
|
# copy capabilities to host_state.capabilities
|
||||||
host_state.update_capabilities(capabilities,
|
host_state.update_capabilities(capabilities,
|
||||||
dict(service.iteritems()))
|
dict(six.iteritems(service)))
|
||||||
else:
|
else:
|
||||||
host_state = self.host_state_cls(host,
|
host_state = self.host_state_cls(host,
|
||||||
capabilities=capabilities,
|
capabilities=capabilities,
|
||||||
service=
|
service=
|
||||||
dict(service.iteritems()))
|
dict(six.iteritems(service)))
|
||||||
self.host_state_map[host] = host_state
|
self.host_state_map[host] = host_state
|
||||||
# update host_state
|
# update host_state
|
||||||
host_state.update_from_share_capability(capabilities)
|
host_state.update_from_share_capability(capabilities)
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
||||||
|
|
||||||
# Copyright 2010 United States Government as represented by the
|
# Copyright 2010 United States Government as represented by the
|
||||||
# Administrator of the National Aeronautics and Space Administration.
|
# Administrator of the National Aeronautics and Space Administration.
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
|
@ -20,6 +18,9 @@
|
||||||
Handles all requests relating to shares.
|
Handles all requests relating to shares.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
import six
|
||||||
|
|
||||||
from manila.db import base
|
from manila.db import base
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila.openstack.common import excutils
|
from manila.openstack.common import excutils
|
||||||
|
@ -30,11 +31,7 @@ from manila import quota
|
||||||
from manila.scheduler import rpcapi as scheduler_rpcapi
|
from manila.scheduler import rpcapi as scheduler_rpcapi
|
||||||
from manila.share import rpcapi as share_rpcapi
|
from manila.share import rpcapi as share_rpcapi
|
||||||
|
|
||||||
from oslo.config import cfg
|
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
GB = 1048576 * 1024
|
GB = 1048576 * 1024
|
||||||
QUOTAS = quota.QUOTAS
|
QUOTAS = quota.QUOTAS
|
||||||
|
@ -317,7 +314,7 @@ class API(base.Base):
|
||||||
results = []
|
results = []
|
||||||
not_found = object()
|
not_found = object()
|
||||||
for share in shares:
|
for share in shares:
|
||||||
for opt, value in search_opts.iteritems():
|
for opt, value in six.iteritems(search_opts):
|
||||||
if share.get(opt, not_found) != value:
|
if share.get(opt, not_found) != value:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -328,7 +325,7 @@ class API(base.Base):
|
||||||
def get_snapshot(self, context, snapshot_id):
|
def get_snapshot(self, context, snapshot_id):
|
||||||
policy.check_policy(context, 'share', 'get_snapshot')
|
policy.check_policy(context, 'share', 'get_snapshot')
|
||||||
rv = self.db.share_snapshot_get(context, snapshot_id)
|
rv = self.db.share_snapshot_get(context, snapshot_id)
|
||||||
return dict(rv.iteritems())
|
return dict(six.iteritems(rv))
|
||||||
|
|
||||||
def get_all_snapshots(self, context, search_opts=None):
|
def get_all_snapshots(self, context, search_opts=None):
|
||||||
policy.check_policy(context, 'share', 'get_all_snapshots')
|
policy.check_policy(context, 'share', 'get_all_snapshots')
|
||||||
|
@ -349,7 +346,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 search_opts.iteritems():
|
for opt, value in six.iteritems(search_opts):
|
||||||
if snapshot.get(opt, not_found) != value:
|
if snapshot.get(opt, not_found) != value:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -420,7 +417,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(rv.iteritems())
|
return dict(six.iteritems(rv))
|
||||||
|
|
||||||
@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):
|
||||||
|
@ -431,7 +428,7 @@ class API(base.Base):
|
||||||
if not metadata:
|
if not metadata:
|
||||||
metadata = {}
|
metadata = {}
|
||||||
|
|
||||||
for k, v in metadata.iteritems():
|
for k, v in six.iteritems(metadata):
|
||||||
if len(k) == 0:
|
if len(k) == 0:
|
||||||
msg = _("Metadata property key is blank")
|
msg = _("Metadata property key is blank")
|
||||||
LOG.warn(msg)
|
LOG.warn(msg)
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
import six
|
||||||
|
|
||||||
from manila import context
|
from manila import context
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ def get_all_types(context, inactive=0, search_opts={}):
|
||||||
LOG.debug("Searching by: %s" % search_opts)
|
LOG.debug("Searching by: %s" % search_opts)
|
||||||
|
|
||||||
def _check_extra_specs_match(vol_type, searchdict):
|
def _check_extra_specs_match(vol_type, searchdict):
|
||||||
for k, v in searchdict.iteritems():
|
for k, v in six.iteritems(searchdict):
|
||||||
if (k not in vol_type['extra_specs'].keys()
|
if (k not in vol_type['extra_specs'].keys()
|
||||||
or vol_type['extra_specs'][k] != v):
|
or vol_type['extra_specs'][k] != v):
|
||||||
return False
|
return False
|
||||||
|
@ -70,9 +70,9 @@ def get_all_types(context, inactive=0, search_opts={}):
|
||||||
filter_mapping = {'extra_specs': _check_extra_specs_match}
|
filter_mapping = {'extra_specs': _check_extra_specs_match}
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
for type_name, type_args in vol_types.iteritems():
|
for type_name, type_args in six.iteritems(vol_types):
|
||||||
# go over all filters in the list
|
# go over all filters in the list
|
||||||
for opt, values in search_opts.iteritems():
|
for opt, values in six.iteritems(search_opts):
|
||||||
try:
|
try:
|
||||||
filter_func = filter_mapping[opt]
|
filter_func = filter_mapping[opt]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -157,11 +157,11 @@ def volume_types_diff(context, vol_type_id1, vol_type_id2):
|
||||||
dict1 = {}
|
dict1 = {}
|
||||||
if dict2 is None:
|
if dict2 is None:
|
||||||
dict2 = {}
|
dict2 = {}
|
||||||
for k, v in dict1.iteritems():
|
for k, v in six.iteritems(dict1):
|
||||||
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 dict2.iteritems():
|
for k, v in six.iteritems(dict2):
|
||||||
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
|
||||||
|
|
|
@ -27,6 +27,7 @@ import uuid
|
||||||
import mock
|
import mock
|
||||||
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
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
|
@ -124,7 +125,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."""
|
||||||
for k, v in kw.iteritems():
|
for k, v in six.iteritems(kw):
|
||||||
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):
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
||||||
|
|
||||||
# Copyright 2010 United States Government as represented by the
|
# Copyright 2010 United States Government as represented by the
|
||||||
# Administrator of the National Aeronautics and Space Administration.
|
# Administrator of the National Aeronautics and Space Administration.
|
||||||
# Copyright 2010 OpenStack LLC.
|
# Copyright 2010 OpenStack LLC.
|
||||||
|
@ -34,11 +32,11 @@ import greenlet
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
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
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
|
||||||
|
@ -402,7 +400,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 resp.headers.iteritems():
|
for (key, value) in six.iteritems(resp.headers):
|
||||||
print(key, '=', value)
|
print(key, '=', value)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue