浏览代码

Quote output values for overcloudrc

If the overcloudrc values have spaces, we need to quote them to ensure
it gets parsed correctly.

Change-Id: I06995dee0ec7eabda16793aa42cae7197c4959f5
Closes-Bug: #1854868
(cherry picked from commit 5d44457ae1)
changes/84/697484/1
Alex Schultz 4 个月前
父节点
当前提交
e6938afd5c
共有 2 个文件被更改,包括 10 次插入2 次删除
  1. +3
    -1
      tripleo_common/tests/utils/test_overcloudrc.py
  2. +7
    -1
      tripleo_common/utils/overcloudrc.py

+ 3
- 1
tripleo_common/tests/utils/test_overcloudrc.py 查看文件

@@ -34,9 +34,11 @@ class OvercloudRcTest(base.TestCase):
]
}

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

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


+ 7
- 1
tripleo_common/utils/overcloudrc.py 查看文件

@@ -18,6 +18,11 @@ from six.moves import urllib

from tripleo_common import constants

try: # py3
from shlex import quote
except ImportError: # py2
from pipes import quote


def get_service_ips(stack):
service_ips = {}
@@ -109,7 +114,8 @@ def create_overcloudrc(stack, no_proxy, admin_password, region_name):

overcloudrc = CLEAR_ENV
for key, value in rc_params.items():
line = "export %(key)s=%(value)s\n" % {'key': key, 'value': value}
line = "export %(key)s=%(value)s\n" % {'key': key,
'value': quote(value)}
overcloudrc = overcloudrc + line
overcloudrc = overcloudrc + CLOUDPROMPT



正在加载...
取消
保存