aboutsummaryrefslogtreecommitdiff
path: root/kolla
diff options
context:
space:
mode:
authorVladislav Belogrudov <vladislav.belogrudov@oracle.com>2015-09-02 17:36:46 +0300
committerVladislav Belogrudov <vladislav.belogrudov@oracle.com>2015-09-03 16:49:50 +0300
commitc22cf33268979db15f06f2bab347750127e5d7ee (patch)
treed591aa2e08b0b0443f4e37264465293025552067 /kolla
parent233864ff32af10a2c927cdbca3475b537c8e6808 (diff)
downloadkolla-c22cf33268979db15f06f2bab347750127e5d7ee.tar.gz
kolla-c22cf33268979db15f06f2bab347750127e5d7ee.zip
Allow arbitrary source archive name to be imported into Dockerfile
Currently we cannot import source archives with names different than expected by hardcoded line in Dockerfiles. This worked well for Openstack services' tarballs where we expected SERVICE-* root folder after extraction or kanaka-noVNC for nova-novncproxy docker. The latter fails if one tries to clone or get tarball under other names. This fix allows any archive (tar,tgz,zip) or repo name to be imported into dockerfile. Change-Id: I869a6a19afaf0e93925572746c22b7589b6600c9 Closes-Bug: #1491415
Diffstat (limited to 'kolla')
-rwxr-xr-xkolla/cmd/build.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/kolla/cmd/build.py b/kolla/cmd/build.py
index 17142b54b..437f19cc4 100755
--- a/kolla/cmd/build.py
+++ b/kolla/cmd/build.py
@@ -88,27 +88,25 @@ class WorkerThread(Thread):
def process_source(self, image):
source = image['source']
- dest_dir = image['path']
- dest_tar = os.path.join(dest_dir, image['name'] + '.tar')
+ dest_archive = os.path.join(image['path'], image['name'] + '-archive')
if source.get('type') == 'url':
- LOG.debug("{}:Getting tarball from {}".format(image['name'],
+ LOG.debug("{}:Getting archive from {}".format(image['name'],
source['source']))
r = requests.get(source['source'])
if r.status_code == 200:
- with open(dest_tar, 'wb') as f:
+ with open(dest_archive, 'wb') as f:
f.write(r.content)
else:
LOG.error(
- '{}:Failed to download tarball: status_code {}'.format(
+ '{}:Failed to download archive: status_code {}'.format(
image['name'], r.status_code))
image['status'] = "error"
return
elif source.get('type') == 'git':
- clone_dir = os.path.splitext(dest_tar)[0] + \
- '-' + source['reference']
+ clone_dir = dest_archive + '-' + source['reference']
try:
LOG.debug("{}:Cloning from {}".format(image['name'],
source['source']))
@@ -125,7 +123,7 @@ class WorkerThread(Thread):
image['status'] = "error"
return
- with tarfile.open(dest_tar, 'w') as tar:
+ with tarfile.open(dest_archive, 'w') as tar:
tar.add(clone_dir, arcname=os.path.basename(clone_dir))
else:
@@ -134,8 +132,8 @@ class WorkerThread(Thread):
image['status'] = "error"
return
- # Set time on destination tarball to epoch 0
- os.utime(dest_tar, (0, 0))
+ # Set time on destination archive to epoch 0
+ os.utime(dest_archive, (0, 0))
def builder(self, image):
LOG.debug('{}:Processing'.format(image['name']))