add "registry" flag to "tools/build.py"

With registry flag,
build image using `tools/build.py --registry 172.22.2.81:4000`
the image name looks like `172.22.2.81:4000/kollaglue/data`
When user use kolla-ansible,
user set `docker_registry` to `172.22.2.81:4000` in `/etc/kolla/globals.yml`.

Build image using `tools/build.py -n abcd`
the image name looks like `abcd/data`
When user use kolla-ansible,
user set `docker_namespace:` to `abcd` in `/etc/kolla/globals.yml`.

build image using `tools/build.py -n abcd --registry 172.22.2.81:4000`
the image name looks like `abcd/data`
When user use kolla-ansible,
user set `docker_namespace:` to `abcd` in `/etc/kolla/globals.yml`.
user set `docker_registry` to `172.22.2.81:4000` in `/etc/kolla/globals.yml`.

With the feature, it will reduce user confusing and mistaking.

Change-Id: I18ac7a3ccec032888e35f5e9a79fc190760cc8a0
Closes-Bug: #1505056
(cherry picked from commit 52b7253811)
This commit is contained in:
Kuo-tung Kao 2015-10-14 16:19:45 +08:00 committed by Sam Yaple
parent d08795865c
commit 6e69e4673a
3 changed files with 13 additions and 3 deletions

View File

@ -37,7 +37,7 @@ The guide assumes that you have build images using the following command.
::
tools/build.py -n 172.22.2.81:4000/kollaglue --base ubuntu --type source --push
tools/build.py --registry 172.22.2.81:4000 --base ubuntu --type source --push
The IP, "172.22.2.81", is the host running private docker registry.
To deploy a private docker registry,

View File

@ -42,6 +42,8 @@
# Path to custome file to be addded at end of Dockerfiles for final images
#include_footer = /path/to/footer_file
# The registry host. The default registry host is Docker Hub.
#registry = None
# Provide location of sources for source install builds.
# Example:

View File

@ -225,7 +225,8 @@ def merge_args_and_config(settings_from_config_file):
"keep": False,
"push": False,
"threads": 8,
"retries": 3
"retries": 3,
"registry": None
}
defaults.update(settings_from_config_file.items('kolla-build'))
parser.set_defaults(**defaults)
@ -282,6 +283,9 @@ def merge_args_and_config(settings_from_config_file):
help=('Path to custom file to be added at '
'end of Dockerfiles for final images'),
type=str)
parser.add_argument('--registry',
help=("the docker registry host"),
type=str)
return vars(parser.parse_args())
@ -291,7 +295,11 @@ class KollaWorker(object):
self.base_dir = os.path.abspath(find_base_dir())
LOG.debug("Kolla base directory: " + self.base_dir)
self.images_dir = os.path.join(self.base_dir, 'docker')
self.namespace = config['namespace']
self.registry = config['registry']
if self.registry:
self.namespace = self.registry + '/' + config['namespace']
else:
self.namespace = config['namespace']
self.base = config['base']
self.base_tag = config['base_tag']
self.install_type = config['install_type']