]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove unused context parameter
authorAbhijeet Malawade <Abhijeet.Malawade@nttdata.com>
Tue, 12 May 2015 08:58:46 +0000 (01:58 -0700)
committerAbhijeet Malawade <Abhijeet.Malawade@nttdata.com>
Tue, 12 May 2015 11:42:02 +0000 (04:42 -0700)
Below methods from volume utils are not using context parameter:
1. _usage_from_volume
2. _usage_from_backup
3. _usage_from_snapshot
4. _usage_from_consistencygroup
5. _usage_from_cgsnapshot

So the context parameter is removed from all of these methods.

Closes-Bug: #1454212
Change-Id: Id87c5635db4a0e8df00f7bd7b87ffe60876f255c

cinder/tests/unit/test_volume_utils.py
cinder/volume/utils.py

index cd49bf6b93954e9b740de4679fd9a303e3e24968..8beba937f099cd615560cb8ae539f11e78a50647 100644 (file)
@@ -42,8 +42,7 @@ class NotifyUsageTestCase(test.TestCase):
                                                         mock.sentinel.volume,
                                                         'test_suffix')
         self.assertIsNone(output)
-        mock_usage.assert_called_once_with(mock.sentinel.context,
-                                           mock.sentinel.volume)
+        mock_usage.assert_called_once_with(mock.sentinel.volume)
         mock_rpc.get_notifier.assert_called_once_with('volume', 'host1')
         mock_rpc.get_notifier.return_value.info.assert_called_once_with(
             mock.sentinel.context,
@@ -63,8 +62,7 @@ class NotifyUsageTestCase(test.TestCase):
             extra_usage_info={'a': 'b', 'c': 'd'},
             host='host2')
         self.assertIsNone(output)
-        mock_usage.assert_called_once_with(mock.sentinel.context,
-                                           mock.sentinel.volume, a='b', c='d')
+        mock_usage.assert_called_once_with(mock.sentinel.volume, a='b', c='d')
         mock_rpc.get_notifier.assert_called_once_with('volume', 'host2')
         mock_rpc.get_notifier.return_value.info.assert_called_once_with(
             mock.sentinel.context,
@@ -82,8 +80,7 @@ class NotifyUsageTestCase(test.TestCase):
             mock.sentinel.volume,
             'test_suffix')
         self.assertIsNone(output)
-        mock_usage.assert_called_once_with(mock.sentinel.context,
-                                           mock.sentinel.volume)
+        mock_usage.assert_called_once_with(mock.sentinel.volume)
         mock_rpc.get_notifier.assert_called_once_with('replication', 'host1')
         mock_rpc.get_notifier.return_value.info.assert_called_once_with(
             mock.sentinel.context,
@@ -103,8 +100,7 @@ class NotifyUsageTestCase(test.TestCase):
             extra_usage_info={'a': 'b', 'c': 'd'},
             host='host2')
         self.assertIsNone(output)
-        mock_usage.assert_called_once_with(mock.sentinel.context,
-                                           mock.sentinel.volume,
+        mock_usage.assert_called_once_with(mock.sentinel.volume,
                                            a='b', c='d')
         mock_rpc.get_notifier.assert_called_once_with('replication', 'host2')
         mock_rpc.get_notifier.return_value.info.assert_called_once_with(
@@ -123,8 +119,7 @@ class NotifyUsageTestCase(test.TestCase):
             mock.sentinel.volume,
             'test_suffix')
         self.assertIsNone(output)
-        mock_usage.assert_called_once_with(mock.sentinel.context,
-                                           mock.sentinel.volume)
+        mock_usage.assert_called_once_with(mock.sentinel.volume)
         mock_rpc.get_notifier.assert_called_once_with('replication', 'host1')
         mock_rpc.get_notifier.return_value.error.assert_called_once_with(
             mock.sentinel.context,
@@ -144,8 +139,7 @@ class NotifyUsageTestCase(test.TestCase):
             extra_error_info={'a': 'b', 'c': 'd'},
             host='host2')
         self.assertIsNone(output)
-        mock_usage.assert_called_once_with(mock.sentinel.context,
-                                           mock.sentinel.volume,
+        mock_usage.assert_called_once_with(mock.sentinel.volume,
                                            a='b', c='d')
         mock_rpc.get_notifier.assert_called_once_with('replication', 'host2')
         mock_rpc.get_notifier.return_value.error.assert_called_once_with(
@@ -164,8 +158,7 @@ class NotifyUsageTestCase(test.TestCase):
             mock.sentinel.snapshot,
             'test_suffix')
         self.assertIsNone(output)
-        mock_usage.assert_called_once_with(mock.sentinel.context,
-                                           mock.sentinel.snapshot)
+        mock_usage.assert_called_once_with(mock.sentinel.snapshot)
         mock_rpc.get_notifier.assert_called_once_with('snapshot', 'host1')
         mock_rpc.get_notifier.return_value.info.assert_called_once_with(
             mock.sentinel.context,
@@ -185,8 +178,7 @@ class NotifyUsageTestCase(test.TestCase):
             extra_usage_info={'a': 'b', 'c': 'd'},
             host='host2')
         self.assertIsNone(output)
-        mock_usage.assert_called_once_with(mock.sentinel.context,
-                                           mock.sentinel.snapshot,
+        mock_usage.assert_called_once_with(mock.sentinel.snapshot,
                                            a='b', c='d')
         mock_rpc.get_notifier.assert_called_once_with('snapshot', 'host2')
         mock_rpc.get_notifier.return_value.info.assert_called_once_with(
@@ -207,9 +199,7 @@ class NotifyUsageTestCase(test.TestCase):
             'status': 'pause',
             'deleted': '',
         }
-        usage_info = volume_utils._usage_from_snapshot(
-            mock.sentinel.context,
-            raw_snapshot)
+        usage_info = volume_utils._usage_from_snapshot(raw_snapshot)
         expected_snapshot = {
             'tenant_id': '12b0330ec2584a',
             'user_id': '158cba1b8c2bb6008e',
@@ -235,8 +225,7 @@ class NotifyUsageTestCase(test.TestCase):
             mock.sentinel.consistencygroup,
             'test_suffix')
         self.assertIsNone(output)
-        mock_usage.assert_called_once_with(mock.sentinel.context,
-                                           mock.sentinel.consistencygroup)
+        mock_usage.assert_called_once_with(mock.sentinel.consistencygroup)
         mock_rpc.get_notifier.assert_called_once_with('consistencygroup',
                                                       'host1')
         mock_rpc.get_notifier.return_value.info.assert_called_once_with(
@@ -258,8 +247,7 @@ class NotifyUsageTestCase(test.TestCase):
             extra_usage_info={'a': 'b', 'c': 'd'},
             host='host2')
         self.assertIsNone(output)
-        mock_usage.assert_called_once_with(mock.sentinel.context,
-                                           mock.sentinel.consistencygroup,
+        mock_usage.assert_called_once_with(mock.sentinel.consistencygroup,
                                            a='b', c='d')
         mock_rpc.get_notifier.assert_called_once_with('consistencygroup',
                                                       'host2')
@@ -279,8 +267,7 @@ class NotifyUsageTestCase(test.TestCase):
             mock.sentinel.cgsnapshot,
             'test_suffix')
         self.assertIsNone(output)
-        mock_usage.assert_called_once_with(mock.sentinel.context,
-                                           mock.sentinel.cgsnapshot)
+        mock_usage.assert_called_once_with(mock.sentinel.cgsnapshot)
         mock_rpc.get_notifier.assert_called_once_with('cgsnapshot', 'host1')
         mock_rpc.get_notifier.return_value.info.assert_called_once_with(
             mock.sentinel.context,
@@ -300,8 +287,7 @@ class NotifyUsageTestCase(test.TestCase):
             extra_usage_info={'a': 'b', 'c': 'd'},
             host='host2')
         self.assertIsNone(output)
-        mock_usage.assert_called_once_with(mock.sentinel.context,
-                                           mock.sentinel.cgsnapshot,
+        mock_usage.assert_called_once_with(mock.sentinel.cgsnapshot,
                                            a='b', c='d')
         mock_rpc.get_notifier.assert_called_once_with('cgsnapshot', 'host2')
         mock_rpc.get_notifier.return_value.info.assert_called_once_with(
index 07d9ebb1b99f1cca166a9f770d330c362226b444..8bb440d21c483585ec3dec3899df0932b5587514 100644 (file)
@@ -42,7 +42,7 @@ def null_safe_str(s):
     return str(s) if s else ''
 
 
-def _usage_from_volume(context, volume_ref, **kw):
+def _usage_from_volume(volume_ref, **kw):
     usage_info = dict(
         tenant_id=volume_ref['project_id'],
         host=volume_ref['host'],
@@ -64,7 +64,7 @@ def _usage_from_volume(context, volume_ref, **kw):
     return usage_info
 
 
-def _usage_from_backup(context, backup_ref, **kw):
+def _usage_from_backup(backup_ref, **kw):
     usage_info = dict(tenant_id=backup_ref['project_id'],
                       user_id=backup_ref['user_id'],
                       availability_zone=backup_ref['availability_zone'],
@@ -91,7 +91,7 @@ def notify_about_volume_usage(context, volume, event_suffix,
     if not extra_usage_info:
         extra_usage_info = {}
 
-    usage_info = _usage_from_volume(context, volume, **extra_usage_info)
+    usage_info = _usage_from_volume(volume, **extra_usage_info)
 
     rpc.get_notifier("volume", host).info(context, 'volume.%s' % event_suffix,
                                           usage_info)
@@ -106,13 +106,13 @@ def notify_about_backup_usage(context, backup, event_suffix,
     if not extra_usage_info:
         extra_usage_info = {}
 
-    usage_info = _usage_from_backup(context, backup, **extra_usage_info)
+    usage_info = _usage_from_backup(backup, **extra_usage_info)
 
     rpc.get_notifier("backup", host).info(context, 'backup.%s' % event_suffix,
                                           usage_info)
 
 
-def _usage_from_snapshot(context, snapshot_ref, **extra_usage_info):
+def _usage_from_snapshot(snapshot_ref, **extra_usage_info):
     usage_info = {
         'tenant_id': snapshot_ref['project_id'],
         'user_id': snapshot_ref['user_id'],
@@ -138,7 +138,7 @@ def notify_about_snapshot_usage(context, snapshot, event_suffix,
     if not extra_usage_info:
         extra_usage_info = {}
 
-    usage_info = _usage_from_snapshot(context, snapshot, **extra_usage_info)
+    usage_info = _usage_from_snapshot(snapshot, **extra_usage_info)
 
     rpc.get_notifier('snapshot', host).info(context,
                                             'snapshot.%s' % event_suffix,
@@ -153,8 +153,7 @@ def notify_about_replication_usage(context, volume, suffix,
     if not extra_usage_info:
         extra_usage_info = {}
 
-    usage_info = _usage_from_volume(context,
-                                    volume,
+    usage_info = _usage_from_volume(volume,
                                     **extra_usage_info)
 
     rpc.get_notifier('replication', host).info(context,
@@ -170,8 +169,7 @@ def notify_about_replication_error(context, volume, suffix,
     if not extra_error_info:
         extra_error_info = {}
 
-    usage_info = _usage_from_volume(context,
-                                    volume,
+    usage_info = _usage_from_volume(volume,
                                     **extra_error_info)
 
     rpc.get_notifier('replication', host).error(context,
@@ -179,7 +177,7 @@ def notify_about_replication_error(context, volume, suffix,
                                                 usage_info)
 
 
-def _usage_from_consistencygroup(context, group_ref, **kw):
+def _usage_from_consistencygroup(group_ref, **kw):
     usage_info = dict(tenant_id=group_ref['project_id'],
                       user_id=group_ref['user_id'],
                       availability_zone=group_ref['availability_zone'],
@@ -200,8 +198,7 @@ def notify_about_consistencygroup_usage(context, group, event_suffix,
     if not extra_usage_info:
         extra_usage_info = {}
 
-    usage_info = _usage_from_consistencygroup(context,
-                                              group,
+    usage_info = _usage_from_consistencygroup(group,
                                               **extra_usage_info)
 
     rpc.get_notifier("consistencygroup", host).info(
@@ -210,7 +207,7 @@ def notify_about_consistencygroup_usage(context, group, event_suffix,
         usage_info)
 
 
-def _usage_from_cgsnapshot(context, cgsnapshot_ref, **kw):
+def _usage_from_cgsnapshot(cgsnapshot_ref, **kw):
     usage_info = dict(
         tenant_id=cgsnapshot_ref['project_id'],
         user_id=cgsnapshot_ref['user_id'],
@@ -232,8 +229,7 @@ def notify_about_cgsnapshot_usage(context, cgsnapshot, event_suffix,
     if not extra_usage_info:
         extra_usage_info = {}
 
-    usage_info = _usage_from_cgsnapshot(context,
-                                        cgsnapshot,
+    usage_info = _usage_from_cgsnapshot(cgsnapshot,
                                         **extra_usage_info)
 
     rpc.get_notifier("cgsnapshot", host).info(