git://git.onelab.eu
/
nodemanager.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Do we really need an exec trace for this expected state - not sure, please change...
[nodemanager.git]
/
plugins
/
codemux.py
diff --git
a/plugins/codemux.py
b/plugins/codemux.py
index
84b0f4e
..
14f2b4b
100644
(file)
--- a/
plugins/codemux.py
+++ b/
plugins/codemux.py
@@
-12,7
+12,7
@@
from config import Config
CODEMUXCONF="/etc/codemux/codemux.conf"
def start(options, conf):
CODEMUXCONF="/etc/codemux/codemux.conf"
def start(options, conf):
- logger.log("codemux plugin starting up...")
+ logger.log("codemux
:
plugin starting up...")
def GetSlivers(data, config, plc = None):
"""
def GetSlivers(data, config, plc = None):
"""
@@
-36,6
+36,9
@@
def GetSlivers(data, config, plc = None):
else: _writeconf = True
# Parse attributes and update dict of scripts
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':
for sliver in data['slivers']:
for attribute in sliver['attributes']:
if attribute['tagname'] == 'codemux':
@@
-44,7
+47,12
@@
def GetSlivers(data, config, plc = None):
if len(parts)<2:
logger.log("codemux: attribute value (%s) for codemux not separated by comma. Skipping."%attribute['value'])
continue
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]}
+ if len(parts) == 3:
+ ip = parts[2]
+ else:
+ ip = ""
+ params = {'host': parts[0], 'port': parts[1], 'ip': ip}
+
try:
# Check to see if sliver is running. If not, continue
if vserver.VServer(sliver['name']).is_running():
try:
# Check to see if sliver is running. If not, continue
if vserver.VServer(sliver['name']).is_running():
@@
-89,7
+97,7
@@
def writeConf(slivers, conf = CODEMUXCONF):
for mapping in slivers:
for (host, params) in mapping.iteritems():
if params['slice'] == "root": continue
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
']))
f.truncate()
f.close()
try: restartService()
f.truncate()
f.close()
try: restartService()
@@
-101,7
+109,7
@@
def sortDomains(slivers):
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:
- dnames[mapping['host']] = {"slice":slice, "port": mapping['port']}
+ dnames[mapping['host']] = {"slice":slice, "port": mapping['port']
, "ip": mapping['ip']
}
hosts = dnames.keys()
# sort by length
hosts.sort(key=str.__len__)
hosts = dnames.keys()
# sort by length
hosts.sort(key=str.__len__)
@@
-139,22
+147,25
@@
def isRunning():
else:
return False
else:
return False
-
def restartService():
def restartService():
+ if not os.path.exists("/etc/init.d/codemux"): return
logger.log("codemux: Restarting codemux service")
if isRunning():
logger.log("codemux: Restarting codemux service")
if isRunning():
- logger.log_call(
"/etc/init.d/codemux","condrestart"
)
+ logger.log_call(
["/etc/init.d/codemux","condrestart", ]
)
else:
else:
- logger.log_call("/etc/init.d/codemux","restart")
-
+ logger.log_call(["/etc/init.d/codemux","restart", ])
def startService():
def startService():
+ if not os.path.exists("/etc/init.d/codemux"): return
if not isRunning():
logger.log("codemux: Starting codemux service")
if not isRunning():
logger.log("codemux: Starting codemux service")
- logger.log_call("/etc/init.d/codemux", "start")
+ logger.log_call(["/etc/init.d/codemux", "start", ])
+ logger.log_call(["/sbin/chkconfig", "codemux", "on"])
def stopService():
def stopService():
+ if not os.path.exists("/etc/init.d/codemux"): return
if isRunning():
logger.log("codemux: Stopping codemux service")
if isRunning():
logger.log("codemux: Stopping codemux service")
- logger.log_call("/etc/init.d/codemux", "stop")
+ logger.log_call(["/etc/init.d/codemux", "stop", ])
+ logger.log_call(["/sbin/chkconfig", "codemux", "off"])