Prevent utf-8 codec error in py3 (#44228)

Cannot upload templates in Python 3.x. Gives utf-8 codec error.
Fixes this by opening the template file in binary mode.
This commit is contained in:
Jose Rodriguez 2018-08-23 20:33:00 +02:00 committed by ansibot
parent aa07da21a3
commit 14e3febb2c

View file

@ -136,7 +136,7 @@ def get_template(proxmox, node, storage, content_type, template):
def upload_template(module, proxmox, api_host, node, storage, content_type, realpath, timeout):
taskid = proxmox.nodes(node).storage(storage).upload.post(content=content_type, filename=open(realpath))
taskid = proxmox.nodes(node).storage(storage).upload.post(content=content_type, filename=open(realpath, 'rb'))
while timeout:
task_status = proxmox.nodes(api_host.split('.')[0]).tasks(taskid).status.get()
if task_status['status'] == 'stopped' and task_status['exitstatus'] == 'OK':