From: Rajesh Tailor <rajesh.tailor@nttdata.com>
Date: Wed, 27 May 2015 09:43:02 +0000 (-0700)
Subject: Fix expression-not-assigned pylint issues
X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=204dbdf9880d734f36b3f0786a24525bdfb83b85;p=openstack-build%2Fcinder-build.git

Fix expression-not-assigned pylint issues

Fixed expression-not-assigned (warning code W0106: Expression "%s" is
assigned to nothing) pylint issues in cinder project.

Closes-Bug: 1459538
Change-Id: Ibb16bde9ff0e3ebc3f1b595ea402d27938b5cf32
---

diff --git a/cinder/cmd/volume_usage_audit.py b/cinder/cmd/volume_usage_audit.py
index cfee52889..7caebfd3e 100644
--- a/cinder/cmd/volume_usage_audit.py
+++ b/cinder/cmd/volume_usage_audit.py
@@ -106,7 +106,7 @@ def main():
     volumes = db.volume_get_active_by_window(admin_context,
                                              begin,
                                              end)
-    LOG.debug("Found %d volumes"), len(volumes)
+    LOG.debug("Found %d volumes", len(volumes))
     for volume_ref in volumes:
         try:
             LOG.debug("Send exists notification for <volume_id: "
@@ -178,7 +178,7 @@ def main():
     snapshots = db.snapshot_get_active_by_window(admin_context,
                                                  begin,
                                                  end)
-    LOG.debug("Found %d snapshots"), len(snapshots)
+    LOG.debug("Found %d snapshots", len(snapshots))
     for snapshot_ref in snapshots:
         try:
             LOG.debug("Send notification for <snapshot_id: %(snapshot_id)s> "
diff --git a/cinder/tests/unit/api/contrib/test_cgsnapshots.py b/cinder/tests/unit/api/contrib/test_cgsnapshots.py
index b1d970833..6a3113e83 100644
--- a/cinder/tests/unit/api/contrib/test_cgsnapshots.py
+++ b/cinder/tests/unit/api/contrib/test_cgsnapshots.py
@@ -351,7 +351,7 @@ class CgsnapshotsAPITestCase(test.TestCase):
         consistencygroup_id = utils.create_consistencygroup(self.context)['id']
         utils.create_volume(
             self.context,
-            consistencygroup_id=consistencygroup_id)['id']
+            consistencygroup_id=consistencygroup_id)
 
         body = {"cgsnapshot": {"name": "cg1",
                                "description":
@@ -394,7 +394,7 @@ class CgsnapshotsAPITestCase(test.TestCase):
         consistencygroup_id = utils.create_consistencygroup(self.context)['id']
         utils.create_volume(
             self.context,
-            consistencygroup_id=consistencygroup_id)['id']
+            consistencygroup_id=consistencygroup_id)
 
         body = {"cgsnapshot": {"name": "cg1",
                                "description":
@@ -419,7 +419,7 @@ class CgsnapshotsAPITestCase(test.TestCase):
         consistencygroup_id = utils.create_consistencygroup(self.context)['id']
         utils.create_volume(
             self.context,
-            consistencygroup_id=consistencygroup_id)['id']
+            consistencygroup_id=consistencygroup_id)
 
         body = {"cgsnapshot": {"name": "cg1",
                                "description":
diff --git a/cinder/tests/unit/image/test_glance.py b/cinder/tests/unit/image/test_glance.py
index f4032c7bf..bba9bd650 100644
--- a/cinder/tests/unit/image/test_glance.py
+++ b/cinder/tests/unit/image/test_glance.py
@@ -215,7 +215,7 @@ class TestGlanceImageService(test.TestCase):
         properties = {'owner_id': 'proj1'}
         fixture['properties'] = properties
 
-        self.service.create(self.context, fixture)['id']
+        self.service.create(self.context, fixture)
 
         proj = self.context.project_id
         self.context.project_id = 'proj1'
diff --git a/cinder/tests/unit/test_volume.py b/cinder/tests/unit/test_volume.py
index 7c53a1be9..35de9584b 100644
--- a/cinder/tests/unit/test_volume.py
+++ b/cinder/tests/unit/test_volume.py
@@ -5730,7 +5730,7 @@ class LVMVolumeDriverTestCase(DriverTestCase):
         backup['parent_id'] = None
         backup['size'] = 5 * 1024 * 1024
         backup['object_count'] = 22
-        db.backup_create(self.context, backup)['id']
+        db.backup_create(self.context, backup)
 
         lvm_driver.check_for_setup_error()
 
diff --git a/cinder/volume/drivers/netapp/dataontap/block_base.py b/cinder/volume/drivers/netapp/dataontap/block_base.py
index 9e461992e..4193fe5b1 100644
--- a/cinder/volume/drivers/netapp/dataontap/block_base.py
+++ b/cinder/volume/drivers/netapp/dataontap/block_base.py
@@ -578,7 +578,7 @@ class NetAppBlockStorageLibrary(object):
             raise exception.ManageExistingInvalidReference(
                 existing_ref=existing_ref, reason=reason)
         lun_info = {}
-        lun_info.setdefault('path', path) if path else None
+        lun_info.setdefault('path', path if path else None)
         if hasattr(self, 'vserver') and uuid:
             lun_info['uuid'] = uuid
         luns = self.zapi_client.get_lun_by_args(**lun_info)
diff --git a/cinder/volume/drivers/netapp/eseries/client.py b/cinder/volume/drivers/netapp/eseries/client.py
index d7c496c02..87812df5e 100644
--- a/cinder/volume/drivers/netapp/eseries/client.py
+++ b/cinder/volume/drivers/netapp/eseries/client.py
@@ -260,8 +260,8 @@ class RestClient(WebserviceClient):
         """Creates host on array."""
         path = "/storage-systems/{system-id}/hosts"
         data = {'name': label, 'hostType': host_type}
-        data.setdefault('groupId', group_id) if group_id else None
-        data.setdefault('ports', ports) if ports else None
+        data.setdefault('groupId', group_id if group_id else None)
+        data.setdefault('ports', ports if ports else None)
         return self._invoke('POST', path, data)
 
     def create_host_with_port(self, label, host_type, port_id,
@@ -377,8 +377,8 @@ class RestClient(WebserviceClient):
         """Registers storage system with web service."""
         path = "/storage-systems"
         data = {'controllerAddresses': controller_addresses}
-        data.setdefault('wwn', wwn) if wwn else None
-        data.setdefault('password', password) if password else None
+        data.setdefault('wwn', wwn if wwn else None)
+        data.setdefault('password', password if password else None)
         return self._invoke('POST', path, data, use_system=False)
 
     def update_stored_system_password(self, password):
diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py
index b56d67497..8461607f6 100644
--- a/cinder/volume/drivers/rbd.py
+++ b/cinder/volume/drivers/rbd.py
@@ -593,9 +593,11 @@ class RBDDriver(driver.RetypeVD, driver.TransferVD, driver.ExtendVD,
         snapshot still depends on the parent.
         """
         try:
-            snap and volume.set_snap(snap)
+            if snap:
+                volume.set_snap(snap)
             pool, parent, parent_snap = tuple(volume.parent_info())
-            snap and volume.set_snap(None)
+            if snap:
+                volume.set_snap(None)
             # Strip the tag off the end of the volume name since it will not be
             # in the snap name.
             if volume_name.endswith('.deleted'):