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
This commit is contained in:
parent
560a870bfc
commit
4ae8eb070e
|
@ -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'])
|
||||
|
||||
|
|
|
@ -76,8 +76,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(common_utils.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 = {
|
||||
'OS_USERNAME': 'admin',
|
||||
|
|
Loading…
Reference in New Issue