X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fcodemux.py;h=471f269b17d38a797edbd70a25441e45718d534a;hb=74a8cfb9d2eac39ae02e5323e1fb5b1d33297981;hp=b367b582342f80c27890305ea770ce2941f98d5d;hpb=544158b1b52bd18b9942b122ce804f59cc929e25;p=nodemanager.git diff --git a/plugins/codemux.py b/plugins/codemux.py index b367b58..471f269 100644 --- a/plugins/codemux.py +++ b/plugins/codemux.py @@ -12,9 +12,9 @@ from config import Config CODEMUXCONF="/etc/codemux/codemux.conf" def start(options, conf): - logger.log("codemux plugin starting up...") + logger.log("codemux: plugin starting up...") -def GetSlivers(plc, data, config): +def GetSlivers(data, config, plc = None): """ For each sliver with the codemux attribute, parse out "host,port" and make entry in conf. Restart service after. @@ -36,12 +36,18 @@ def GetSlivers(plc, data, config): else: _writeconf = True # Parse attributes and update dict of scripts + if 'slivers' not in data: + logger.log_missing_data("codemux.GetSlivers", 'slivers') + return 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 + params = {'host': parts[0], 'port': parts[1]} try: # Check to see if sliver is running. If not, continue if vserver.VServer(sliver['name']).is_running(): @@ -90,7 +96,7 @@ def writeConf(slivers, conf = CODEMUXCONF): f.truncate() f.close() try: restartService() - except: logger.log_exc() + except: logger.log_exc("codemux.writeConf failed to restart service") def sortDomains(slivers): @@ -126,7 +132,7 @@ def parseConf(conf = CODEMUXCONF): slicesinconf.setdefault(slice, []) slicesinconf[slice].append({"host": host, "port": port}) f.close() - except IOError: logger.log_exc() + except IOError: logger.log_exc("codemux.parseConf got IOError") return slicesinconf