]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Replace dict.iteritems() with dict.items()
authorVictor Stinner <vstinner@redhat.com>
Fri, 12 Jun 2015 12:53:05 +0000 (14:53 +0200)
committerVictor Stinner <vstinner@redhat.com>
Fri, 12 Jun 2015 13:18:57 +0000 (15:18 +0200)
This change adds Python 3 compatibility to the modified code.

Replace also six.iteritems(obj) with obj.items().

The iteritems() method of Python 2 dictionaries was renamed to items()
on Python 3. As discussed on the openstack-dev mailing list, iteritems()
must be replaced with items(), six.iteritems() should not be used. In
OpenStack, the overhead of creating a temporary list with dict.items()
on Python 2 is negligible.

Blueprint cinder-python3
Change-Id: Ic3d8fd6b71d2c9f21929b0d6bf68c8f84a5e2567

55 files changed:
cinder/api/contrib/hosts.py
cinder/api/contrib/used_limits.py
cinder/api/extensions.py
cinder/api/v1/volumes.py
cinder/api/v2/volumes.py
cinder/api/views/limits.py
cinder/backup/drivers/tsm.py
cinder/cmd/manage.py
cinder/consistencygroup/api.py
cinder/db/sqlalchemy/api.py
cinder/exception.py
cinder/scheduler/flows/create_volume.py
cinder/test.py
cinder/tests/unit/api/contrib/test_used_limits.py
cinder/tests/unit/api/contrib/test_volume_type_access.py
cinder/tests/unit/api/fakes.py
cinder/tests/unit/fake_driver.py
cinder/tests/unit/scheduler/fakes.py
cinder/tests/unit/test_cmd.py
cinder/tests/unit/test_db_api.py
cinder/tests/unit/test_ibm_flashsystem.py
cinder/tests/unit/test_ibm_flashsystem_iscsi.py
cinder/tests/unit/test_ibm_xiv_ds8k.py
cinder/tests/unit/test_ibmnas.py
cinder/tests/unit/test_netapp.py
cinder/tests/unit/test_netapp_ssc.py
cinder/tests/unit/test_storwize_svc.py
cinder/tests/unit/test_volume_glance_metadata.py
cinder/tests/unit/test_volume_types.py
cinder/tests/unit/test_volume_types_extra_specs.py
cinder/tests/unit/test_wsgi.py
cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_driver_interfaces.py
cinder/tests/unit/volume/drivers/netapp/test_common.py
cinder/utils.py
cinder/volume/api.py
cinder/volume/drivers/block_device.py
cinder/volume/drivers/cloudbyte/cloudbyte.py
cinder/volume/drivers/emc/scaleio.py
cinder/volume/drivers/huawei/rest_common.py
cinder/volume/drivers/ibm/flashsystem.py
cinder/volume/drivers/ibm/storwize_svc/__init__.py
cinder/volume/drivers/ibm/storwize_svc/helpers.py
cinder/volume/drivers/netapp/utils.py
cinder/volume/drivers/remotefs.py
cinder/volume/drivers/san/hp/hp_3par_common.py
cinder/volume/drivers/san/hp/hp_3par_iscsi.py
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py
cinder/volume/drivers/smbfs.py
cinder/volume/drivers/solidfire.py
cinder/volume/drivers/storpool.py
cinder/volume/drivers/xio.py
cinder/volume/flows/api/create_volume.py
cinder/volume/qos_specs.py
cinder/volume/volume_types.py
cinder/wsgi.py

index ed529e2fd8e2e50fc55784bf4cdbd05e8428d7da..fcad9a2b37463b916decd8f1b6eee941bbd9db3c 100644 (file)
@@ -157,7 +157,7 @@ class HostController(wsgi.Controller):
     def update(self, req, id, body):
         authorize(req.environ['cinder.context'])
         update_values = {}
-        for raw_key, raw_val in body.iteritems():
+        for raw_key, raw_val in body.items():
             key = raw_key.lower().strip()
             val = raw_val.lower().strip()
             if key == "status":
@@ -171,7 +171,7 @@ class HostController(wsgi.Controller):
                 raise webob.exc.HTTPBadRequest(explanation=explanation)
         update_setters = {'status': self._set_enabled_status}
         result = {}
-        for key, value in update_values.iteritems():
+        for key, value in update_values.items():
             result.update(update_setters[key](req, id, value))
         return result
 
index a720eddea821e8b3b389ad6b7cdb8b96f2c505db..52887ba802adb49b019f125e29e569a070f40124 100644 (file)
@@ -40,7 +40,7 @@ class UsedLimitsController(wsgi.Controller):
         }
 
         used_limits = {}
-        for display_name, single_quota in quota_map.iteritems():
+        for display_name, single_quota in quota_map.items():
             if single_quota in quotas:
                 used_limits[display_name] = quotas[single_quota]['in_use']
 
index b0a5f5870677a9afd46155d3521a45e2deb9b6e1..20af44c0cf1e210d2be3eacee98a0aedec9ae93a 100644 (file)
@@ -151,7 +151,7 @@ class ExtensionsResource(wsgi.Resource):
     @wsgi.serializers(xml=ExtensionsTemplate)
     def index(self, req):
         extensions = []
-        for _alias, ext in self.extension_manager.extensions.iteritems():
+        for _alias, ext in self.extension_manager.extensions.items():
             extensions.append(self._translate(ext))
         return dict(extensions=extensions)
 
index 6beba81a869b6401b4c0a086421d48eaabf3934f..781acb1572dcb1dfe9a14d9aa7a03a39ba11038c 100644 (file)
@@ -275,7 +275,7 @@ class VolumeController(wsgi.Controller):
         search_opts.pop('limit', None)
         search_opts.pop('offset', None)
 
-        for k, v in search_opts.iteritems():
+        for k, v in search_opts.items():
             try:
                 search_opts[k] = ast.literal_eval(v)
             except (ValueError, SyntaxError):
index 50d0d3c6fe5c3910f3f1293cfc0515feb4899e3b..6c8c47ffc2eb1d9ff9cf3e496a3703a3b2377fe2 100644 (file)
@@ -244,7 +244,7 @@ class VolumeController(wsgi.Controller):
             filters['display_name'] = filters['name']
             del filters['name']
 
-        for k, v in filters.iteritems():
+        for k, v in filters.items():
             try:
                 filters[k] = ast.literal_eval(v)
             except (ValueError, SyntaxError):
index 3751b05e2938bd1e8a85c6792bbc5a7f29a9e719..b8603627a509c627bc996ded62b4d794cce86513 100644 (file)
@@ -55,7 +55,7 @@ class ViewBuilder(object):
             "injected_file_content_bytes": ["maxPersonalitySize"],
         }
         limits = {}
-        for name, value in absolute_limits.iteritems():
+        for name, value in absolute_limits.items():
             if name in limit_names and value is not None:
                 for name in limit_names[name]:
                     limits[name] = value
index 4bcd903b57d29b86e0918801ff1dc0aa3da26ffb..6f689e6e5592a8268de8dc91df343d8339ce2fb5 100644 (file)
@@ -176,7 +176,7 @@ def _check_dsmc_output(output, check_attrs, exact_match=True):
         if sep is not None and key is not None and len(val.strip()) > 0:
             parsed_attrs[key] = val.strip()
 
-    for ckey, cval in check_attrs.iteritems():
+    for ckey, cval in check_attrs.items():
         if ckey not in parsed_attrs:
             return False
         elif exact_match and parsed_attrs[ckey] != cval:
index 76f9d7cf623ae19624dd80f39de53a227480145d..e087e606a9db337f9620ae0fce1c8c6a5e85f0ee 100644 (file)
@@ -338,7 +338,7 @@ class ConfigCommands(object):
         if param:
             print('%s = %s' % (param, CONF.get(param)))
         else:
-            for key, value in CONF.iteritems():
+            for key, value in CONF.items():
                 print('%s = %s' % (key, value))
 
 
index 72ebf00222a0177ec87710cae3fd7e4a512e3d6c..75506c475f0b3337f34ae71462ba2b720cb37a81 100644 (file)
@@ -697,7 +697,7 @@ class API(base.Base):
             results = []
             not_found = object()
             for cgsnapshot in cgsnapshots:
-                for opt, value in search_opts.iteritems():
+                for opt, value in search_opts.items():
                     if cgsnapshot.get(opt, not_found) != value:
                         break
                 else:
index b3c00fe89fefc421a2f0dea20d2ac90f7cc7a7cd..2a5bf2ac1c673ff0e95d2ab87f68b4570b97dd05 100644 (file)
@@ -450,7 +450,7 @@ def service_update(context, service_id, values):
 def _metadata_refs(metadata_dict, meta_class):
     metadata_refs = []
     if metadata_dict:
-        for k, v in metadata_dict.iteritems():
+        for k, v in metadata_dict.items():
             metadata_ref = meta_class()
             metadata_ref['key'] = k
             metadata_ref['value'] = v
@@ -490,7 +490,7 @@ def iscsi_target_count_by_host(context, host):
 def iscsi_target_create_safe(context, values):
     iscsi_target_ref = models.IscsiTarget()
 
-    for (key, value) in values.iteritems():
+    for (key, value) in values.items():
         iscsi_target_ref[key] = value
     session = get_session()
 
@@ -1564,14 +1564,14 @@ def _process_volume_filters(query, filters):
     filter_dict = {}
 
     # Iterate over all filters, special case the filter if necessary
-    for key, value in filters.iteritems():
+    for key, value in filters.items():
         if key == 'metadata':
             # model.VolumeMetadata defines the backref to Volumes as
             # 'volume_metadata' or 'volume_admin_metadata', use those as
             # column attribute keys
             col_attr = getattr(models.Volume, 'volume_metadata')
             col_ad_attr = getattr(models.Volume, 'volume_admin_metadata')
-            for k, v in value.iteritems():
+            for k, v in value.items():
                 query = query.filter(or_(col_attr.any(key=k, value=v),
                                          col_ad_attr.any(key=k, value=v)))
         elif isinstance(value, (list, tuple, set, frozenset)):
@@ -1773,7 +1773,7 @@ def _volume_x_metadata_update(context, volume_id, metadata, delete,
         if delete:
             original_metadata = _volume_x_metadata_get(context, volume_id,
                                                        model, session=session)
-            for meta_key, meta_value in original_metadata.iteritems():
+            for meta_key, meta_value in original_metadata.items():
                 if meta_key not in metadata:
                     meta_ref = _volume_x_metadata_get_item(context, volume_id,
                                                            meta_key, model,
@@ -2130,7 +2130,7 @@ def snapshot_metadata_update(context, snapshot_id, metadata, delete):
         if delete:
             original_metadata = _snapshot_metadata_get(context, snapshot_id,
                                                        session)
-            for meta_key, meta_value in original_metadata.iteritems():
+            for meta_key, meta_value in original_metadata.items():
                 if meta_key not in metadata:
                     meta_ref = _snapshot_metadata_get_item(context,
                                                            snapshot_id,
@@ -2620,7 +2620,7 @@ def volume_type_extra_specs_update_or_create(context, volume_type_id,
     session = get_session()
     with session.begin():
         spec_ref = None
-        for key, value in specs.iteritems():
+        for key, value in specs.items():
             try:
                 spec_ref = _volume_type_extra_specs_get_item(
                     context, volume_type_id, key, session)
@@ -2672,7 +2672,7 @@ def qos_specs_create(context, values):
             specs_root.save(session=session)
 
             # Insert all specification entries for QoS specs
-            for k, v in values['qos_specs'].iteritems():
+            for k, v in values['qos_specs'].items():
                 item = dict(key=k, value=v, specs_id=specs_id)
                 item['id'] = str(uuid.uuid4())
                 spec_entry = models.QualityOfServiceSpecs()
index 8d0c2791f34690e5e39812af537db71362de0d64..c3cd405c98480dac2469029f9eb80300a3289359 100644 (file)
@@ -80,7 +80,7 @@ class CinderException(Exception):
             except AttributeError:
                 pass
 
-        for k, v in self.kwargs.iteritems():
+        for k, v in self.kwargs.items():
             if isinstance(v, Exception):
                 self.kwargs[k] = six.text_type(v)
 
@@ -93,7 +93,7 @@ class CinderException(Exception):
                 # kwargs doesn't match a variable in the message
                 # log the issue and the kwargs
                 LOG.exception(_LE('Exception in string format operation'))
-                for name, value in kwargs.iteritems():
+                for name, value in kwargs.items():
                     LOG.error(_LE("%(name)s: %(value)s"),
                               {'name': name, 'value': value})
                 if CONF.fatal_exception_format_errors:
index 43a87bace40f9761fa6069b7fe526331403651da..70e9527611913ee432bd5e477a6ff1a05c802cd9 100644 (file)
@@ -65,7 +65,7 @@ class ExtractSchedulerSpecTask(flow_utils.CinderTask):
                 'availability_zone': volume_ref.get('availability_zone'),
                 'volume_type_id': volume_type_id,
             },
-            'volume_type': list(dict(vol_type).iteritems()),
+            'volume_type': list(dict(vol_type).items()),
         }
 
     def execute(self, context, request_spec, volume_id, snapshot_id,
index 105d34be7eab8d0e9ce277133a564a4be2f00a2d..e78237ff047f909a99c2d27aa3e50f2adbe4fa2a 100644 (file)
@@ -253,7 +253,7 @@ class TestCase(testtools.TestCase):
 
     def flags(self, **kw):
         """Override CONF variables for a test."""
-        for k, v in kw.iteritems():
+        for k, v in kw.items():
             self.override_config(k, v)
 
     def log_level(self, level):
index 0c4f1f1d8a78e71fbee3768ee9761386711231c1..7a292060586274f5003a993951a71b4e61f9396c 100644 (file)
@@ -47,7 +47,7 @@ class UsedLimitsTestCase(test.TestCase):
         }
 
         limits = {}
-        for display_name, q in quota_map.iteritems():
+        for display_name, q in quota_map.items():
             limits[q] = {'limit': 2,
                          'in_use': 1}
 
@@ -61,6 +61,6 @@ class UsedLimitsTestCase(test.TestCase):
 
         self.controller.index(fake_req, res)
         abs_limits = res.obj['limits']['absolute']
-        for used_limit, value in abs_limits.iteritems():
+        for used_limit, value in abs_limits.items():
             self.assertEqual(value,
                              limits[quota_map[used_limit]]['in_use'])
index 96d06c9cf80e0b54647c65dcd13d37fd84d6c4f7..270686868183d1f766c17562ac366d80de19b6de 100644 (file)
@@ -71,7 +71,7 @@ def fake_volume_type_get_all(context, inactive=False, filters=None):
     if filters is None or filters['is_public'] is None:
         return VOLUME_TYPES
     res = {}
-    for k, v in VOLUME_TYPES.iteritems():
+    for k, v in VOLUME_TYPES.items():
         if filters['is_public'] and _has_type_access(k, context.project_id):
             res.update({k: v})
             continue
index de8c9f371db0b7c6d1f886297d109defe46df52c..a87a0ed827e0316e6392135d0c10ca9da9cbeea5 100644 (file)
@@ -91,7 +91,7 @@ class FakeToken(object):
     def __init__(self, **kwargs):
         FakeToken.id_count += 1
         self.id = FakeToken.id_count
-        for k, v in kwargs.iteritems():
+        for k, v in kwargs.items():
             setattr(self, k, v)
 
 
index a0db8ed4dea171ce06d073a24a6586820a8cbdf2..dcc6eeca57e7850dd18e1555b620100b7e307e5c 100644 (file)
@@ -180,7 +180,7 @@ class LoggingVolumeDriver(driver.VolumeDriver):
             if entry['action'] != action:
                 continue
             match = True
-            for k, v in kwargs.iteritems():
+            for k, v in kwargs.items():
                 if entry.get(k) != v:
                     match = False
                     break
index 8d38e2f6a24ee21ee1b0ae62aacfd02bd4fdbcb9..071eb64e67901ffc3a0d290765aecfc63b9c203c 100644 (file)
@@ -90,7 +90,7 @@ class FakeHostManager(host_manager.HostManager):
 class FakeHostState(host_manager.HostState):
     def __init__(self, host, attribute_dict):
         super(FakeHostState, self).__init__(host)
-        for (key, val) in attribute_dict.iteritems():
+        for (key, val) in attribute_dict.items():
             setattr(self, key, val)
 
 
@@ -118,7 +118,7 @@ class FakeNovaClient(object):
         def list(self, detailed=True, search_opts=None):
             matching = list(self._servers)
             if search_opts:
-                for opt, val in search_opts.iteritems():
+                for opt, val in search_opts.items():
                     matching = [m for m in matching
                                 if getattr(m, opt, None) == val]
             return matching
index 435217fe44c36ceca600fb4d10522e1dc0796482..56543b722c3083ef71e2e928d5f8375bdc863c16 100644 (file)
@@ -496,7 +496,7 @@ class TestCinderManageCmd(test.TestCase):
     def test_config_commands_list(self):
         with mock.patch('sys.stdout', new=six.StringIO()) as fake_out:
             expected_out = ''
-            for key, value in CONF.iteritems():
+            for key, value in CONF.items():
                 expected_out += '%s = %s' % (key, value) + '\n'
 
             config_cmds = cinder_manage.ConfigCommands()
index ef793b8813a7f6e7c73570017d579207894575bd..2fc79fb2c14cee9b3d7d91610934488a45ff4000 100644 (file)
@@ -77,7 +77,7 @@ class ModelsObjectComparatorMixin(object):
         self.assertEqual(
             len(obj1), len(obj2),
             "Keys mismatch: %s" % str(set(obj1.keys()) ^ set(obj2.keys())))
-        for key, value in obj1.iteritems():
+        for key, value in obj1.items():
             self.assertEqual(value, obj2[key])
 
     def _assertEqualListsOfObjects(self, objs1, objs2, ignored_keys=None):
@@ -123,7 +123,7 @@ class DBAPIServiceTestCase(BaseTest):
     def test_service_create(self):
         service = self._create_service({})
         self.assertFalse(service['id'] is None)
-        for key, value in self._get_base_values().iteritems():
+        for key, value in self._get_base_values().items():
             self.assertEqual(value, service[key])
 
     def test_service_destroy(self):
@@ -147,7 +147,7 @@ class DBAPIServiceTestCase(BaseTest):
         }
         db.service_update(self.ctxt, service['id'], new_values)
         updated_service = db.service_get(self.ctxt, service['id'])
-        for key, value in new_values.iteritems():
+        for key, value in new_values.items():
             self.assertEqual(value, updated_service[key])
 
     def test_service_update_not_found_exception(self):
@@ -1441,7 +1441,7 @@ class DBAPIQuotaTestCase(BaseTest):
         quota_usage = db.quota_usage_get(self.ctxt, 'p1', 'gigabytes')
         expected = {'resource': 'gigabytes', 'project_id': 'p1',
                     'in_use': 0, 'reserved': 2, 'total': 2}
-        for key, value in expected.iteritems():
+        for key, value in expected.items():
             self.assertEqual(value, quota_usage[key], key)
 
     def test_quota_usage_get_all_by_project(self):
index 929e101c3db6f08428b952dcabb4cb5fc389e16a..76e8062367dea8a4e730adbccc07b3539b98a8db 100644 (file)
@@ -688,7 +688,7 @@ class FlashSystemDriverTestCase(test.TestCase):
 
     def _reset_flags(self):
         self.driver.configuration.local_conf.reset()
-        for k, v in self._def_flags.iteritems():
+        for k, v in self._def_flags.items():
             self._set_flag(k, v)
 
     def _generate_vol_info(self,
index 2971b1798cc5e43d89f043092941f5fa6bebfd3d..8da1ede7ba8b6d91a4735b5a19ed3dcf2c4909a0 100644 (file)
@@ -91,7 +91,7 @@ class FlashSystemISCSIDriverTestCase(test.TestCase):
 
     def _reset_flags(self):
         self.driver.configuration.local_conf.reset()
-        for k, v in self._def_flags.iteritems():
+        for k, v in self._def_flags.items():
             self._set_flag(k, v)
 
     def _generate_vol_info(self,
index f9a51e2c201499b3d3f4b8970283ad90f7f3fe85..baabf73182230a60bda850105fdb981e00bb433c 100644 (file)
@@ -185,7 +185,7 @@ class XIVDS8KFakeProxyDriver(object):
 
     def create_consistencygroup(self, ctxt, group):
 
-        volumes = [volume for k, volume in self.volumes.iteritems()
+        volumes = [volume for k, volume in self.volumes.items()
                    if volume['consistencygroup_id'] == group['id']]
 
         if volumes:
@@ -207,12 +207,12 @@ class XIVDS8KFakeProxyDriver(object):
                     volumes.append(volume)
 
         # Delete snapshots in consistency group
-        self.snapshots = {k: snap for k, snap in self.snapshots.iteritems()
+        self.snapshots = {k: snap for k, snap in self.snapshots.items()
                           if not(snap.get('consistencygroup_id', None)
                                  == group.get('id', None))}
 
         # Delete volume in consistency group
-        self.volumes = {k: vol for k, vol in self.volumes.iteritems()
+        self.volumes = {k: vol for k, vol in self.volumes.items()
                         if not(vol.get('consistencygroup_id', None)
                                == group.get('id', None))}
 
@@ -254,7 +254,7 @@ class XIVDS8KFakeProxyDriver(object):
                     snapshots.append(snapshot)
 
         # Delete snapshots in consistency group
-        self.snapshots = {k: snap for k, snap in self.snapshots.iteritems()
+        self.snapshots = {k: snap for k, snap in self.snapshots.items()
                           if not(snap.get('consistencygroup_id', None)
                                  == cgsnapshot.get('cgsnapshot_id', None))}
 
index e90ef1d598c775fd56309ea06fa8a65d10990670..a7536030d378c91c03d6ea6e0fb9b2ae1e05e6e0 100644 (file)
@@ -87,7 +87,7 @@ class IBMNASDriverTestCase(test.TestCase):
 
     def _reset_flags(self):
         self._driver.configuration.local_conf.reset()
-        for k, v in self._def_flags.iteritems():
+        for k, v in self._def_flags.items():
             self._set_flag(k, v)
 
     def test_check_for_setup_error(self):
index d21f96ec4bf07000419189bfa24b0a77010c2ba1..0f05013a5dc23807e723f09a09f3e81260a882c0 100644 (file)
@@ -457,7 +457,7 @@ class FakeDirectCmodeHTTPConnection(object):
         if not headers:
             headers = {}
         req_str = '%s %s HTTP/1.1\r\n' % (method, path)
-        for key, value in headers.iteritems():
+        for key, value in headers.items():
             req_str += "%s: %s\r\n" % (key, value)
         if data:
             req_str += '\r\n%s' % data
@@ -1139,7 +1139,7 @@ class FakeDirect7modeHTTPConnection(object):
         if not headers:
             headers = {}
         req_str = '%s %s HTTP/1.1\r\n' % (method, path)
-        for key, value in headers.iteritems():
+        for key, value in headers.items():
             req_str += "%s: %s\r\n" % (key, value)
         if data:
             req_str += '\r\n%s' % data
index 68f1fa3683eea73dd9ba166e1ce3e519045c9a8d..b760c431852363022e920125b7c47a5fca2766dc 100644 (file)
@@ -265,7 +265,7 @@ class FakeDirectCmodeHTTPConnection(object):
         if not headers:
             headers = {}
         req_str = '%s %s HTTP/1.1\r\n' % (method, path)
-        for key, value in headers.iteritems():
+        for key, value in headers.items():
             req_str += "%s: %s\r\n" % (key, value)
         if data:
             req_str += '\r\n%s' % data
index cd23c887a594be915484b94997e541ea377ccdfd..e7a0d1f33eb30c11efffbef2eb18841d37010f8b 100644 (file)
@@ -1253,7 +1253,7 @@ port_speed!N/A
         filter_key = kwargs['filtervalue'].split('=')[0]
         filter_value = kwargs['filtervalue'].split('=')[1]
         to_delete = []
-        for k, v in self._fcmappings_list.iteritems():
+        for k, v in self._fcmappings_list.items():
             if str(v[filter_key]) == filter_value:
                 source = self._volumes_list[v['source']]
                 target = self._volumes_list[v['target']]
@@ -1541,7 +1541,7 @@ port_speed!N/A
 
         params = ['name', 'warning', 'udid',
                   'autoexpand', 'easytier', 'primary']
-        for key, value in kwargs.iteritems():
+        for key, value in kwargs.items():
             if key == 'easytier':
                 vol['easy_tier'] = value
                 continue
@@ -1765,7 +1765,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
 
     def _reset_flags(self):
         self.driver.configuration.local_conf.reset()
-        for k, v in self._def_flags.iteritems():
+        for k, v in self._def_flags.items():
             self._set_flag(k, v)
 
     def _assert_vol_exists(self, name, exists):
@@ -2206,7 +2206,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
 
         for idx in range(len(opts_list)):
             attrs = self._create_test_vol(opts_list[idx])
-            for k, v in chck_list[idx].iteritems():
+            for k, v in chck_list[idx].items():
                 try:
                     if k[0] == '-':
                         k = k[1:]
@@ -2340,14 +2340,14 @@ class StorwizeSVCDriverTestCase(test.TestCase):
             ret = self.driver.initialize_connection(volume1, self._connector)
             self.assertEqual(ret['driver_volume_type'],
                              expected[protocol]['driver_volume_type'])
-            for k, v in expected[protocol]['data'].iteritems():
+            for k, v in expected[protocol]['data'].items():
                 self.assertEqual(ret['data'][k], v)
 
             # Initialize again, should notice it and do nothing
             ret = self.driver.initialize_connection(volume1, self._connector)
             self.assertEqual(ret['driver_volume_type'],
                              expected[protocol]['driver_volume_type'])
-            for k, v in expected[protocol]['data'].iteritems():
+            for k, v in expected[protocol]['data'].items():
                 self.assertEqual(ret['data'][k], v)
 
             # Try to delete the 1st volume (should fail because it is mapped)
@@ -2382,7 +2382,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
                     self.assertEqual(
                         ret['driver_volume_type'],
                         expected_fc_npiv['driver_volume_type'])
-                    for k, v in expected_fc_npiv['data'].iteritems():
+                    for k, v in expected_fc_npiv['data'].items():
                         self.assertEqual(ret['data'][k], v)
                     self._set_flag('storwize_svc_npiv_compatibility_mode',
                                    False)
index 249d81ab92be8543ef628f0b4c63508097100ead..96297fc4484621357b5ffe52ceb7438cf5d5da8d 100644 (file)
@@ -68,7 +68,7 @@ class VolumeGlanceMetadataTestCase(test.TestCase):
         metadata = db.volume_glance_metadata_get(ctxt, 2)
         self.assertEqual(len(metadata), 3)
         for expected, meta in zip(expected_metadata_2, metadata):
-            for key, value in expected.iteritems():
+            for key, value in expected.items():
                 self.assertEqual(meta[key], value)
 
         self.assertRaises(exception.GlanceMetadataExists,
index e5a024e781162a624cdeb4f3fa5b4c2ab83f1285..c5257a77fbe208fd9f0764bae9da0eda1dfee7ac 100644 (file)
@@ -68,7 +68,7 @@ class VolumeTypeTestCase(test.TestCase):
 
         self.assertEqual(self.vol_type1_description, new['description'])
 
-        for k, v in self.vol_type1_specs.iteritems():
+        for k, v in self.vol_type1_specs.items():
             self.assertEqual(v, new['extra_specs'][k],
                              'one of fields does not match')
 
index 36733420610812758f4458b0984e3a2934623aee..5391a7fe3b7296793630a7c66c8ac12f3536c1d3 100644 (file)
@@ -35,7 +35,7 @@ class VolumeTypeExtraSpecsTestCase(test.TestCase):
         self.addCleanup(db.volume_type_destroy, context.get_admin_context(),
                         self.vol_type1['id'])
         self.volume_type1_id = ref.id
-        for k, v in self.vol_type1_specs.iteritems():
+        for k, v in self.vol_type1_specs.items():
             self.vol_type1_specs[k] = str(v)
 
         self.vol_type2_noextra = dict(name="TEST: Volume type without extra")
index c72dac28285a3a757894698b9f3d1e33ecb0b110..a62a78bbe8408be0398c797fadf4ab9e26a8c69b 100644 (file)
@@ -313,7 +313,7 @@ class ExceptionTest(test.TestCase):
         self.assertEqual(resp.status_int, exception_type.code, resp.body)
 
         if hasattr(exception_type, 'headers'):
-            for (key, value) in exception_type.headers.iteritems():
+            for (key, value) in exception_type.headers.items():
                 self.assertIn(key, resp.headers)
                 self.assertEqual(resp.headers[key], value)
 
index e192d9bb3f543a734412c42f6ef781b69aa3727b..4bd744b63e080107be9c2c5060221cf27c758079 100644 (file)
@@ -17,7 +17,6 @@ Mock unit tests for the NetApp block storage driver interfaces
 
 
 import mock
-import six
 
 from cinder import test
 from cinder.volume.drivers.netapp.dataontap import block_7mode
@@ -69,5 +68,5 @@ class NetAppBlockStorageDriverInterfaceTestCase(test.TestCase):
 
     def _get_local_functions(self, obj):
         """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)])
index d846b3c6a0c44c949a4f99825e6fe35d80bf346e..db3a6362743726ca93083fdffd5bbb485def0e7c 100644 (file)
@@ -92,7 +92,7 @@ class NetAppDriverFactoryTestCase(test.TestCase):
         registry = na_common.NETAPP_UNIFIED_DRIVER_REGISTRY
 
         for family in six.iterkeys(registry):
-            for protocol, full_class_name in six.iteritems(registry[family]):
+            for protocol, full_class_name in registry[family].items():
                 driver = na_common.NetAppDriver.create_driver(
                     family, protocol, **kwargs)
                 self.assertEqual(full_class_name, get_full_class_name(driver))
index 1b2baa59daaecefe6fe34043151cc06099992c07..dca7385fded90d6ab0080bf4811a12cd882645b9 100644 (file)
@@ -118,7 +118,7 @@ def check_exclusive_options(**kwargs):
 
     pretty_keys = kwargs.pop("pretty_keys", True)
     exclusive_options = {}
-    for (k, v) in kwargs.iteritems():
+    for (k, v) in kwargs.items():
         if v is not None:
             exclusive_options[k] = True
 
@@ -714,7 +714,7 @@ def add_visible_admin_metadata(volume):
         for item in orig_meta:
             if item['key'] in visible_admin_meta.keys():
                 item['value'] = visible_admin_meta.pop(item['key'])
-        for key, value in visible_admin_meta.iteritems():
+        for key, value in visible_admin_meta.items():
             orig_meta.append({'key': key, 'value': value})
         volume['volume_metadata'] = orig_meta
     # avoid circular ref when vol is a Volume instance
index f0c17367648a824c8e3bb08d407bcc78ff490a26..ecfcbfa902d174bb83d134ada3f92ac8e754916f 100644 (file)
@@ -522,7 +522,7 @@ class API(base.Base):
             results = []
             not_found = object()
             for snapshot in snapshots:
-                for opt, value in search_opts.iteritems():
+                for opt, value in search_opts.items():
                     if snapshot.get(opt, not_found) != value:
                         break
                 else:
@@ -954,7 +954,7 @@ class API(base.Base):
         if not metadata:
             metadata = {}
 
-        for k, v in metadata.iteritems():
+        for k, v in metadata.items():
             if len(k) == 0:
                 msg = _("Metadata property key blank.")
                 LOG.warning(msg)
index 9c65338e0ea781a4baeb3203aa70fe55e144cfe5..cfe87663827b0efdae3a94832effc30eb77f7d37 100644 (file)
@@ -127,7 +127,7 @@ class BlockDeviceDriver(driver.BaseVD, driver.LocalVD, driver.CloneableVD,
         used_devices = self._get_used_devices()
         total_size = 0
         free_size = 0
-        for device, size in dict_of_devices_sizes.iteritems():
+        for device, size in dict_of_devices_sizes.items():
             if device not in used_devices:
                 free_size += size
             total_size += size
index 310e91b36b54f482af0a79960839b585a219088a..6da5a7826c4b83eab80ba61791faeb700fa6c068 100644 (file)
@@ -86,7 +86,7 @@ class CloudByteISCSIDriver(san.SanISCSIDriver):
         error_msg = ""
 
         # error_data is a single key value dict
-        for key, value in error_data.iteritems():
+        for key, value in error_data.items():
             error_msg = value.get('errortext')
 
         return error_msg
@@ -188,7 +188,7 @@ class CloudByteISCSIDriver(san.SanISCSIDriver):
             # Nothing to override
             return default_dict
 
-        for key, value in default_dict.iteritems():
+        for key, value in default_dict.items():
             # Fill the user dict with default options based on condition
             if filtered_user_dict.get(key) is None and value is not None:
                 filtered_user_dict[key] = value
index 23b3c5a231e5b31fbd7d4fcfba15e373c605e65c..1fddd3b45d96db8bfdc0d2d27865c59d03b5134d 100644 (file)
@@ -897,7 +897,7 @@ class ScaleIODriver(driver.VolumeDriver):
         if type_id:
             volume_type = volume_types.get_volume_type(ctxt, type_id)
             specs = volume_type.get('extra_specs')
-            for key, value in specs.iteritems():
+            for key, value in specs.items():
                 specs[key] = value
 
         return specs
index 6b34823448deae18dd0f79867702ecf243baf21d..f7535878218397adb830fba40fc0c2a40ed1c356 100644 (file)
@@ -1620,7 +1620,7 @@ class RestCommon(object):
             kvs = specs
 
         LOG.info(_LI('The QoS sepcs is: %s.'), kvs)
-        for key, value in kvs.iteritems():
+        for key, value in kvs.items():
             if key in huawei_valid_keys:
                 qos[key.upper()] = value
 
@@ -1696,7 +1696,7 @@ class RestCommon(object):
     def _check_qos_high_priority(self, qos):
         """Check QoS priority."""
 
-        for key, value in qos.iteritems():
+        for key, value in qos.items():
             if (key.find('MIN') == 0) or (key.find('LATENCY') == 0):
                 return True
 
index 67b22a2813d0ff49d3be72e352144a9c23e6b152..445ad9b31f17394de149986c1944d53817ebcb86 100644 (file)
@@ -588,7 +588,7 @@ class FlashSystemDriver(san.SanDriver):
         # Get preferred node and other nodes in I/O group
         preferred_node_entry = None
         io_group_nodes = []
-        for k, node in self._storage_nodes.iteritems():
+        for k, node in self._storage_nodes.items():
             if vdisk_params['protocol'] != node['protocol']:
                 continue
             if node['id'] == preferred_node:
@@ -644,7 +644,7 @@ class FlashSystemDriver(san.SanDriver):
             ctxt = context.get_admin_context()
             volume_type = volume_types.get_volume_type(ctxt, type_id)
             specs = volume_type.get('extra_specs')
-            for k, value in specs.iteritems():
+            for k, value in specs.items():
                 # Get the scope, if using scope format
                 key_split = k.split(':')
                 if len(key_split) == 1:
@@ -1084,7 +1084,7 @@ class FlashSystemDriver(san.SanDriver):
         # For each node, check what connection modes it supports.  Delete any
         # nodes that do not support any types (may be partially configured).
         to_delete = []
-        for k, node in self._storage_nodes.iteritems():
+        for k, node in self._storage_nodes.items():
             if not node['WWPN']:
                 to_delete.append(k)
 
index 5bd324f3a511cbe748b6c11d8a2c86e26df2a46b..8e1057a4aaaf251698dc702661bfd204070cebe4 100644 (file)
@@ -200,7 +200,7 @@ class StorwizeSVCDriver(san.SanDriver):
         # For each node, check what connection modes it supports.  Delete any
         # nodes that do not support any types (may be partially configured).
         to_delete = []
-        for k, node in self._state['storage_nodes'].iteritems():
+        for k, node in self._state['storage_nodes'].items():
             if ((len(node['ipv4']) or len(node['ipv6']))
                     and len(node['iscsi_name'])):
                 node['enabled_protocols'].append('iSCSI')
index fe129535bae424578dc4961dfc21421b949c7b11..f24875b5a127f4df14395439acacb93a092443da 100644 (file)
@@ -455,7 +455,7 @@ class StorwizeHelpers(object):
 
     def _get_opts_from_specs(self, opts, specs):
         qos = {}
-        for k, value in specs.iteritems():
+        for k, value in specs.items():
             # Get the scope, if using scope format
             key_split = k.split(':')
             if len(key_split) == 1:
@@ -1033,7 +1033,7 @@ class StorwizeHelpers(object):
 
     def add_vdisk_qos(self, vdisk, qos):
         """Add the QoS configuration to the volume."""
-        for key, value in qos.iteritems():
+        for key, value in qos.items():
             if key in self.svc_qos_keys.keys():
                 param = self.svc_qos_keys[key]['param']
                 self.ssh.chvdisk(vdisk, ['-' + param, str(value)])
@@ -1046,7 +1046,7 @@ class StorwizeHelpers(object):
         available in the QoS configuration, the value is taken from it;
         if not, the value will be set to default.
         """
-        for key, value in self.svc_qos_keys.iteritems():
+        for key, value in self.svc_qos_keys.items():
             param = value['param']
             if key in qos.keys():
                 # If the value is set in QoS, take the value from
@@ -1059,7 +1059,7 @@ class StorwizeHelpers(object):
 
     def disable_vdisk_qos(self, vdisk, qos):
         """Disable the QoS."""
-        for key, value in qos.iteritems():
+        for key, value in qos.items():
             if key in self.svc_qos_keys.keys():
                 param = self.svc_qos_keys[key]['param']
                 # Take the default value.
index 295c37fdaef907199352b41f0bf3b57c47763888..d319882b3be74d92ff0eb61e40b66c4721aa9b30 100644 (file)
@@ -174,7 +174,7 @@ def validate_qos_spec(qos_spec):
         return
     normalized_qos_keys = [key.lower() for key in QOS_KEYS]
     keylist = []
-    for key, value in six.iteritems(qos_spec):
+    for key, value in qos_spec.items():
         lower_case_key = key.lower()
         if lower_case_key not in normalized_qos_keys:
             msg = _('Unrecognized QOS keyword: "%s"') % key
index 3b976857fab4610f4f1e4f19b45ab3775d7d7d26..8fee2dbd24cda6d0010cf13e7e6495446f3201ff 100644 (file)
@@ -172,7 +172,7 @@ class RemoteFSDriver(driver.VolumeDriver):
                           self.configuration.nas_secure_file_permissions,
                           'nas_secure_file_operations':
                           self.configuration.nas_secure_file_operations}
-        for opt_name, opt_value in secure_options.iteritems():
+        for opt_name, opt_value in secure_options.items():
             if opt_value not in valid_secure_opts:
                 err_parms = {'name': opt_name, 'value': opt_value}
                 msg = _("NAS config '%(name)s=%(value)s' invalid. Must be "
@@ -978,7 +978,7 @@ class RemoteFSSnapDriver(RemoteFSDriver):
             new_base_file = base_file_img_info.backing_file
 
             base_id = None
-            for key, value in snap_info.iteritems():
+            for key, value in snap_info.items():
                 if value == base_file and key != 'active':
                     base_id = key
                     break
index ff52768d5c0603de1a96017569642229ec2719af..6420bc101fdf0c0171e2f5e6f3258a3664331a56 100644 (file)
@@ -867,7 +867,7 @@ class HP3PARCommon(object):
         else:
             kvs = specs
 
-        for key, value in kvs.iteritems():
+        for key, value in kvs.items():
             if 'qos:' in key:
                 fields = key.split(':')
                 key = fields[1]
@@ -878,7 +878,7 @@ class HP3PARCommon(object):
     def _get_keys_by_volume_type(self, volume_type):
         hp3par_keys = {}
         specs = volume_type.get('extra_specs')
-        for key, value in specs.iteritems():
+        for key, value in specs.items():
             if ':' in key:
                 fields = key.split(':')
                 key = fields[1]
index 70472f12df030dea132132b1ae1bba4f4e12c2f3..cbf35f470c286cbd36391504bda6e8f87b56faeb 100644 (file)
@@ -655,7 +655,7 @@ class HP3PARISCSIDriver(cinder.volume.driver.ISCSIDriver):
 
         # identify key (nsp) of least used nsp
         current_smallest_count = sys.maxint
-        for (nsp, count) in nsp_counts.iteritems():
+        for (nsp, count) in nsp_counts.items():
             if count < current_smallest_count:
                 current_least_used_nsp = nsp
                 current_smallest_count = count
index bd70124ba3507c20fd98a7123d87aea0b2c4b304..65fcc4cf3ad7474694da25d3212c2d97503b36a9 100644 (file)
@@ -438,7 +438,7 @@ class HPLeftHandRESTProxy(driver.ISCSIDriver):
     def _get_lh_extra_specs(self, extra_specs, valid_keys):
         """Get LeftHand extra_specs (valid_keys only)."""
         extra_specs_of_interest = {}
-        for key, value in extra_specs.iteritems():
+        for key, value in extra_specs.items():
             if key in valid_keys:
                 extra_specs_of_interest[key] = value
         return extra_specs_of_interest
@@ -446,7 +446,7 @@ class HPLeftHandRESTProxy(driver.ISCSIDriver):
     def _map_extra_specs(self, extra_specs):
         """Map the extra spec key/values to LeftHand key/values."""
         client_options = {}
-        for key, value in extra_specs.iteritems():
+        for key, value in extra_specs.items():
             # map extra spec key to lh client option key
             client_key = extra_specs_key_map[key]
             # map extra spect value to lh client option value
@@ -540,7 +540,7 @@ class HPLeftHandRESTProxy(driver.ISCSIDriver):
 
             # only set the ones that have changed
             changed_extra_specs = {}
-            for key, value in lh_extra_specs.iteritems():
+            for key, value in lh_extra_specs.items():
                 (old, new) = diff['extra_specs'][key]
                 if old != new:
                     changed_extra_specs[key] = value
index a226d70a5f94fe0f6073316a3f143ea6f848d1e4..e3321f0c3aa82307b1fd78093e3e32e43a47dc4a 100644 (file)
@@ -541,7 +541,7 @@ class SmbfsDriver(remotefs_drv.RemoteFSSnapDriver):
         else:
             options_dict['username'] = 'guest'
         named_options = ','.join("%s=%s" % (key, val) for (key, val)
-                                 in options_dict.iteritems())
+                                 in options_dict.items())
         options_list = ','.join(options_list)
         flags = '-o ' + ','.join([named_options, options_list])
 
index 43864665df6832c2f6c7442f8861f9f909c9f228..e500ceaf6ce709a9f8fe8a9803d020d11e07924e 100644 (file)
@@ -495,7 +495,7 @@ class SolidFireDriver(san.SanISCSIDriver):
         else:
             kvs = specs
 
-        for key, value in kvs.iteritems():
+        for key, value in kvs.items():
             if ':' in key:
                 fields = key.split(':')
                 key = fields[1]
index 4fe3cb5f7c66f68d6dd1c166e1c08b43c932688f..78a4e351cbb0223ffece1f55280e45fc091665bc 100644 (file)
@@ -241,7 +241,7 @@ class StorPoolDriver(driver.TransferVD, driver.ExtendVD, driver.CloneableVD,
         used = 0
         free = 0
         agSize = 512 * units.Mi
-        for (id, desc) in dl.iteritems():
+        for (id, desc) in dl.items():
             if desc.generationLeft != -1:
                 continue
             total += desc.agCount * agSize
@@ -405,7 +405,7 @@ class StorPoolDriver(driver.TransferVD, driver.ExtendVD, driver.CloneableVD,
         templ = self.configuration.storpool_template
         repl = self.configuration.storpool_replication
         if diff['extra_specs']:
-            for (k, v) in diff['extra_specs'].iteritems():
+            for (k, v) in diff['extra_specs'].items():
                 if k == 'volume_backend_name':
                     if v[0] != v[1]:
                         # Retype of a volume backend not supported yet,
index 32a80998d7d4aa06e92a954ecd9211b20203fb7d..0674bb62b88aaada2f16e5d8164a6bb3d7b60c69 100644 (file)
@@ -1073,7 +1073,7 @@ class XIOISEDriver(object):
             volume_type = volume_types.get_volume_type(ctxt, type_id)
             extra_specs = volume_type.get('extra_specs')
             # Parse out RAID, pool and affinity values
-            for key, value in extra_specs.iteritems():
+            for key, value in extra_specs.items():
                 subkey = ''
                 if ':' in key:
                     fields = key.split(':')
@@ -1110,7 +1110,7 @@ class XIOISEDriver(object):
             else:
                 kvs = volume_type.get('extra_specs')
             # Parse out min, max and burst values
-            for key, value in kvs.iteritems():
+            for key, value in kvs.items():
                 if ':' in key:
                     fields = key.split(':')
                     key = fields[1]
index 3be0251b34bd49b6ae3cffd9f27eef8849119b02..1d2746238793177d537554406ca79f4f6bd1381b 100644 (file)
@@ -281,7 +281,7 @@ class ExtractVolumeRequestTask(flow_utils.CinderTask):
         if not metadata:
             metadata = {}
 
-        for (k, v) in metadata.iteritems():
+        for (k, v) in metadata.items():
             if len(k) == 0:
                 msg = _("Metadata property key blank")
                 LOG.warning(msg)
index ee0a438fcf0090012525d68709378c4f66a03ec1..efe74afe9f2a87cdb0befa54b18933547018a924 100644 (file)
@@ -242,7 +242,7 @@ def get_all_specs(context, inactive=False, search_opts=None):
         LOG.debug("Searching by: %s", search_opts)
 
         def _check_specs_match(qos_specs, searchdict):
-            for k, v in searchdict.iteritems():
+            for k, v in searchdict.items():
                 if ((k not in qos_specs['specs'].keys() or
                      qos_specs['specs'][k] != v)):
                     return False
@@ -252,9 +252,9 @@ def get_all_specs(context, inactive=False, search_opts=None):
         filter_mapping = {'qos_specs': _check_specs_match}
 
         result = {}
-        for name, args in qos_specs.iteritems():
+        for name, args in qos_specs.items():
             # go over all filters in the list
-            for opt, values in search_opts.iteritems():
+            for opt, values in search_opts.items():
                 try:
                     filter_func = filter_mapping[opt]
                 except KeyError:
index 1b3cbadb2f7d95600f5fc146f8baae9913e8ec48..b02ef946df01d906f2410c6a735991c1f4b24ed1 100644 (file)
@@ -102,7 +102,7 @@ def get_all_types(context, inactive=0, search_opts=None):
         LOG.debug("Searching by: %s" % search_opts)
 
         def _check_extra_specs_match(vol_type, searchdict):
-            for k, v in searchdict.iteritems():
+            for k, v in searchdict.items():
                 if (k not in vol_type['extra_specs'].keys()
                         or vol_type['extra_specs'][k] != v):
                     return False
@@ -112,9 +112,9 @@ def get_all_types(context, inactive=0, search_opts=None):
         filter_mapping = {'extra_specs': _check_extra_specs_match}
 
         result = {}
-        for type_name, type_args in vol_types.iteritems():
+        for type_name, type_args in vol_types.items():
             # go over all filters in the list
-            for opt, values in search_opts.iteritems():
+            for opt, values in search_opts.items():
                 try:
                     filter_func = filter_mapping[opt]
                 except KeyError:
@@ -258,11 +258,11 @@ def volume_types_diff(context, vol_type_id1, vol_type_id2):
             dict1 = {}
         if dict2 is None:
             dict2 = {}
-        for k, v in dict1.iteritems():
+        for k, v in dict1.items():
             res[k] = (v, dict2.get(k))
             if k not in dict2 or res[k][0] != res[k][1]:
                 equal = False
-        for k, v in dict2.iteritems():
+        for k, v in dict2.items():
             res[k] = (dict1.get(k), v)
             if k not in dict1 or res[k][0] != res[k][1]:
                 equal = False
index 1d1c4d0e39201657c104318b600a1ff37715f16e..c2d8ed23ed75c3af6edd82b2060c0bd51ee9f08f 100644 (file)
@@ -445,7 +445,7 @@ class Debug(Middleware):
         resp = req.get_response(self.application)
 
         print(('*' * 40) + ' RESPONSE HEADERS')  # noqa
-        for (key, value) in resp.headers.iteritems():
+        for (key, value) in resp.headers.items():
             print(key, '=', value)  # noqa
         print()  # noqa