Merge "Add --overcloud-ssh-network"

This commit is contained in:
Zuul
2018-06-08 14:27:29 +00:00
committed by Gerrit Code Review
4 changed files with 45 additions and 18 deletions

View File

@@ -85,3 +85,25 @@ class TestDeploymentWorkflows(utils.TestCommand):
# tmpdir should be cleaned up
self.assertEqual(1, mock_rmtree.call_count)
self.assertEqual('/foo', mock_rmtree.call_args[0][0])
@mock.patch('tripleoclient.utils.get_role_net_ip_map')
def test_get_overcloud_hosts(self, mock_role_net_ip_map):
stack = mock.Mock()
mock_role_net_ip_map.return_value = {
'Controller': {
'ctlplane': ['1.1.1.1', '2.2.2.2', '3.3.3.3'],
'external': ['4.4.4.4', '5.5.5.5', '6.6.6.6']},
'Compute': {
'ctlplane': ['7.7.7.7', '8.8.8.8', '9.9.9.9'],
'external': ['10.10.10.10', '11.11.11.11', '12.12.12.12']},
}
ips = deployment.get_overcloud_hosts(stack, 'ctlplane')
expected = ['1.1.1.1', '2.2.2.2', '3.3.3.3',
'7.7.7.7', '8.8.8.8', '9.9.9.9']
self.assertEqual(sorted(expected), sorted(ips))
ips = deployment.get_overcloud_hosts(stack, 'external')
expected = ['4.4.4.4', '5.5.5.5', '6.6.6.6',
'10.10.10.10', '11.11.11.11', '12.12.12.12']
self.assertEqual(sorted(expected), sorted(ips))

View File

@@ -378,6 +378,12 @@ def get_role_net_hostname_map(stack):
return output['output_value']
def get_role_net_ip_map(stack):
for output in stack.to_dict().get('outputs', {}):
if output['output_key'] == 'RoleNetIpMap':
return output['output_value']
def get_hosts_entry(stack):
for output in stack.to_dict().get('outputs', {}):
if output['output_key'] == 'HostsEntry':

View File

@@ -636,6 +636,11 @@ class DeployOvercloud(command.Command):
os.path.expanduser('~'), '.ssh', 'id_rsa'),
help=_('Key path for ssh access to overcloud nodes.')
)
parser.add_argument(
'--overcloud-ssh-network',
help=_('Network name to use for ssh access to overcloud nodes.'),
default='ctlplane'
)
parser.add_argument(
'--environment-file', '-e', metavar='<HEAT ENVIRONMENT FILE>',
action='append', dest='environment_files',
@@ -918,7 +923,8 @@ class DeployOvercloud(command.Command):
if parsed_args.config_download:
print("Deploying overcloud configuration")
hosts = deployment.get_overcloud_hosts(self.clients, stack)
hosts = deployment.get_overcloud_hosts(
stack, parsed_args.overcloud_ssh_network)
deployment.enable_ssh_admin(self.log, self.clients,
hosts,
parsed_args.overcloud_ssh_user,
@@ -927,6 +933,7 @@ class DeployOvercloud(command.Command):
parsed_args.templates,
parsed_args.overcloud_ssh_user,
parsed_args.overcloud_ssh_key,
parsed_args.overcloud_ssh_network,
parsed_args.output_dir,
verbosity=self.app_args.verbose_level)

View File

@@ -13,7 +13,6 @@ from __future__ import print_function
import os
import pprint
import re
import shutil
import socket
import subprocess
@@ -112,21 +111,13 @@ def overcloudrc(workflow_client, **input_):
**input_)
def get_overcloud_hosts(clients, stack):
role_net_hostname_map = utils.get_role_net_hostname_map(stack)
hostnames = []
for role in role_net_hostname_map:
hostnames.extend(role_net_hostname_map[role].get('ctlplane', []))
def get_overcloud_hosts(stack, ssh_network):
ips = []
role_net_ip_map = utils.get_role_net_ip_map(stack)
for net_ip_map in role_net_ip_map.values():
ips.extend(net_ip_map.get(ssh_network, []))
hosts = []
hosts_entry = utils.get_hosts_entry(stack)
for hostname in hostnames:
for line in hosts_entry.split('\n'):
match = re.search('\s*%s\s*' % hostname, line)
if match:
hosts.append(line.split(' ')[0])
return hosts
return ips
def wait_for_ssh_port(host):
@@ -234,13 +225,14 @@ def enable_ssh_admin(log, clients, hosts, ssh_user, ssh_key):
def config_download(log, clients, stack, templates,
ssh_user, ssh_key, output_dir, verbosity=1):
ssh_user, ssh_key, ssh_network, output_dir, verbosity=1):
workflow_client = clients.workflow_engine
tripleoclients = clients.tripleoclient
workflow_input = {
'verbosity': verbosity or 1,
'plan_name': stack.stack_name
'plan_name': stack.stack_name,
'ssh_network': ssh_network
}
if output_dir:
workflow_input.update(dict(work_dir=output_dir))