Browse Source

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
tags/12.1.0
Alex Schultz 4 months ago
parent
commit
5d44457ae1
2 changed files with 10 additions and 2 deletions
  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 View File

@@ -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_IDENTITY_API_VERSION=3", result['overcloudrc'])
self.assertIn(overcloudrc.CLOUDPROMPT, result['overcloudrc'])


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

@@ -17,6 +17,11 @@ from six.moves import urllib
from tripleo_common import constants
from tripleo_common.utils import common as common_utils

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


def get_service_ips(stack):
service_ips = {}
@@ -98,7 +103,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



Loading…
Cancel
Save