Improve static provider to check non-ssh hosts

This behavior is now in line with how the OpenStack driver is checking
hosts with a non-ssh connection type.

Change-Id: Ica553430d1d64fe69f5a8ccc9d4b453c7f21dac8
This commit is contained in:
Simon Westphahl 2018-09-05 12:35:30 +02:00
parent a54e4bf0dc
commit 55e70f7636
1 changed files with 8 additions and 4 deletions

View File

@ -36,18 +36,22 @@ class StaticNodeProvider(Provider):
self.static_nodes = {}
def checkHost(self, node):
# Check node is reachable
if node["connection-type"] != "ssh":
return
'''Check node is reachable'''
# only gather host keys if the connection type is ssh
gather_hostkeys = node["connection-type"] == 'ssh'
try:
keys = nodeutils.nodescan(node["name"],
port=node["connection-port"],
timeout=node["timeout"])
timeout=node["timeout"],
gather_hostkeys=gather_hostkeys)
except exceptions.ConnectionTimeoutException:
raise StaticNodeError(
"%s:%s: ConnectionTimeoutException" % (
node["name"], node["connection-port"]))
if not gather_hostkeys:
return
# Check node host-key
if set(node["host-key"]).issubset(set(keys)):
return keys