Fix some pylint error in Coraid Driver
Chage usage of rpc method in tests, for fixing 3 pylint error. Change-Id: Ib30d3f1a26b718d2fca588668683253c03df01ba
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user