Fix ssh proxy regression

The recent change [1] broke ssh proxy because ssh.close()
closes the transport connection as well.  Fix it by creating
proxy connections on every retries.

[1] Ida499a80be184b1af9b53d4ab27a8abbc4d59898

Closes-Bug: #1694458
Change-Id: Ic9a65d1da518a7253a1f6e4f4a909138f9e52de9
This commit is contained in:
YAMAMOTO Takashi 2017-05-30 20:53:50 +09:00
parent 345dc6cda4
commit 2c0ae157d5
1 changed files with 4 additions and 4 deletions

View File

@ -84,10 +84,6 @@ class Client(object):
ssh.set_missing_host_key_policy(
paramiko.AutoAddPolicy())
_start_time = time.time()
if self.proxy_client is not None:
proxy_chan = self._get_proxy_channel()
else:
proxy_chan = None
if self.pkey is not None:
LOG.info("Creating ssh connection to '%s:%d' as '%s'"
" with public key authentication",
@ -98,6 +94,10 @@ class Client(object):
self.host, self.port, self.username, str(self.password))
attempts = 0
while True:
if self.proxy_client is not None:
proxy_chan = self._get_proxy_channel()
else:
proxy_chan = None
try:
ssh.connect(self.host, port=self.port, username=self.username,
password=self.password,