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,
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()
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