From 279594ab6456694de883f0a6873de65d41e0ca8f Mon Sep 17 00:00:00 2001 From: SamYaple Date: Thu, 18 Feb 2016 03:01:49 +0000 Subject: [PATCH] Add local directory or file for source build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change allows using a local directory or tarball to build from sources by specifying the 'local' type in your kolla-build.conf: [keystone-base] type=local location=/home/martin/src/keystone [neutron-server-plugin-networking-cisco] type=local location=/tmp/networking-cisco.tar.gz Closes-Bug: #1509625 Co-Authored-By: Martin André Change-Id: I3f6f68b0f44efdac653d186d2625591ad7cb3b2a --- kolla/cmd/build.py | 10 ++++++++++ kolla/common/config.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/kolla/cmd/build.py b/kolla/cmd/build.py index d21109647d..1bb8d80762 100755 --- a/kolla/cmd/build.py +++ b/kolla/cmd/build.py @@ -208,6 +208,16 @@ class WorkerThread(threading.Thread): with tarfile.open(dest_archive, 'w') as tar: tar.add(clone_dir, arcname=os.path.basename(clone_dir)) + elif source.get('type') == 'local': + LOG.debug("%s:Getting local archive from %s", image['name'], + source['source']) + if os.path.isdir(source['source']): + with tarfile.open(dest_archive, 'w') as tar: + tar.add(source['source'], + arcname=os.path.basename(source['source'])) + else: + shutil.copyfile(source['source'], dest_archive) + else: LOG.error("%s:Wrong source type '%s'", image['name'], source.get('type')) diff --git a/kolla/common/config.py b/kolla/common/config.py index 2eeb8c9ca5..3816230af0 100644 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -241,7 +241,7 @@ SOURCES = { def get_source_opts(type_=None, location=None, reference=None): - return [cfg.StrOpt('type', choices=['git', 'url'], + return [cfg.StrOpt('type', choices=['local', 'git', 'url'], default=type_, help='Source location type'), cfg.StrOpt('location', default=location,