Merge "Set timeout for parmiko ssh connection"
This commit is contained in:
commit
0af7c9649b
@ -147,10 +147,11 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||||||
|
|
||||||
def _ssh_exec(self, server, command):
|
def _ssh_exec(self, server, command):
|
||||||
connection = self.ssh_connections.get(server['instance_id'])
|
connection = self.ssh_connections.get(server['instance_id'])
|
||||||
|
ssh_conn_timeout = self.configuration.ssh_conn_timeout
|
||||||
if not connection:
|
if not connection:
|
||||||
ssh_pool = utils.SSHPool(server['ip'],
|
ssh_pool = utils.SSHPool(server['ip'],
|
||||||
22,
|
22,
|
||||||
None,
|
ssh_conn_timeout,
|
||||||
server['username'],
|
server['username'],
|
||||||
server.get('password'),
|
server.get('password'),
|
||||||
server.get('pk_path'),
|
server.get('pk_path'),
|
||||||
|
@ -1267,6 +1267,8 @@ class GenericShareDriverTestCase(test.TestCase):
|
|||||||
self._driver.admin_context, server_details)
|
self._driver.admin_context, server_details)
|
||||||
|
|
||||||
def test_ssh_exec_connection_not_exist(self):
|
def test_ssh_exec_connection_not_exist(self):
|
||||||
|
ssh_conn_timeout = 30
|
||||||
|
CONF.set_default('ssh_conn_timeout', ssh_conn_timeout)
|
||||||
ssh_output = 'fake_ssh_output'
|
ssh_output = 'fake_ssh_output'
|
||||||
cmd = ['fake', 'command']
|
cmd = ['fake', 'command']
|
||||||
ssh = mock.Mock()
|
ssh = mock.Mock()
|
||||||
@ -1282,7 +1284,7 @@ class GenericShareDriverTestCase(test.TestCase):
|
|||||||
result = self._driver._ssh_exec(self.server, cmd)
|
result = self._driver._ssh_exec(self.server, cmd)
|
||||||
|
|
||||||
utils.SSHPool.assert_called_once_with(
|
utils.SSHPool.assert_called_once_with(
|
||||||
self.server['ip'], 22, None, self.server['username'],
|
self.server['ip'], 22, ssh_conn_timeout, self.server['username'],
|
||||||
self.server['password'], self.server['pk_path'], max_size=1)
|
self.server['password'], self.server['pk_path'], max_size=1)
|
||||||
ssh_pool.create.assert_called_once_with()
|
ssh_pool.create.assert_called_once_with()
|
||||||
processutils.ssh_execute.assert_called_once_with(ssh, 'fake command')
|
processutils.ssh_execute.assert_called_once_with(ssh, 'fake command')
|
||||||
|
Loading…
Reference in New Issue
Block a user