fix multiple links
@@ -261,7 +261,6 @@ class PluginHelper:
tool_d[c_name] = {'image': image_name,
'name': c_name}
- self.logger.info('C_NAMES: {0}'.format(c_name))
# get rid of all commented sections in various runtime
# configurations
manifest = Template(self.manifest)
@@ -495,6 +494,7 @@ class PluginHelper:
'type',
'version']
vent_config = Template(template=self.path_dirs.cfg_file)
+ manifest = Template(self.manifest)
files = vent_config.option('main', 'files')
files = (files[0], expanduser(files[1]))
s, _ = self.constraint_options(args, options)
@@ -507,12 +507,25 @@ class PluginHelper:
# look out for links to delete because they're defined externally
links_to_delete = set()
+
+ # get instances for each tool
+ tool_instances = {}
+ sections = manifest.sections()[1]
+ for section in sections:
+ settings = manifest.option(section, 'settings')
+ if settings[0]:
+ settings = json.loads(settings[1])
+ if 'instances' in settings:
+ l_name = manifest.option(section, 'link_name')
+ if l_name[0]:
+ tool_instances[l_name[1]] = int(settings['instances'])
+
# check and update links, volumes_from, network_mode
for container in list(tool_d.keys()):
if 'labels' not in tool_d[container] or 'vent.groups' not in tool_d[container]['labels'] or 'core' not in tool_d[container]['labels']['vent.groups']:
tool_d[container]['remove'] = True
if 'links' in tool_d[container]:
- for link in tool_d[container]['links']:
+ for link in list(tool_d[container]['links'].keys()):
# add links to external services already running if
# necessary, by default configure local services too
configure_local = True
@@ -550,12 +563,13 @@ class PluginHelper:
status = False
if configure_local:
for c in list(tool_d.keys()):
- self.logger.info('WHAT: containers: {0} | {1} | {2} | {3}'.format(
- c, link, tool_d[c], tool_d[container]['links']))
if ('tmp_name' in tool_d[c] and
tool_d[c]['tmp_name'] == link):
tool_d[container]['links'][tool_d[c]['name']
] = tool_d[container]['links'].pop(link)
+ if link in tool_instances and tool_instances[link] > 1:
+ for i in range(2, tool_instances[link] + 1):
+ tool_d[container]['links'][tool_d[c]['name'] + str(i)] = tool_d[container]['links'][tool_d[c]['name']] + str(i)
if 'volumes_from' in tool_d[container]:
tmp_volumes_from = tool_d[container]['volumes_from']
tool_d[container]['volumes_from'] = []
