Add --tmp to lorax-composer and set default tempdir

It was using /tmp/ which can fill up quickly when building images.
Default to /var/tmp unless the user passes --tmp /tmp/
This commit is contained in:
Brian C. Lane 2018-05-10 08:53:12 -07:00
parent 050f87168a
commit 3a38a57ae1

View File

@ -30,6 +30,7 @@ import os
import pwd import pwd
import sys import sys
import subprocess import subprocess
import tempfile
from threading import Lock from threading import Lock
from gevent import socket from gevent import socket
from gevent.wsgi import WSGIServer from gevent.wsgi import WSGIServer
@ -67,6 +68,8 @@ def get_parser():
help="Path to lorax-composer configuration file.") help="Path to lorax-composer configuration file.")
parser.add_argument( "--releasever", default=None, metavar="STRING", parser.add_argument( "--releasever", default=None, metavar="STRING",
help="Release version to use for $releasever in yum repository urls" ) help="Release version to use for $releasever in yum repository urls" )
parser.add_argument("--tmp", default="/var/tmp",
help="Top level temporary directory")
parser.add_argument("BLUEPRINTS", metavar="BLUEPRINTS", parser.add_argument("BLUEPRINTS", metavar="BLUEPRINTS",
help="Path to the blueprints") help="Path to the blueprints")
@ -155,6 +158,7 @@ if __name__ == '__main__':
print(VERSION) print(VERSION)
sys.exit(0) sys.exit(0)
tempfile.tempdir = opts.tmp
logpath = os.path.abspath(os.path.dirname(opts.logfile)) logpath = os.path.abspath(os.path.dirname(opts.logfile))
if not os.path.isdir(logpath): if not os.path.isdir(logpath):
os.makedirs(logpath) os.makedirs(logpath)