Skip to content

Commit

Permalink
fixed usage of NamedTemporaryFile with Python 3 in testsuite
Browse files Browse the repository at this point in the history
The Ganeti QA testsuite makes use of NamedTemporaryFile in several
places. With Python 3, the i/o mode needs to be either binary (default)
or string. The QA testsuite only needs string modes so the code
was fixed accordingly.

Signed-off-by: Rudolph Bott <bott@sipgate.de>
  • Loading branch information
rbott authored and apoikos committed Dec 14, 2019
1 parent 96dedcc commit 296f1dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions qa/qa_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ def TestClusterRenewCrypto():
pathutils.RAPI_CERT_FILE)
try:
# Custom RAPI certificate
fh = tempfile.NamedTemporaryFile()
fh = tempfile.NamedTemporaryFile(mode="w")

# Ensure certificate doesn't cause "gnt-cluster verify" to complain
validity = constants.SSL_CERT_EXPIRATION_WARN * 3
Expand Down Expand Up @@ -1528,7 +1528,7 @@ def TestClusterCopyfile():
uniqueid = utils.NewUUID()

# Create temporary file
f = tempfile.NamedTemporaryFile()
f = tempfile.NamedTemporaryFile(mode="w")
f.write(uniqueid)
f.flush()
f.seek(0)
Expand Down
6 changes: 3 additions & 3 deletions qa/qa_rapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def ReloadCertificates(ensure_presence=True):
qa_utils.MakeNodePath(master, pathutils.RAPI_CERT_FILE)]

# Write to temporary file
_rapi_ca = tempfile.NamedTemporaryFile()
_rapi_ca = tempfile.NamedTemporaryFile(mode="w")
_rapi_ca.write(qa_utils.GetCommandOutput(master.primary,
utils.ShellQuoteArgs(cmd)))
_rapi_ca.flush()
Expand Down Expand Up @@ -181,7 +181,7 @@ def _CreateRapiUser(rapi_user):
rapi_users_path = qa_utils.MakeNodePath(master, pathutils.RAPI_USERS_FILE)
rapi_dir = os.path.dirname(rapi_users_path)

fh = tempfile.NamedTemporaryFile()
fh = tempfile.NamedTemporaryFile(mode="w")
try:
fh.write("%s %s write\n" % (rapi_user, rapi_secret))
fh.flush()
Expand Down Expand Up @@ -1222,7 +1222,7 @@ def TestInterClusterInstanceMove(src_instance, dest_instance,
"""Test tools/move-instance"""
master = qa_config.GetMasterNode()

rapi_pw_file = tempfile.NamedTemporaryFile()
rapi_pw_file = tempfile.NamedTemporaryFile(mode="w")
rapi_pw_file.write(_rapi_password)
rapi_pw_file.flush()

Expand Down

0 comments on commit 296f1dc

Please sign in to comment.