[Python3] Adds bytes to str conversion management

On RHEL8 with Python3, the template's contents returned by the Swift
client get_object method is byte object and need to be converted into a
string.

Change-Id: Ia35abb66b9e61a7154406cf83c6da1e68a2f96b7
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
(cherry picked from commit f144be5bcc)
This commit is contained in:
Gael Chamoulaud 2019-05-13 15:50:25 +02:00
parent db89c5d3b0
commit 1027a4f54a

View File

@ -41,6 +41,11 @@ class LookupModule(LookupBase):
container = swift.get_container(variables['plan'])
for item in container[1]:
obj = swift.get_object(variables['plan'], item['name'])
try:
obj = (obj[0], obj[1].decode('utf-8'))
except AttributeError:
pass
if os.path.splitext(item['name'])[-1] not in EXCLUDED_EXT:
ret.append((item['name'], obj))