Merge "Add work-dir command-line option"
This commit is contained in:
commit
d571f83939
@ -217,6 +217,8 @@ _CLI_OPTS = [
|
||||
cfg.StrOpt('logs-dir', help='Path to logs directory'),
|
||||
cfg.BoolOpt('pull', default=True,
|
||||
help='Attempt to pull a newer version of the base image.'),
|
||||
cfg.StrOpt('work-dir', help='Path to be used as working directory.'
|
||||
'By default, a temporary dir is created.'),
|
||||
]
|
||||
|
||||
_BASE_OPTS = [
|
||||
|
@ -633,10 +633,14 @@ class KollaWorker(object):
|
||||
|
||||
def setup_working_dir(self):
|
||||
"""Creates a working directory for use while building"""
|
||||
ts = time.time()
|
||||
ts = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d_%H-%M-%S_')
|
||||
self.temp_dir = tempfile.mkdtemp(prefix='kolla-' + ts)
|
||||
self.working_dir = os.path.join(self.temp_dir, 'docker')
|
||||
if self.conf.work_dir:
|
||||
self.working_dir = os.path.join(self.conf.work_dir, 'docker')
|
||||
else:
|
||||
ts = time.time()
|
||||
ts = datetime.datetime.fromtimestamp(ts).strftime(
|
||||
'%Y-%m-%d_%H-%M-%S_')
|
||||
self.temp_dir = tempfile.mkdtemp(prefix='kolla-' + ts)
|
||||
self.working_dir = os.path.join(self.temp_dir, 'docker')
|
||||
shutil.copytree(self.images_dir, self.working_dir)
|
||||
self.copy_apt_files()
|
||||
LOG.debug('Created working dir: %s', self.working_dir)
|
||||
@ -754,7 +758,8 @@ class KollaWorker(object):
|
||||
|
||||
def cleanup(self):
|
||||
"""Remove temp files"""
|
||||
shutil.rmtree(self.temp_dir)
|
||||
if not self.conf.work_dir:
|
||||
shutil.rmtree(self.temp_dir)
|
||||
|
||||
def filter_images(self):
|
||||
"""Filter which images to build"""
|
||||
|
@ -349,6 +349,13 @@ class KollaWorkerTest(base.TestCase):
|
||||
results = kolla.summary()
|
||||
self.assertEqual(None, results['failed'][0]['status'])
|
||||
|
||||
@mock.patch('shutil.copytree')
|
||||
def test_work_dir(self, copytree_mock):
|
||||
self.conf.set_override('work_dir', '/tmp/foo')
|
||||
kolla = build.KollaWorker(self.conf)
|
||||
kolla.setup_working_dir()
|
||||
self.assertEqual('/tmp/foo/docker', kolla.working_dir)
|
||||
|
||||
|
||||
class MainTest(base.TestCase):
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- A new work-dir command-line option has been added to
|
||||
the client, to allow the user to specify a directory
|
||||
to be used as working dir, instead of the default
|
||||
temp directory.
|
Loading…
Reference in New Issue
Block a user