# XXX Hack for planetflow
if slicesinconf.has_key("root"): _writeconf = False
else: _writeconf = True
# Parse attributes and update dict of scripts
# XXX Hack for planetflow
if slicesinconf.has_key("root"): _writeconf = False
else: _writeconf = True
# Parse attributes and update dict of scripts
for sliver in data['slivers']:
for attribute in sliver['attributes']:
if attribute['tagname'] == 'codemux':
# add to conf. Attribute is [host, port]
for sliver in data['slivers']:
for attribute in sliver['attributes']:
if attribute['tagname'] == 'codemux':
# add to conf. Attribute is [host, port]
- params = {'host': attribute['value'].split(",")[0],
- 'port': attribute['value'].split(",")[1]}
+ parts = attribute['value'].split(",")
+ if len(parts)<2:
+ logger.log("codemux: attribute value (%s) for codemux not separated by comma. Skipping."%attribute['value'])
+ continue
+ if len(parts) == 3:
+ ip = parts[2]
+ else:
+ ip = ""
+ params = {'host': parts[0], 'port': parts[1], 'ip': ip}
+
# Check if new or needs updating
if (sliver['name'] not in slicesinconf.keys()) \
or (params not in slicesinconf.get(sliver['name'], [])):
# Check if new or needs updating
if (sliver['name'] not in slicesinconf.keys()) \
or (params not in slicesinconf.get(sliver['name'], [])):
'''Write conf with default entry up top. Elements in [] should have lower order domain names first. Restart service.'''
f = open(conf, "w")
# This needs to be the first entry...
'''Write conf with default entry up top. Elements in [] should have lower order domain names first. Restart service.'''
f = open(conf, "w")
# This needs to be the first entry...
logger.log("codemux: Can't find PLC_CONFIG_HOST in config. Using PLC_API_HOST")
f.write("* root 1080 %s\n" % Config().PLC_API_HOST)
# Sort items for like domains
for mapping in slivers:
for (host, params) in mapping.iteritems():
if params['slice'] == "root": continue
logger.log("codemux: Can't find PLC_CONFIG_HOST in config. Using PLC_API_HOST")
f.write("* root 1080 %s\n" % Config().PLC_API_HOST)
# Sort items for like domains
for mapping in slivers:
for (host, params) in mapping.iteritems():
if params['slice'] == "root": continue
- f.write("%s %s %s\n" % (host, params['slice'], params['port']))
+ f.write("%s %s %s %s\n" % (host, params['slice'], params['port'], params['ip']))
dnames = {} # {host: slice}
for (slice, params) in slivers.iteritems():
for mapping in params:
dnames = {} # {host: slice}
for (slice, params) in slivers.iteritems():
for mapping in params:
def parseConf(conf = CODEMUXCONF):
'''Parse the CODEMUXCONF and return dict of slices in conf. {slice: (host,port)}'''
slicesinconf = {} # default
def parseConf(conf = CODEMUXCONF):
'''Parse the CODEMUXCONF and return dict of slices in conf. {slice: (host,port)}'''
slicesinconf = {} # default
slicesinconf.setdefault(slice, [])
slicesinconf[slice].append({"host": host, "port": port})
f.close()
slicesinconf.setdefault(slice, [])
slicesinconf[slice].append({"host": host, "port": port})
f.close()
- logger.log_call("/etc/init.d/codemux", "start")
+ logger.log_call(["/etc/init.d/codemux", "start", ])
+ logger.log_call(["/sbin/chkconfig", "codemux", "on"])
- logger.log_call("/etc/init.d/codemux", "stop")
+ logger.log_call(["/etc/init.d/codemux", "stop", ])
+ logger.log_call(["/sbin/chkconfig", "codemux", "off"])
+