]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix some pylint error in Coraid Driver
authorNikolay Sobolevskiy <nsobolevsky@mirantis.com>
Mon, 19 Aug 2013 07:22:37 +0000 (11:22 +0400)
committerNikolay Sobolevskiy <nsobolevsky@mirantis.com>
Mon, 19 Aug 2013 07:22:37 +0000 (11:22 +0400)
Chage usage of rpc method in tests, for fixing
3 pylint error.

Change-Id: Ib30d3f1a26b718d2fca588668683253c03df01ba

cinder/tests/test_coraid.py
cinder/volume/drivers/coraid.py

index f31b850847ada20602591ab3fdaaa7aea93112c6..05d743c28a0e760e7bf8539470fbf064e17bb6e6 100644 (file)
@@ -374,14 +374,10 @@ class CoraidDriverIntegrationalTestCase(CoraidDriverLoginSuccessTestCase):
         self.mox.VerifyAll()
 
     def test_ping_failed(self):
-        self.mox.StubOutWithMock(self.driver._appliance, 'rpc')
-
-        def rpc(handle, url_params, data,
-                allow_empty_response=True):
+        def rpc(*args, **kwargs):
             raise Exception("Some exception")
 
-        self.driver._appliance.rpc = rpc
-
+        self.stubs.Set(self.driver._appliance, 'rpc', rpc)
         self.mox.ReplayAll()
 
         self.assertRaises(exception.CoraidESMNotAvailable,
index 354dd885ac05c35d1f03cf26a41ae2753a31b8bb..8a5d1bc68a2e59106dcedcb69de26005d2fed90c 100644 (file)
@@ -219,9 +219,7 @@ class CoraidAppliance(object):
             reply = self._rest_client.rpc(handle, url_params, data,
                                           allow_empty_response)
 
-            if ('state' in reply and
-                reply['state'] in ESM_SESSION_EXPIRED_STATES and
-                    reply['metaCROp'] == 'reboot'):
+            if self._is_session_expired(reply):
                 relogin_attempts -= 1
                 if relogin_attempts <= 0:
                     raise exception.CoraidESMReloginFailed()
@@ -230,6 +228,11 @@ class CoraidAppliance(object):
             else:
                 return reply
 
+    def _is_session_expired(self, reply):
+        return ('state' in reply and
+                reply['state'] in ESM_SESSION_EXPIRED_STATES and
+                reply['metaCROp'] == 'reboot')
+
     def _is_bad_config_state(self, reply):
         return (not reply or
                 'configState' not in reply or