"""
-Configure interfaces inside a container by pulling down files via URL.
+Update /etc/hosts in slivers to contain the contents of the sliver_hostmap tag.
"""
import logger
hostname = data['hostname']
+ hostname_filter = ".".join(hostname.split(".")[1:])
+
for sliver in data['slivers']:
slicename = sliver['name']
for tag in sliver['attributes']:
for index, entry in enumerate(tag["value"].split("\n")):
parts = entry.split(" ")
if len(parts)==2:
- if parts[1] == hostname:
- line = "127.0.0.1 %s.%s private%d" % (slicename, parts[1], index)
- else:
- line = "%s %s.%s private%d" % (parts[0], slicename, parts[1], index)
+ line = "%s pvt.%s private%d" % (parts[0], parts[1], index)
+
+ if (parts[0].startswith("10.")) and (hostname_filter not in parts[1]):
+ continue
if (index==0):
line = line + " headnode"
+ if parts[1] == hostname:
+ line = line + " pvt.self"
+
hostmap.append(line)
hostmap = "\n".join(hostmap)
# remove anything between PREFIX and SUFFIX from contents
- pattern = PREFIX + ".*" + SUFFIX
+ pattern = PREFIX + ".*" + SUFFIX + "\n"
regex = re.compile(pattern, re.DOTALL)
if regex.search(contents) != None:
contents = regex.sub(hostmap, contents)
logger.log_exc("hostmap (%s): failed to write %s" % (slicename, fn))
-