X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=nm.py;h=8ad5e65b1b8034ee3345bfde4a242d113536f7a5;hb=refs%2Fheads%2F1.5;hp=482f610f389a34de2d0ededf84391d43e3094b2b;hpb=b6e806fc73f0fa8f2526cc7d1e62245db814d725;p=nodemanager.git diff --git a/nm.py b/nm.py index 482f610..8ad5e65 100644 --- a/nm.py +++ b/nm.py @@ -1,5 +1,7 @@ #!/usr/bin/python +# $Id: nm.py,v 1.15.2.8 2007/09/04 20:50:30 faiyaza Exp $ + """Node Manager""" import optparse @@ -16,6 +18,7 @@ import tools from config import Config from plcapi import PLCAPI import random +import net savedargv = sys.argv[:] @@ -30,20 +33,17 @@ parser.add_option('-p', '--period', action='store', dest='period', default=600, modules = [] def GetSlivers(plc): - data = plc.GetSlivers() - # net needs access to API for i2 nodes. + try: data = plc.GetSlivers() + except: logger.log_exc() + # Set i2 ip list for nodes in I2 nodegroup. + try: net.GetSlivers(plc, data) + except: logger.log_exc() + # All other callback modules for module in modules: - if module.__name__ == 'net': - module.GetSlivers(plc, data) - else: + try: callback = getattr(module, 'GetSlivers') callback(data) - -def UpdateHostKey(plc): - logger.log('Trying to update ssh host key at PLC...') - ssh_host_key = open('/etc/ssh/ssh_host_rsa_key.pub').read().strip() - plc.BootUpdateNode(dict(ssh_host_key=ssh_host_key)) - logger.log('Host key update succeeded') + except: logger.log_exc() def run(): try: @@ -61,7 +61,7 @@ def run(): print "Warning while writing PID file:", err # Load and start modules - for module in ['net', 'proper', 'conf_files', 'sm', 'bwmon']: + for module in ['proper', 'conf_files', 'sm', 'bwmon']: try: m = __import__(module) m.start(options, config) @@ -79,10 +79,8 @@ def run(): plc = PLCAPI(config.plc_api_uri, config.cacert, session, timeout=options.period/2) while True: - try: UpdateHostKey(plc) - except: logger.log_exc() - try: GetSlivers(plc) - except: logger.log_exc() + # Main NM Loop + GetSlivers(plc) time.sleep(options.period + random.randrange(0,301)) except: logger.log_exc()