From dbc0fda1505bb1bedd418a4fa7f3e038c223eff9 Mon Sep 17 00:00:00 2001 From: Nikolay Sobolevskiy Date: Mon, 19 Aug 2013 11:22:37 +0400 Subject: [PATCH] Fix some pylint error in Coraid Driver Chage usage of rpc method in tests, for fixing 3 pylint error. Change-Id: Ib30d3f1a26b718d2fca588668683253c03df01ba --- cinder/tests/test_coraid.py | 8 ++------ cinder/volume/drivers/coraid.py | 9 ++++++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cinder/tests/test_coraid.py b/cinder/tests/test_coraid.py index f31b85084..05d743c28 100644 --- a/cinder/tests/test_coraid.py +++ b/cinder/tests/test_coraid.py @@ -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, diff --git a/cinder/volume/drivers/coraid.py b/cinder/volume/drivers/coraid.py index 354dd885a..8a5d1bc68 100644 --- a/cinder/volume/drivers/coraid.py +++ b/cinder/volume/drivers/coraid.py @@ -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 -- 2.45.2