diff --git a/service-mgmt-api/sm-api/sm_api/api/controllers/v1/nodes.py b/service-mgmt-api/sm-api/sm_api/api/controllers/v1/nodes.py index fdf76fd1..404545d1 100644 --- a/service-mgmt-api/sm-api/sm_api/api/controllers/v1/nodes.py +++ b/service-mgmt-api/sm-api/sm_api/api/controllers/v1/nodes.py @@ -54,7 +54,7 @@ class Nodes(base.APIBase): "A list containing a self link and associated nodes links" def __init__(self, **kwargs): - self.fields = objects.sm_node.fields.keys() + self.fields = list(objects.sm_node.fields) for k in self.fields: setattr(self, k, kwargs.get(k)) diff --git a/service-mgmt-api/sm-api/sm_api/api/controllers/v1/service_groups.py b/service-mgmt-api/sm-api/sm_api/api/controllers/v1/service_groups.py index 973f9d03..ddb410be 100644 --- a/service-mgmt-api/sm-api/sm_api/api/controllers/v1/service_groups.py +++ b/service-mgmt-api/sm-api/sm_api/api/controllers/v1/service_groups.py @@ -59,7 +59,7 @@ class ServiceGroup(base.APIBase): "A list containing a self link and associated sm_sda links" def __init__(self, **kwargs): - self.fields = objects.sm_sda.fields.keys() + self.fields = list(objects.sm_sda.fields) for k in self.fields: setattr(self, k, kwargs.get(k)) diff --git a/service-mgmt-api/sm-api/sm_api/api/controllers/v1/servicenode.py b/service-mgmt-api/sm-api/sm_api/api/controllers/v1/servicenode.py index 5b04bb23..0c28350c 100755 --- a/service-mgmt-api/sm-api/sm_api/api/controllers/v1/servicenode.py +++ b/service-mgmt-api/sm-api/sm_api/api/controllers/v1/servicenode.py @@ -135,7 +135,7 @@ def rest_api_request(token, method, api_cmd, api_cmd_headers=None, request_info.add_header("Accept", "application/json") if api_cmd_headers is not None: - for header_type, header_value in api_cmd_headers.items(): + for header_type, header_value in list(api_cmd_headers.items()): request_info.add_header(header_type, header_value) if api_cmd_payload is not None: @@ -484,7 +484,7 @@ class ServiceNodeController(rest.RestController): chk_list[sda.service_group_name].remove(service_name) all_good = True - for svcs in chk_list.values(): + for svcs in list(chk_list.values()): if len(svcs) > 0: all_good = False break diff --git a/service-mgmt-api/sm-api/sm_api/api/controllers/v1/services.py b/service-mgmt-api/sm-api/sm_api/api/controllers/v1/services.py index 391f072a..e5ba0a03 100644 --- a/service-mgmt-api/sm-api/sm_api/api/controllers/v1/services.py +++ b/service-mgmt-api/sm-api/sm_api/api/controllers/v1/services.py @@ -55,7 +55,7 @@ class Services(base.APIBase): "A list containing a self link and associated services links" def __init__(self, **kwargs): - self.fields = objects.service.fields.keys() + self.fields = list(objects.service.fields) for k in self.fields: setattr(self, k, kwargs.get(k)) diff --git a/service-mgmt-api/sm-api/sm_api/api/controllers/v1/sm_sda.py b/service-mgmt-api/sm-api/sm_api/api/controllers/v1/sm_sda.py index 5a5a8500..6dc76363 100755 --- a/service-mgmt-api/sm-api/sm_api/api/controllers/v1/sm_sda.py +++ b/service-mgmt-api/sm-api/sm_api/api/controllers/v1/sm_sda.py @@ -59,7 +59,7 @@ class SmSda(base.APIBase): "A list containing a self link and associated sm_sda links" def __init__(self, **kwargs): - self.fields = objects.sm_sda.fields.keys() + self.fields = list(objects.sm_sda.fields) for k in self.fields: setattr(self, k, kwargs.get(k)) diff --git a/service-mgmt-api/sm-api/sm_api/common/exception.py b/service-mgmt-api/sm-api/sm_api/common/exception.py index eff1befa..200bad45 100644 --- a/service-mgmt-api/sm-api/sm_api/common/exception.py +++ b/service-mgmt-api/sm-api/sm_api/common/exception.py @@ -73,7 +73,7 @@ class ProcessExecutionError(IOError): def _cleanse_dict(original): """Strip all admin_password, new_pass, rescue_pass keys from a dict.""" - return dict((k, v) for k, v in original.iteritems() if not "_pass" in k) + return dict((k, v) for k, v in original.items() if not "_pass" in k) def wrap_exception(notifier=None, publisher_id=None, event_type=None, @@ -146,7 +146,7 @@ class SmApiException(Exception): # kwargs doesn't match a variable in the message # log the issue and the kwargs LOG.exception(_('Exception in string format operation')) - for name, value in kwargs.iteritems(): + for name, value in kwargs.items(): LOG.error("%s: %s" % (name, value)) if CONF.fatal_exception_format_errors: diff --git a/service-mgmt-api/sm-api/sm_api/objects/base.py b/service-mgmt-api/sm-api/sm_api/objects/base.py index 657d18e6..0137b56f 100644 --- a/service-mgmt-api/sm-api/sm_api/objects/base.py +++ b/service-mgmt-api/sm-api/sm_api/objects/base.py @@ -39,7 +39,7 @@ def get_attrname(name): def make_class_properties(cls): # NOTE(danms): Inherit Sm_apiObject's base fields only cls.fields.update(Sm_apiObject.fields) - for name, typefn in cls.fields.iteritems(): + for name, typefn in cls.fields.items(): def getter(self, name=name): attrname = get_attrname(name) @@ -120,7 +120,7 @@ def remotable(fn): if Sm_apiObject.indirection_api: updates, result = Sm_apiObject.indirection_api.object_action( ctxt, self, fn.__name__, args, kwargs) - for key, value in updates.iteritems(): + for key, value in updates.items(): if key in self.fields: self[key] = self._attr_from_primitive(key, value) self._changed_fields = set(updates.get('obj_what_changed', [])) @@ -336,7 +336,7 @@ class Sm_apiObject(object): name in self.obj_extra_fields): yield name, getattr(self, name) - items = lambda self: list(self.iteritems()) + items = lambda self: list(self.items()) def __getitem__(self, name): """For backwards-compatibility with dict-based objects. @@ -383,7 +383,7 @@ class Sm_apiObject(object): def get_defaults(cls): """Return a dict of its fields with their default value.""" return dict((k, v(None)) - for k, v in cls.fields.iteritems() + for k, v in cls.fields.items() if k != "id" and callable(v)) @@ -497,7 +497,7 @@ def obj_to_primitive(obj): return [obj_to_primitive(x) for x in obj] elif isinstance(obj, Sm_apiObject): result = {} - for key, value in obj.iteritems(): + for key, value in obj.items(): result[key] = obj_to_primitive(value) return result else: diff --git a/service-mgmt-api/sm-api/sm_api/openstack/common/db/sqlalchemy/models.py b/service-mgmt-api/sm-api/sm_api/openstack/common/db/sqlalchemy/models.py index bcbaff96..8cc0049e 100644 --- a/service-mgmt-api/sm-api/sm_api/openstack/common/db/sqlalchemy/models.py +++ b/service-mgmt-api/sm-api/sm_api/openstack/common/db/sqlalchemy/models.py @@ -64,7 +64,7 @@ class ModelBase(object): return getattr(self, key, default) def __iter__(self): - columns = dict(object_mapper(self).columns).keys() + columns = list(dict(object_mapper(self).columns)) # NOTE(russellb): Allow models to specify other keys that can be looked # up, beyond the actual db columns. An example would be the 'name' # property for an Instance. @@ -79,7 +79,7 @@ class ModelBase(object): def update(self, values): """Make the model object behave like a dict.""" - for k, v in values.iteritems(): + for k, v in values.items(): setattr(self, k, v) def iteritems(self): @@ -87,10 +87,10 @@ class ModelBase(object): Includes attributes from joins.""" local = dict(self) - joined = dict([(k, v) for k, v in self.__dict__.iteritems() + joined = dict([(k, v) for k, v in self.__dict__.items() if not k[0] == '_']) local.update(joined) - return local.iteritems() + return iter(local.items()) class TimestampMixin(object): diff --git a/service-mgmt-api/sm-api/sm_api/openstack/common/jsonutils.py b/service-mgmt-api/sm-api/sm_api/openstack/common/jsonutils.py index f7388a51..17a27655 100644 --- a/service-mgmt-api/sm-api/sm_api/openstack/common/jsonutils.py +++ b/service-mgmt-api/sm-api/sm_api/openstack/common/jsonutils.py @@ -121,7 +121,7 @@ def to_primitive(value, convert_instances=False, convert_datetime=True, level=level, max_depth=max_depth) if isinstance(value, dict): - return dict((k, recursive(v)) for k, v in value.iteritems()) + return dict((k, recursive(v)) for k, v in value.items()) elif isinstance(value, (list, tuple)): return [recursive(lv) for lv in value] @@ -134,7 +134,7 @@ def to_primitive(value, convert_instances=False, convert_datetime=True, if convert_datetime and isinstance(value, datetime.datetime): return timeutils.strtime(value) elif hasattr(value, 'iteritems'): - return recursive(dict(value.iteritems()), level=level + 1) + return recursive(dict(iter(value.items())), level=level + 1) elif hasattr(value, '__iter__'): return recursive(list(value)) elif convert_instances and hasattr(value, '__dict__'): diff --git a/service-mgmt-api/sm-api/sm_api/openstack/common/log.py b/service-mgmt-api/sm-api/sm_api/openstack/common/log.py index 9293af47..a47d957d 100644 --- a/service-mgmt-api/sm-api/sm_api/openstack/common/log.py +++ b/service-mgmt-api/sm-api/sm_api/openstack/common/log.py @@ -380,7 +380,7 @@ def _find_facility_from_conf(): facility = facility_names.get(CONF.syslog_log_facility) if facility is None: - valid_facilities = facility_names.keys() + valid_facilities = list(facility_names) consts = ['LOG_AUTH', 'LOG_AUTHPRIV', 'LOG_CRON', 'LOG_DAEMON', 'LOG_FTP', 'LOG_KERN', 'LOG_LPR', 'LOG_MAIL', 'LOG_NEWS', 'LOG_AUTH', 'LOG_SYSLOG', 'LOG_USER', 'LOG_UUCP', diff --git a/service-mgmt-api/sm-api/sm_api/openstack/common/notifier/api.py b/service-mgmt-api/sm-api/sm_api/openstack/common/notifier/api.py index 8c9e33be..bc5564ec 100644 --- a/service-mgmt-api/sm-api/sm_api/openstack/common/notifier/api.py +++ b/service-mgmt-api/sm-api/sm_api/openstack/common/notifier/api.py @@ -159,7 +159,7 @@ def _get_drivers(): for notification_driver in CONF.notification_driver: add_driver(notification_driver) - return _drivers.values() + return list(_drivers.values()) def add_driver(notification_driver): diff --git a/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/amqp.py b/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/amqp.py index f928c3d1..7ee065ab 100644 --- a/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/amqp.py +++ b/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/amqp.py @@ -240,7 +240,7 @@ def msg_reply(conf, msg_id, reply_q, connection_pool, reply=None, msg = {'result': reply, 'failure': failure} except TypeError: msg = {'result': dict((k, repr(v)) - for k, v in reply.__dict__.iteritems()), + for k, v in reply.__dict__.items()), 'failure': failure} if ending: msg['ending'] = True @@ -307,7 +307,7 @@ def pack_context(msg, context): """ context_d = dict([('_context_%s' % key, value) - for (key, value) in context.to_dict().iteritems()]) + for (key, value) in context.to_dict().items()]) msg.update(context_d) diff --git a/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/common.py b/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/common.py index 697c5e90..430ab906 100644 --- a/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/common.py +++ b/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/common.py @@ -89,7 +89,7 @@ class RPCException(Exception): # kwargs doesn't match a variable in the message # log the issue and the kwargs LOG.exception(_('Exception in string format operation')) - for name, value in kwargs.iteritems(): + for name, value in kwargs.items(): LOG.error("%s: %s" % (name, value)) # at least get the core message out if something happened message = self.message diff --git a/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/dispatcher.py b/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/dispatcher.py index 8520ab7a..cedcd926 100644 --- a/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/dispatcher.py +++ b/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/dispatcher.py @@ -125,7 +125,7 @@ class RpcDispatcher(object): :returns: A new set of deserialized args """ new_kwargs = dict() - for argname, arg in kwargs.iteritems(): + for argname, arg in kwargs.items(): new_kwargs[argname] = self.serializer.deserialize_entity(context, arg) return new_kwargs diff --git a/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/impl_kombu.py b/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/impl_kombu.py index da546afd..c5652496 100644 --- a/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/impl_kombu.py +++ b/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/impl_kombu.py @@ -432,7 +432,7 @@ class Connection(object): 'virtual_host': self.conf.rabbit_virtual_host, } - for sp_key, value in server_params.iteritems(): + for sp_key, value in server_params.items(): p_key = server_params_to_kombu_params.get(sp_key, sp_key) params[p_key] = value diff --git a/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/impl_qpid.py b/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/impl_qpid.py index ecc4d95d..4133b7dc 100644 --- a/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/impl_qpid.py +++ b/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/impl_qpid.py @@ -368,7 +368,7 @@ class Connection(object): consumers = self.consumers self.consumers = {} - for consumer in consumers.itervalues(): + for consumer in consumers.values(): consumer.reconnect(self.session) self._register_consumer(consumer) diff --git a/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/proxy.py b/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/proxy.py index cf5cdfc2..cd80ef22 100644 --- a/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/proxy.py +++ b/service-mgmt-api/sm-api/sm_api/openstack/common/rpc/proxy.py @@ -99,7 +99,7 @@ class RpcProxy(object): :returns: A new set of serialized arguments """ new_kwargs = dict() - for argname, arg in kwargs.iteritems(): + for argname, arg in kwargs.items(): new_kwargs[argname] = self.serializer.serialize_entity(context, arg) return new_kwargs diff --git a/service-mgmt-api/sm-api/sm_api/openstack/common/setup.py b/service-mgmt-api/sm-api/sm_api/openstack/common/setup.py index 137fa71f..66909ad9 100644 --- a/service-mgmt-api/sm-api/sm_api/openstack/common/setup.py +++ b/service-mgmt-api/sm-api/sm_api/openstack/common/setup.py @@ -58,7 +58,7 @@ def canonicalize_emails(changelog, mapping): """Takes in a string and an email alias mapping and replaces all instances of the aliases in the string with their real email. """ - for alias, email_address in mapping.iteritems(): + for alias, email_address in mapping.items(): changelog = changelog.replace(alias, email_address) return changelog @@ -245,7 +245,7 @@ def get_cmdclass(): for pkg in self.distribution.packages: if '.' not in pkg: os.path.walk(pkg, _find_modules, modules) - module_list = modules.keys() + module_list = list(modules.keys()) module_list.sort() autoindex_filename = os.path.join(source_dir, 'autoindex.rst') with open(autoindex_filename, 'w') as autoindex: diff --git a/service-mgmt-client/sm-client/sm_client/common/base.py b/service-mgmt-client/sm-client/sm_client/common/base.py index 3ebf2530..b6631108 100644 --- a/service-mgmt-client/sm-client/sm_client/common/base.py +++ b/service-mgmt-client/sm-client/sm_client/common/base.py @@ -99,7 +99,7 @@ class Resource(object): self._loaded = loaded def _add_details(self, info): - for (k, v) in info.iteritems(): + for (k, v) in info.items(): setattr(self, k, v) def __getattr__(self, k):