tests: Make sure the log directory exists

In the qemu_provision module, make sure the log directory exists
before trying to write to it.
This commit is contained in:
Stef Walter 2017-08-21 16:59:40 +02:00
parent d52199e26b
commit 3a53b78063

View File

@ -109,6 +109,14 @@ def main(argv):
"-output", cloudinit, userdata, metadata], stdout=null)
log = module.params.get("log") or os.devnull
artifacts = os.path.dirname(log)
# Make sure the log directory exists
try:
os.makedirs(artifacts)
except OSError as exc:
if exc.errno != errno.EEXIST or not os.path.isdir(artifacts):
raise
inventory = os.path.join(directory, "inventory")
with open(inventory, 'w') as f: