diff --git a/dockerfiles/heat-container-agent/scripts/55-heat-config b/dockerfiles/heat-container-agent/scripts/55-heat-config index 9cc0df15c5..4dd96b448e 100755 --- a/dockerfiles/heat-container-agent/scripts/55-heat-config +++ b/dockerfiles/heat-container-agent/scripts/55-heat-config @@ -18,6 +18,7 @@ import os import shutil import stat import subprocess +import six import sys import requests @@ -93,7 +94,7 @@ def invoke_hook(c, log): hot_inputs = c.get('inputs', []) for hot_input in hot_inputs: if hot_input.get('type', None) == 'String' and \ - not isinstance(hot_input['value'], basestring): + not isinstance(hot_input['value'], six.string_types): hot_input['value'] = str(hot_input['value']) iv = dict((i['name'], i['value']) for i in c['inputs']) # The group property indicates whether it is softwarecomponent or @@ -145,7 +146,8 @@ def invoke_hook(c, log): stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = subproc.communicate(input=json.dumps(c)) + stdout, stderr = subproc.communicate( + input=json.dumps(c).encode('utf-8', 'replace')) log.info(stdout) log.debug(stderr) @@ -158,7 +160,7 @@ def invoke_hook(c, log): try: if stdout: - signal_data = json.loads(stdout) + signal_data = json.loads(stdout.decode('utf-8', 'replace')) except ValueError: signal_data = { 'deploy_stdout': stdout, @@ -178,7 +180,8 @@ def invoke_hook(c, log): stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = subproc.communicate(input=json.dumps(signal_data)) + stdout, stderr = subproc.communicate( + input=json.dumps(signal_data).encode('utf-8', 'replace')) log.info(stdout) diff --git a/dockerfiles/heat-container-agent/scripts/heat-config-notify b/dockerfiles/heat-container-agent/scripts/heat-config-notify index f26a6ced22..9eb5c7509a 100755 --- a/dockerfiles/heat-container-agent/scripts/heat-config-notify +++ b/dockerfiles/heat-container-agent/scripts/heat-config-notify @@ -58,7 +58,7 @@ def trim_response(response, trimmed_values=None): """ trimmed_values = trimmed_values or ('deploy_stdout', 'deploy_stderr') - str_response = json.dumps(response, ensure_ascii=True, encoding='utf-8') + str_response = json.dumps(response, ensure_ascii=True) len_total = len(str_response) offset = MAX_RESPONSE_SIZE - len_total if offset >= 0: diff --git a/dockerfiles/heat-container-agent/scripts/hooks/atomic b/dockerfiles/heat-container-agent/scripts/hooks/atomic index bba5e4f3f0..46aac9e712 100755 --- a/dockerfiles/heat-container-agent/scripts/hooks/atomic +++ b/dockerfiles/heat-container-agent/scripts/hooks/atomic @@ -30,8 +30,8 @@ def prepare_dir(path): def build_response(deploy_stdout, deploy_stderr, deploy_status_code): return { - 'deploy_stdout': deploy_stdout, - 'deploy_stderr': deploy_stderr, + 'deploy_stdout': deploy_stdout.decode('utf-8', 'replace'), + 'deploy_stderr': deploy_stderr.decode('utf-8', 'replace'), 'deploy_status_code': deploy_status_code, } diff --git a/dockerfiles/heat-container-agent/scripts/hooks/docker-compose b/dockerfiles/heat-container-agent/scripts/hooks/docker-compose index 41219efb16..2577507712 100755 --- a/dockerfiles/heat-container-agent/scripts/hooks/docker-compose +++ b/dockerfiles/heat-container-agent/scripts/hooks/docker-compose @@ -38,13 +38,13 @@ def write_input_file(file_path, content): prepare_dir(os.path.dirname(file_path)) with os.fdopen(os.open( file_path, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f: - f.write(content.encode('utf-8')) + f.write(content) def build_response(deploy_stdout, deploy_stderr, deploy_status_code): return { - 'deploy_stdout': deploy_stdout, - 'deploy_stderr': deploy_stderr, + 'deploy_stdout': deploy_stdout.decode('utf-8', 'replace'), + 'deploy_stderr': deploy_stderr.decode('utf-8', 'replace'), 'deploy_status_code': deploy_status_code, } diff --git a/dockerfiles/heat-container-agent/scripts/hooks/script b/dockerfiles/heat-container-agent/scripts/hooks/script index 5c9cb4dc00..5760619937 100755 --- a/dockerfiles/heat-container-agent/scripts/hooks/script +++ b/dockerfiles/heat-container-agent/scripts/hooks/script @@ -59,15 +59,15 @@ def main(argv=sys.argv): env['heat_outputs_path'] = heat_outputs_path with os.fdopen(os.open(fn, os.O_CREAT | os.O_WRONLY, 0o700), 'w') as f: - f.write(c.get('config', '').encode('utf-8')) + f.write(c.get('config', '')) log.debug('Running %s' % fn) subproc = subprocess.Popen([fn], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) stdout, stderr = subproc.communicate() - log.info(stdout) - log.debug(stderr) + log.info(stdout.decode('utf-8', 'replace')) + log.debug(stderr.decode('utf-8', 'replace')) if subproc.returncode: log.error("Error running %s. [%s]\n" % (fn, subproc.returncode)) @@ -85,8 +85,8 @@ def main(argv=sys.argv): pass response.update({ - 'deploy_stdout': stdout, - 'deploy_stderr': stderr, + 'deploy_stdout': stdout.decode('utf-8', 'replace'), + 'deploy_stderr': stderr.decode('utf-8', 'replace'), 'deploy_status_code': subproc.returncode, })