diff --git a/cinderclient/base.py b/cinderclient/base.py index 3af3de8f2..4e2907833 100644 --- a/cinderclient/base.py +++ b/cinderclient/base.py @@ -201,7 +201,7 @@ class ManagerWithFind(six.with_metaclass(abc.ABCMeta, Manager)): the Python side. """ found = [] - searches = kwargs.items() + searches = list(kwargs.items()) for obj in self.list(): try: @@ -270,8 +270,8 @@ class Resource(object): return self.__dict__[k] def __repr__(self): - reprkeys = sorted(k for k in self.__dict__.keys() if k[0] != '_' and - k != 'manager') + reprkeys = sorted(k for k in list(self.__dict__.keys()) if k[0] != '_' + and k != 'manager') info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys) return "<%s %s>" % (self.__class__.__name__, info) diff --git a/cinderclient/client.py b/cinderclient/client.py index ec51b9241..d940da48b 100644 --- a/cinderclient/client.py +++ b/cinderclient/client.py @@ -387,7 +387,7 @@ def get_client_class(version): client_path = version_map[str(version)] except (KeyError, ValueError): msg = "Invalid client version '%s'. must be one of: %s" % ( - (version, ', '.join(version_map.keys()))) + (version, ', '.join(list(version_map.keys())))) raise exceptions.UnsupportedVersion(msg) return utils.import_class(client_path) diff --git a/cinderclient/exceptions.py b/cinderclient/exceptions.py index d381246f8..d56f34a7b 100644 --- a/cinderclient/exceptions.py +++ b/cinderclient/exceptions.py @@ -143,7 +143,7 @@ def from_response(response, body): message = "n/a" details = "n/a" if hasattr(body, 'keys'): - error = body[body.keys()[0]] + error = body[list(body.keys())[0]] message = error.get('message', None) details = error.get('details', None) return cls(code=response.status_code, message=message, details=details, diff --git a/cinderclient/extension.py b/cinderclient/extension.py index ced67f0c7..07d845038 100644 --- a/cinderclient/extension.py +++ b/cinderclient/extension.py @@ -29,7 +29,7 @@ class Extension(utils.HookableMixin): def _parse_extension_module(self): self.manager_class = None - for attr_name, attr_value in self.module.__dict__.items(): + for attr_name, attr_value in list(self.module.__dict__.items()): if attr_name in self.SUPPORTED_HOOKS: self.add_hook(attr_name, attr_value) elif utils.safe_issubclass(attr_value, base.Manager): diff --git a/cinderclient/shell.py b/cinderclient/shell.py index 9d4af0918..9750d2f79 100644 --- a/cinderclient/shell.py +++ b/cinderclient/shell.py @@ -465,9 +465,9 @@ class OpenStackCinderShell(object): """ commands = set() options = set() - for sc_str, sc in self.subcommands.items(): + for sc_str, sc in list(self.subcommands.items()): commands.add(sc_str) - for option in sc._optionals._option_string_actions.keys(): + for option in list(sc._optionals._option_string_actions.keys()): options.add(option) commands.remove('bash-completion') diff --git a/cinderclient/tests/fakes.py b/cinderclient/tests/fakes.py index fcf6d2bd4..a6872bc4a 100644 --- a/cinderclient/tests/fakes.py +++ b/cinderclient/tests/fakes.py @@ -10,7 +10,7 @@ from __future__ import print_function def assert_has_keys(dict, required=[], optional=[]): - keys = dict.keys() + keys = list(dict.keys()) for k in required: try: assert k in keys diff --git a/cinderclient/tests/v1/fakes.py b/cinderclient/tests/v1/fakes.py index a71f50247..8534c561e 100644 --- a/cinderclient/tests/v1/fakes.py +++ b/cinderclient/tests/v1/fakes.py @@ -215,10 +215,10 @@ class FakeHTTPClient(base_client.HTTPClient): def post_volumes_1234_action(self, body, **kw): _body = None resp = 202 - assert len(body.keys()) == 1 - action = body.keys()[0] + assert len(list(body.keys())) == 1 + action = list(body.keys())[0] if action == 'os-attach': - assert body[action].keys() == ['instance_uuid', 'mountpoint'] + assert list(body[action].keys()) == ['instance_uuid', 'mountpoint'] elif action == 'os-detach': assert body[action] is None elif action == 'os-reserve': @@ -226,10 +226,10 @@ class FakeHTTPClient(base_client.HTTPClient): elif action == 'os-unreserve': assert body[action] is None elif action == 'os-initialize_connection': - assert body[action].keys() == ['connector'] + assert list(body[action].keys()) == ['connector'] return (202, {}, {'connection_info': 'foos'}) elif action == 'os-terminate_connection': - assert body[action].keys() == ['connector'] + assert list(body[action].keys()) == ['connector'] elif action == 'os-begin_detaching': assert body[action] is None elif action == 'os-roll_detaching': @@ -265,7 +265,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'gigabytes': 1}}) def put_os_quota_sets_test(self, body, **kw): - assert body.keys() == ['quota_set'] + assert list(body.keys()) == ['quota_set'] fakes.assert_has_keys(body['quota_set'], required=['tenant_id']) return (200, {}, {'quota_set': { @@ -288,7 +288,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'gigabytes': 1}}) def put_os_quota_class_sets_test(self, body, **kw): - assert body.keys() == ['quota_class_set'] + assert list(body.keys()) == ['quota_class_set'] fakes.assert_has_keys(body['quota_class_set'], required=['class_name']) return (200, {}, {'quota_class_set': { @@ -321,7 +321,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'extra_specs': {}}}) def post_types_1_extra_specs(self, body, **kw): - assert body.keys() == ['extra_specs'] + assert list(body.keys()) == ['extra_specs'] return (200, {}, {'extra_specs': {'k': 'v'}}) def delete_types_1_extra_specs_k(self, **kw): diff --git a/cinderclient/tests/v2/fakes.py b/cinderclient/tests/v2/fakes.py index 28cb20a8a..4880dea0d 100644 --- a/cinderclient/tests/v2/fakes.py +++ b/cinderclient/tests/v2/fakes.py @@ -222,10 +222,10 @@ class FakeHTTPClient(base_client.HTTPClient): def post_volumes_1234_action(self, body, **kw): _body = None resp = 202 - assert len(body.keys()) == 1 - action = body.keys()[0] + assert len(list(body.keys())) == 1 + action = list(body.keys())[0] if action == 'os-attach': - assert body[action].keys() == ['instance_uuid', 'mountpoint'] + assert list(body[action].keys()) == ['instance_uuid', 'mountpoint'] elif action == 'os-detach': assert body[action] is None elif action == 'os-reserve': @@ -233,10 +233,10 @@ class FakeHTTPClient(base_client.HTTPClient): elif action == 'os-unreserve': assert body[action] is None elif action == 'os-initialize_connection': - assert body[action].keys() == ['connector'] + assert list(body[action].keys()) == ['connector'] return (202, {}, {'connection_info': 'foos'}) elif action == 'os-terminate_connection': - assert body[action].keys() == ['connector'] + assert list(body[action].keys()) == ['connector'] elif action == 'os-begin_detaching': assert body[action] is None elif action == 'os-roll_detaching': @@ -272,7 +272,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'gigabytes': 1}}) def put_os_quota_sets_test(self, body, **kw): - assert body.keys() == ['quota_set'] + assert list(body.keys()) == ['quota_set'] fakes.assert_has_keys(body['quota_set'], required=['tenant_id']) return (200, {}, {'quota_set': { @@ -295,7 +295,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'gigabytes': 1}}) def put_os_quota_class_sets_test(self, body, **kw): - assert body.keys() == ['quota_class_set'] + assert list(body.keys()) == ['quota_class_set'] fakes.assert_has_keys(body['quota_class_set'], required=['class_name']) return (200, {}, {'quota_class_set': { @@ -328,7 +328,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'extra_specs': {}}}) def post_types_1_extra_specs(self, body, **kw): - assert body.keys() == ['extra_specs'] + assert list(body.keys()) == ['extra_specs'] return (200, {}, {'extra_specs': {'k': 'v'}}) def delete_types_1_extra_specs_k(self, **kw): diff --git a/cinderclient/utils.py b/cinderclient/utils.py index 6e8712921..fe947a020 100644 --- a/cinderclient/utils.py +++ b/cinderclient/utils.py @@ -217,7 +217,7 @@ def find_resource(manager, name_or_id): def _format_servers_list_networks(server): output = [] - for (network, addresses) in server.networks.items(): + for (network, addresses) in list(server.networks.items()): if len(addresses) == 0: continue addresses_csv = ', '.join(addresses) diff --git a/cinderclient/v1/limits.py b/cinderclient/v1/limits.py index 007c533ee..f76cd68b9 100644 --- a/cinderclient/v1/limits.py +++ b/cinderclient/v1/limits.py @@ -11,7 +11,7 @@ class Limits(base.Resource): @property def absolute(self): - for (name, value) in self._info['absolute'].items(): + for (name, value) in list(self._info['absolute'].items()): yield AbsoluteLimit(name, value) @property diff --git a/cinderclient/v1/quota_classes.py b/cinderclient/v1/quota_classes.py index 669602454..da96e5c46 100644 --- a/cinderclient/v1/quota_classes.py +++ b/cinderclient/v1/quota_classes.py @@ -46,7 +46,7 @@ class QuotaClassSetManager(base.Manager): 'volumes': volumes, 'gigabytes': gigabytes}} - for key in body['quota_class_set'].keys(): + for key in list(body['quota_class_set'].keys()): if body['quota_class_set'][key] is None: body['quota_class_set'].pop(key) diff --git a/cinderclient/v1/quotas.py b/cinderclient/v1/quotas.py index a463b8192..ce7a91283 100644 --- a/cinderclient/v1/quotas.py +++ b/cinderclient/v1/quotas.py @@ -45,7 +45,7 @@ class QuotaSetManager(base.Manager): 'snapshots': snapshots, 'gigabytes': gigabytes}} - for key in body['quota_set'].keys(): + for key in list(body['quota_set'].keys()): if body['quota_set'][key] is None: body['quota_set'].pop(key) diff --git a/cinderclient/v1/shell.py b/cinderclient/v1/shell.py index 5c56f4a95..a9e366ef3 100644 --- a/cinderclient/v1/shell.py +++ b/cinderclient/v1/shell.py @@ -83,7 +83,7 @@ def _print_volume_snapshot(snapshot): def _translate_keys(collection, convert): for item in collection: - keys = item.__dict__.keys() + keys = list(item.__dict__.keys()) for from_key, to_key in convert: if from_key in keys and to_key not in keys: setattr(item, to_key, item._info[from_key]) @@ -306,7 +306,7 @@ def do_metadata(cs, args): if args.action == 'set': cs.volumes.set_metadata(volume, metadata) elif args.action == 'unset': - cs.volumes.delete_metadata(volume, metadata.keys()) + cs.volumes.delete_metadata(volume, list(metadata.keys())) @utils.arg( @@ -491,7 +491,7 @@ def do_type_key(cs, args): if args.action == 'set': vtype.set_keys(keypair) elif args.action == 'unset': - vtype.unset_keys(keypair.keys()) + vtype.unset_keys(list(keypair.keys())) def do_endpoints(cs, args): diff --git a/cinderclient/v2/limits.py b/cinderclient/v2/limits.py index 72f9ea652..87349b6c6 100644 --- a/cinderclient/v2/limits.py +++ b/cinderclient/v2/limits.py @@ -11,7 +11,7 @@ class Limits(base.Resource): @property def absolute(self): - for (name, value) in self._info['absolute'].items(): + for (name, value) in list(self._info['absolute'].items()): yield AbsoluteLimit(name, value) @property diff --git a/cinderclient/v2/quota_classes.py b/cinderclient/v2/quota_classes.py index 0a2a8df40..eeda85ccd 100644 --- a/cinderclient/v2/quota_classes.py +++ b/cinderclient/v2/quota_classes.py @@ -44,7 +44,7 @@ class QuotaClassSetManager(base.Manager): 'volumes': volumes, 'gigabytes': gigabytes}} - for key in body['quota_class_set'].keys(): + for key in list(body['quota_class_set'].keys()): if body['quota_class_set'][key] is None: body['quota_class_set'].pop(key) diff --git a/cinderclient/v2/quotas.py b/cinderclient/v2/quotas.py index 476ab418e..30c4186d5 100644 --- a/cinderclient/v2/quotas.py +++ b/cinderclient/v2/quotas.py @@ -43,7 +43,7 @@ class QuotaSetManager(base.Manager): 'snapshots': snapshots, 'gigabytes': gigabytes}} - for key in body['quota_set'].keys(): + for key in list(body['quota_set'].keys()): if body['quota_set'][key] is None: body['quota_set'].pop(key) diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index 0555a7846..e96609d61 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -75,7 +75,7 @@ def _print_volume_snapshot(snapshot): def _translate_keys(collection, convert): for item in collection: - keys = item.__dict__.keys() + keys = list(item.__dict__.keys()) for from_key, to_key in convert: if from_key in keys and to_key not in keys: setattr(item, to_key, item._info[from_key]) @@ -351,7 +351,7 @@ def do_metadata(cs, args): if args.action == 'set': cs.volumes.set_metadata(volume, metadata) elif args.action == 'unset': - cs.volumes.delete_metadata(volume, metadata.keys()) + cs.volumes.delete_metadata(volume, list(metadata.keys())) @utils.arg('--all-tenants', @@ -557,7 +557,7 @@ def do_type_key(cs, args): if args.action == 'set': vtype.set_keys(keypair) elif args.action == 'unset': - vtype.unset_keys(keypair.keys()) + vtype.unset_keys(list(keypair.keys())) def do_endpoints(cs, args): diff --git a/tools/colorizer.py b/tools/colorizer.py index 9547802b8..1b6e57638 100755 --- a/tools/colorizer.py +++ b/tools/colorizer.py @@ -267,7 +267,7 @@ class NovaTestResult(testtools.TestResult): if not self.last_written or (self._now() - time).total_seconds() > 2.0: diff = 3.0 while diff > 2.0: - classes = self.results.keys() + classes =list(self.results.keys()) oldest = min(classes, key=lambda x: self.last_time[x]) diff = (self._now() - self.last_time[oldest]).total_seconds() self.writeTestCase(oldest)