summaryrefslogtreecommitdiff
path: root/tools/build.py
diff options
context:
space:
mode:
authorMichal Jastrzebski (inc0) <michal.jastrzebski@intel.com>2015-08-24 13:31:26 +0200
committerMichal Jastrzebski (inc0) <michal.jastrzebski@intel.com>2015-08-24 13:33:18 +0000
commit48c0ecf54642167495a7fd7df099fc497987aadc (patch)
treee1351f08a6255f2aacbb8c34ce698371fce2c7a6 /tools/build.py
parent44aa4af5f538df3a7656dbf2232e5ed882b7993b (diff)
downloadkolla-48c0ecf54642167495a7fd7df099fc497987aadc.tar.gz
kolla-48c0ecf54642167495a7fd7df099fc497987aadc.zip
Build.py regex filtering
Adds option to build.py to only build images matching and its dependencies Change-Id: I281bea5bed932b7c948b247392fa6a52b1d1aecf
Diffstat (limited to 'tools/build.py')
-rwxr-xr-xtools/build.py38
1 files changed, 34 insertions, 4 deletions
diff --git a/tools/build.py b/tools/build.py
index 8ece0d63c..4f571c790 100755
--- a/tools/build.py
+++ b/tools/build.py
@@ -22,6 +22,7 @@ import json
import logging
import os
import Queue
+import re
import requests
import shutil
import signal
@@ -125,6 +126,10 @@ class WorkerThread(Thread):
def argParser():
parser = argparse.ArgumentParser(description='Kolla build script')
+ parser.add_argument('regex',
+ help=('Build only images matching '
+ 'regex and its dependencies'),
+ nargs='*')
parser.add_argument('-n', '--namespace',
help='Set the Docker namespace name',
type=str,
@@ -197,9 +202,11 @@ class KollaWorker(object):
self.config = ConfigParser.SafeConfigParser()
self.config.read(os.path.join(sys.path[0], '..', 'build.ini'))
self.include_header = args['include_header']
+ self.regex = args['regex']
self.image_statuses_bad = {}
self.image_statuses_good = {}
+ self.image_statuses_unproc = {}
def setupWorkingDir(self):
"""Creates a working directory for use while building"""
@@ -262,7 +269,23 @@ class KollaWorker(object):
def sortImages(self):
"""Build images dependency tiers"""
- images_to_process = list(self.images)
+ if self.regex:
+ patterns = re.compile(r'({})'.format("|".join(self.regex)))
+ images_to_process = list()
+ for image in self.images:
+ if re.search(patterns, image['fullname']):
+ images_to_process.append(image)
+ added = True
+ while added:
+ added = False
+ parents = [p['parent'] for p in images_to_process]
+ for image in self.images:
+ if (image['fullname'] in parents and
+ image not in images_to_process):
+ images_to_process.append(image)
+ added = True
+ else:
+ images_to_process = self.images
self.tiers = list()
while images_to_process:
@@ -303,13 +326,18 @@ class KollaWorker(object):
LOG.info("Successfully built images")
LOG.info("=========================")
for name in self.image_statuses_good.keys():
- LOG.info(name)
+ LOG.info(name)
LOG.info("Images that failed to build")
LOG.info("===========================")
for name, status in self.image_statuses_bad.iteritems():
- LOG.error('{}\r\t\t\t Failed with status: {}'.format(
- name, status))
+ LOG.error('{}\r\t\t\t Failed with status: {}'.format(
+ name, status))
+
+ LOG.debug("Not processed images")
+ LOG.debug("=========================")
+ for name in self.image_statuses_unproc.keys():
+ LOG.debug(name)
def get_image_statuses(self):
if len(self.image_statuses_bad) or len(self.image_statuses_good):
@@ -317,6 +345,8 @@ class KollaWorker(object):
for image in self.images:
if image['status'] == "built":
self.image_statuses_good[image['name']] = image['status']
+ elif image['status'] == "unprocessed":
+ self.image_statuses_unproc[image['name']] = image['status']
else:
self.image_statuses_bad[image['name']] = image['status']
return (self.image_statuses_bad, self.image_statuses_good)