Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --docker-registry and --image-tag flags to generator #2160

Merged
merged 4 commits into from
Nov 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions python/topology/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _create_networks(self):

def _br_conf(self, topo_id, topo, base):
raw_entry = {
'image': 'scion_border',
'image': self._docker_image('border'),
'depends_on': [
'scion_disp_br_%s' % topo_id.file_fmt(),
],
Expand Down Expand Up @@ -143,9 +143,9 @@ def _br_conf(self, topo_id, topo, base):
self.dc_conf['services']['scion_%s' % k] = entry

def _cs_conf(self, topo_id, topo, base):
image = 'scion_cert_py' if self.args.cert_server == 'py' else 'scion_cert'
image = 'cert_py' if self.args.cert_server == 'py' else 'cert'
raw_entry = {
'image': image,
'image': self._docker_image(image),
'depends_on': [
self._sciond_name(topo_id),
'scion_disp_%s' % topo_id.file_fmt(),
Expand All @@ -172,7 +172,7 @@ def _cs_conf(self, topo_id, topo, base):

def _bs_conf(self, topo_id, topo, base):
raw_entry = {
'image': 'scion_beacon_py',
'image': self._docker_image('beacon_py'),
'depends_on': [
self._sciond_name(topo_id),
'scion_disp_%s' % topo_id.file_fmt(),
Expand All @@ -199,9 +199,9 @@ def _bs_conf(self, topo_id, topo, base):
self.dc_conf['services']['scion_%s' % k] = entry

def _ps_conf(self, topo_id, topo, base):
image = 'scion_path_py' if self.args.path_server == 'py' else 'scion_path'
image = 'path_py' if self.args.path_server == 'py' else 'path'
raw_entry = {
'image': image,
'image': self._docker_image(image),
'depends_on': [
self._sciond_name(topo_id),
'scion_disp_%s' % topo_id.file_fmt(),
Expand Down Expand Up @@ -256,7 +256,7 @@ def _zookeeper_conf(self):
def _dispatcher_conf(self, topo_id, topo, base):
# Create dispatcher config
entry = {
'image': 'scion_dispatcher',
'image': self._docker_image('dispatcher'),
'environment': {
'SU_EXEC_USERSPEC': self.user_spec,
},
Expand Down Expand Up @@ -302,9 +302,9 @@ def _infra_dispatcher(self, entry, topo_id):

def _sciond_conf(self, topo_id, base):
name = self._sciond_name(topo_id)
image = 'scion_sciond_py' if self.args.sciond == 'py' else 'scion_sciond'
image = 'sciond_py' if self.args.sciond == 'py' else 'sciond'
entry = {
'image': image,
'image': self._docker_image(image),
'container_name': '%ssd%s' % (self.prefix, topo_id.file_fmt()),
'depends_on': [
'scion_disp_%s' % topo_id.file_fmt()
Expand Down Expand Up @@ -353,3 +353,12 @@ def _std_vol(self, topo_id):
self._cache_vol(),
self._logs_vol()
]

def _docker_image(self, image):
if self.args.docker_registry:
image = '%s/%s' % (self.args.docker_registry, image)
else:
image = 'scion_%s' % image
if self.args.image_tag:
image = '%s:%s' % (image, self.args.image_tag)
return image
9 changes: 8 additions & 1 deletion python/topology/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,17 @@ def _utils_conf(self):
self.dc_conf['services']['utils_cleaner'] = entry_clean

def _test_conf(self, topo_id):
image = 'app_builder'
if self.args.docker_registry:
image = '%s/%s' % (self.args.docker_registry, image)
else:
image = 'scion_%s' % image
if self.args.image_tag:
image = '%s:%s' % (image, self.args.image_tag)
docker = 'docker_' if self.args.in_docker else ''
cntr_base = '/home/scion/go/src/github.com/scionproto/scion'
entry = {
'image': 'scion_app_builder',
'image': image,
'volumes': [
'vol_scion_%sdisp_%s:/run/shm/dispatcher:rw' % (docker, topo_id.file_fmt()),
'vol_scion_%ssciond_%s:/run/shm/sciond:rw' % (docker, topo_id.file_fmt()),
Expand Down
2 changes: 2 additions & 0 deletions python/topology/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def add_arguments(parser):
help='Generate random IFIDs')
parser.add_argument('--in-docker', action='store_true',
help='Set if running in a docker container')
parser.add_argument('--docker-registry', help='Specify docker registry to pull images from')
parser.add_argument('--image-tag', help='Docker image tag')
return parser


Expand Down