| |
@@ -107,8 +107,8 @@
|
| |
path = str(path) if path is not None else None
|
| |
drive_file = tempfile.NamedTemporaryFile(dir=path)
|
| |
drive_file.truncate(size)
|
| |
- cls._tempfiles.append({'file': drive_file, 'path': path})
|
| |
- logger.info("Created temporary sparse file '%s'." % drive_file.name)
|
| |
+ cls._tempfiles.append(drive_file)
|
| |
+ logger.info("Created temporary sparse file '%s'.", drive_file.name)
|
| |
# translate data into qemu command options
|
| |
result += ["-drive", "file=%s,media=disk,if=virtio" % drive_file.name]
|
| |
atexit.register(cls.cleanup)
|
| |
@@ -118,11 +118,11 @@
|
| |
def cleanup(cls):
|
| |
"""Close all temporary files created by this class
|
| |
"""
|
| |
- for tempfile in cls._tempfiles:
|
| |
- fullname = os.path.join(tempfile['path'], tempfile['file'].name)
|
| |
- logger.info("Closing and removing temporary sparse file '%s'" % fullname)
|
| |
+ for drive_file in cls._tempfiles:
|
| |
+ fullname = drive_file.name
|
| |
+ logger.info("Closing and removing temporary sparse file '%s'", fullname)
|
| |
if os.path.isfile(fullname):
|
| |
- tempfile['file'].close()
|
| |
+ drive_file.close()
|
| |
|
| |
|
| |
def print_bad_inventory():
|
| |
Seems good, name will be absolute path, because of :