Add support for SSH proxy in os-faults integration.

Change-Id: I07fbae3c477b4075ffba6b454b4a5f62d53cf63d
This commit is contained in:
Federico Ressi 2019-10-01 14:10:32 +02:00
parent c47a48bfbf
commit 0a81543134
4 changed files with 24 additions and 11 deletions
tobiko
openstack/os_faults
shell/ssh
tripleo

@ -21,6 +21,7 @@ from oslo_log import log
import tobiko
from tobiko.tripleo import overcloud
from tobiko.shell import ssh
LOG = log.getLogger(__name__)
@ -135,8 +136,7 @@ class OsFaultsConfigFileFixture(tobiko.SharedFixture):
config_content = template.render(
nodes=self.list_nodes(),
services=self.list_services(),
containers=self.list_containers(),
proxy=None)
containers=self.list_containers())
with tobiko.open_output_file(config_filename) as f:
f.write(config_content)
return config_filename
@ -157,13 +157,23 @@ class OsFaultsConfigFileFixture(tobiko.SharedFixture):
nodes = []
overcloud_nodes = overcloud.list_overcloud_nodes()
for overcloud_node in overcloud_nodes:
host_config = overcloud.overcloud_host_config(
overcloud_host_config = overcloud.overcloud_host_config(
overcloud_node.name)
address = str(overcloud_host_config.hostname)
os_faults_node = dict(
name=overcloud_node.name,
username=host_config.username,
address=host_config.hostname,
private_key_file=host_config.key_filename)
address=address,
username=overcloud_host_config.username,
private_key_file=overcloud_host_config.key_filename)
host_config = ssh.ssh_host_config(host=address)
if host_config.proxy_jump:
proxy_config = ssh.ssh_host_config(
host=host_config.proxy_jump)
os_faults_node['jump'] = dict(
username=proxy_config.username,
host=proxy_config.hostname,
private_key_file=os.path.expanduser(
proxy_config.key_filename))
nodes.append(os_faults_node)
return nodes

@ -10,11 +10,11 @@ node_discover:
auth:
username: {{ node['username'] }}
private_key_file: {{ node['private_key_file'] }}
{% if proxy %}
{% if 'jump' in node %}
jump:
host: {{ proxy['host'] }}
username: {{ proxy['username'] }}
private_key_file: {{ proxy['private_key_file'] }}
host: {{ node['jump']['host'] }}
username: {{ node['jump']['username'] }}
private_key_file: {{ node['jump']['private_key_file'] }}
{% endif %}
{% endfor %}

@ -20,6 +20,7 @@ from tobiko.shell.ssh import _client
from tobiko.shell.ssh import _command
SSHHostConfig = _config.SSHHostConfig
ssh_host_config = _config.ssh_host_config
SSHClientFixture = _client.SSHClientFixture
ssh_client = _client.ssh_client

@ -152,6 +152,8 @@ class OvercloudHostConfig(tobiko.SharedFixture):
@property
def connect_parameters(self):
parameters = ssh.gather_ssh_connect_parameters(self)
parameters = ssh.ssh_host_config(
host=str(self.hostname)).connect_parameters
parameters.update(ssh.gather_ssh_connect_parameters(self))
parameters.update(self._connect_parameters)
return parameters