Skip to content

Commit 9e19a9a

Browse files
Gaurrav AradhyeSrikanteswaraRao Talluri
authored andcommitted
Revert "CLOUDSTACK-7408: Fixed - Private key of the ssh keypair was getting corrupted"
This reverts commit e921ec6. CLOUDSTACK-7408: sshClient.py - removing function load_host_keys(). This function is used to load host keys from local host keys file and to save back the host key. It is not needed while running test cases because we are connecting to unknown host anyway and don't want to use any local host key file. We have the AutoAddPolicy for missing host key file, hence whenever ssh connects to a new host, it will save the host key in memory temporarily. Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
1 parent 0d6e3e4 commit 9e19a9a

3 files changed

Lines changed: 6 additions & 26 deletions

File tree

‎tools/marvin/marvin/lib/base.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ def restore(self, apiclient, templateid=None):
552552

553553
def get_ssh_client(
554554
self, ipaddress=None, reconnect=False, port=None,
555-
keyPairFileLocation=None, knownHostsFilePath=None):
555+
keyPairFileLocation=None):
556556
"""Get SSH object of VM"""
557557

558558
# If NAT Rules are not created while VM deployment in Advanced mode
@@ -571,16 +571,14 @@ def get_ssh_client(
571571
self.ssh_port,
572572
self.username,
573573
self.password,
574-
keyPairFileLocation=keyPairFileLocation,
575-
knownHostsFilePath=knownHostsFilePath
574+
keyPairFileLocation=keyPairFileLocation
576575
)
577576
self.ssh_client = self.ssh_client or is_server_ssh_ready(
578577
self.ssh_ip,
579578
self.ssh_port,
580579
self.username,
581580
self.password,
582-
keyPairFileLocation=keyPairFileLocation,
583-
knownHostsFilePath=knownHostsFilePath
581+
keyPairFileLocation=keyPairFileLocation
584582
)
585583
return self.ssh_client
586584

‎tools/marvin/marvin/lib/utils.py‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ def cleanup_resources(api_client, resources):
121121
obj.delete(api_client)
122122

123123

124-
def is_server_ssh_ready(ipaddress, port, username, password, retries=20,
125-
retryinterv=30, timeout=10.0, keyPairFileLocation=None,
126-
knownHostsFilePath=None):
124+
def is_server_ssh_ready(ipaddress, port, username, password, retries=20, retryinterv=30, timeout=10.0, keyPairFileLocation=None):
127125
'''
128126
@Name: is_server_ssh_ready
129127
@Input: timeout: tcp connection timeout flag,
@@ -142,8 +140,7 @@ def is_server_ssh_ready(ipaddress, port, username, password, retries=20,
142140
keyPairFiles=keyPairFileLocation,
143141
retries=retries,
144142
delay=retryinterv,
145-
timeout=timeout,
146-
knownHostsFilePath=knownHostsFilePath)
143+
timeout=timeout)
147144
except Exception, e:
148145
raise Exception("SSH connection has Failed. Waited %ss. Error is %s" % (retries * retryinterv, str(e)))
149146
else:

‎tools/marvin/marvin/sshClient.py‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
SFTPClient)
2525
import socket
2626
import time
27-
import os
2827
from marvin.cloudstackException import (
2928
internalError,
3029
GetDetailExceptionInfo
@@ -50,8 +49,7 @@ class SshClient(object):
5049
'''
5150

5251
def __init__(self, host, port, user, passwd, retries=60, delay=10,
53-
log_lvl=logging.DEBUG, keyPairFiles=None, timeout=10.0,
54-
knownHostsFilePath=None):
52+
log_lvl=logging.DEBUG, keyPairFiles=None, timeout=10.0):
5553
self.host = None
5654
self.port = 22
5755
self.user = user
@@ -79,18 +77,6 @@ def __init__(self, host, port, user, passwd, retries=60, delay=10,
7977
self.timeout = timeout
8078
if port is not None and port >= 0:
8179
self.port = port
82-
83-
# If the known_hosts file is not at default location,
84-
# then its location can be passed, or else the default
85-
# path will be considered (which is ~/.ssh/known_hosts)
86-
if knownHostsFilePath:
87-
self.knownHostsFilePath = knownHostsFilePath
88-
else:
89-
self.knownHostsFilePath = os.path.expanduser(
90-
os.path.join(
91-
"~",
92-
".ssh",
93-
"known_hosts"))
9480
if self.createConnection() == FAILED:
9581
raise internalError("SSH Connection Failed")
9682

@@ -134,7 +120,6 @@ def createConnection(self):
134120
password=self.passwd,
135121
timeout=self.timeout)
136122
else:
137-
self.ssh.load_host_keys(self.knownHostsFilePath)
138123
self.ssh.connect(hostname=self.host,
139124
port=self.port,
140125
username=self.user,

0 commit comments

Comments
 (0)