Commit 3853b94e authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼 Committed by Thomas Gambier

slapgrid: fix _updateCertificate in python3

Traceback (most recent call last):
  File "/opt/slapos/eggs/slapos.core-1.7.10-py3.7.egg/slapos/grid/slapgrid.py", line 1435, in processComputerPartitionList
    self.processComputerPartition(computer_partition)
  File "/opt/slapos/eggs/slapos.core-1.7.10-py3.7.egg/slapos/grid/slapgrid.py", line 1329, in processComputerPartition
    raise e
  File "/opt/slapos/eggs/slapos.core-1.7.10-py3.7.egg/slapos/grid/slapgrid.py", line 1254, in processComputerPartition
    local_partition._updateCertificate()
  File "/opt/slapos/eggs/slapos.core-1.7.10-py3.7.egg/slapos/grid/SlapObject.py", line 513, in _updateCertificate
    fout.write(new_content)
TypeError: a bytes-like object is required, not 'str'

Also add test for the failure.
parent 23854306
...@@ -509,7 +509,7 @@ class Partition(object): ...@@ -509,7 +509,7 @@ class Partition(object):
else: else:
self.logger.info('Changed %s content. Updating %r' % (name, path)) self.logger.info('Changed %s content. Updating %r' % (name, path))
with os.fdopen(os.open(path, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o400), 'wb') as fout: with os.fdopen(os.open(path, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o400), 'w') as fout:
fout.write(new_content) fout.write(new_content)
os.chown(path, uid, gid) os.chown(path, uid, gid)
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment