Browse Source

Prevent duplicated hosts in overcloudrc no_proxy

When an operator runs `source overcloudrc` then `source stackrc`,
ENV['no_proxy'] keep having overcloud information because stackrc
doesn't include no_proxy line.
If they runs deploy commands like overcloud deploy with that situation,
the command is executed with ENV['no_proxy'] including overcloud hosts.
This generates overcloudrc with duplicated host in no_proxy line,
because no_proxy in overcloudrc is generated by joining ENV['no_proxy']
and rquired overcloud hosts.

This patch makes sure that duplicated hosts are removed before they get
dumped into no_proxy parameter.

Change-Id: I94934ae7631100d20a9e2e72e348f26bd595a3c5
Closes-Bug: #1870017
(cherry picked from commit 4ae8eb070e)
changes/41/731341/1
Takashi Kajinami 3 months ago
committed by Emilien Macchi
parent
commit
7901b1fe85
2 changed files with 36 additions and 2 deletions
  1. +31
    -1
      tripleo_common/tests/utils/test_overcloudrc.py
  2. +5
    -1
      tripleo_common/utils/overcloudrc.py

+ 31
- 1
tripleo_common/tests/utils/test_overcloudrc.py View File

@@ -37,7 +37,37 @@ class OvercloudRcTest(base.TestCase):
result = overcloudrc.create_overcloudrc(stack, "foo", "AdminPassword",
"regionTwo")

self.assertIn("export no_proxy='foo,foo.com,[fd00::1]'",
self.assertIn("export no_proxy='[fd00::1],foo,foo.com'",
result['overcloudrc'])
self.assertIn("OS_PASSWORD=AdminPassword", result['overcloudrc'])

self.assertIn("export PYTHONWARNINGS='ignore:Certificate",
result['overcloudrc'])
self.assertIn("OS_IDENTITY_API_VERSION=3", result['overcloudrc'])
self.assertIn(overcloudrc.CLOUDPROMPT, result['overcloudrc'])
self.assertIn("OS_AUTH_TYPE=password", result['overcloudrc'])
self.assertIn("OS_AUTH_URL=http://foo.com:8000/",
result['overcloudrc'])
self.assertIn("OS_REGION_NAME=regionTwo",
result['overcloudrc'])

def test_generate_overcloudrc_with_duplicated_no_proxy(self):

stack = mock.MagicMock()
stack.stack_name = 'overcast'
stack.to_dict.return_value = {
"outputs": [
{'output_key': 'KeystoneURL',
'output_value': 'http://foo.com:8000/'},
{'output_key': 'EndpointMap',
'output_value': {'KeystoneAdmin': {'host': 'fd00::1'}}},
]
}

result = overcloudrc.create_overcloudrc(
stack, "foo,foo.com", "AdminPassword", "regionTwo")

self.assertIn("export no_proxy='[fd00::1],foo,foo.com'",
result['overcloudrc'])
self.assertIn("OS_PASSWORD=AdminPassword", result['overcloudrc'])
self.assertIn("OS_PASSWORD=AdminPassword", result['overcloudrc.v3'])


+ 5
- 1
tripleo_common/utils/overcloudrc.py View File

@@ -88,8 +88,12 @@ def create_overcloudrc(stack, no_proxy, admin_password, region_name):
overcloud_host = urllib.parse.urlparse(overcloud_endpoint).hostname
overcloud_admin_vip = get_endpoint('KeystoneAdmin', stack)

no_proxy_list = no_proxy.split(',')
no_proxy_list = map(bracket_ipv6,
[no_proxy, overcloud_host, overcloud_admin_vip])
no_proxy_list + [overcloud_host, overcloud_admin_vip])

# Remove duplicated entries
no_proxy_list = sorted(list(set(no_proxy_list)))

rc_params = {
'NOVA_VERSION': '1.1',


Loading…
Cancel
Save