Skip to content
Permalink
Browse files

fix(composer): fix composer router generation logic

  • Loading branch information...
hanxiao committed Aug 6, 2019
1 parent 23a83a4 commit e35e3b3c1385cd18f102143b8d56247313aa9bab
Showing with 15 additions and 13 deletions.
  1. +15 −13 gnes/composer/base.py
@@ -191,17 +191,17 @@ def build_dockerswarm(all_layers: List['YamlComposer.Layer'], docker_img: str =
args.append('--yaml_path /%s_yaml' % c_name)
config_dict['%s_yaml' % c_name] = {'file': c['yaml_path']}

# if l_idx + 1 < len(all_layers):
# next_layer = all_layers[l_idx + 1]
# _l_idx = l_idx + 1
# else:
# next_layer = all_layers[0]
# _l_idx = 0
# host_out_name = ''
# for _c_idx, _c in enumerate(next_layer.components):
# if _c['port_in'] == c['port_out']:
# host_out_name = '%s%d%d' % (_c['name'], _l_idx, _c_idx)
# break
if l_idx + 1 < len(all_layers):
next_layer = all_layers[l_idx + 1]
_l_idx = l_idx + 1
else:
next_layer = all_layers[0]
_l_idx = 0
host_out_name = ''
for _c_idx, _c in enumerate(next_layer.components):
if _c['port_in'] == c['port_out']:
host_out_name = '%s%d%d' % (_c['name'], _l_idx, _c_idx)
break

if l_idx - 1 >= 0:
last_layer = all_layers[l_idx - 1]
@@ -216,8 +216,10 @@ def build_dockerswarm(all_layers: List['YamlComposer.Layer'], docker_img: str =
host_in_name = '%s%d%d' % (_c['name'], _l_idx, _c_idx)
break

args += ['--host_in %s' % host_in_name]
# '--host_out %s' % host_out_name]
if 'BIND' not in c['socket_out']:
args.append('--host_out %s' % host_out_name)
if 'BIND' not in c['socket_in']:
args.append('--host_in %s' % host_in_name)

cmd = '%s %s' % (YamlComposer.comp2file[c['name']], ' '.join(args))
swarm_lines['services'][c_name] = CommentedMap({

0 comments on commit e35e3b3

Please sign in to comment.
You can’t perform that action at this time.