X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=nodemanager.py;h=dfe62848755819ab2a2d5fe584efda6fdbb1090f;hb=6dff11015d344650af70fb1b2ce4ac2bf3d25b39;hp=d397a4b36dbc3e1e731d77fce11f5caa8accee13;hpb=1b4f53e648b13f7629970787b6ec03387e2d966a;p=nodemanager.git diff --git a/nodemanager.py b/nodemanager.py index d397a4b..dfe6284 100755 --- a/nodemanager.py +++ b/nodemanager.py @@ -11,7 +11,7 @@ import optparse import time -import xmlrpclib +import xmlrpc.client import socket import os import sys @@ -77,7 +77,7 @@ class NodeManager: if os.path.exists(self.options.path): sys.path.append(self.options.path) plugins = [ os.path.split(os.path.splitext(x)[0])[1] - for x in glob.glob( os.path.join(self.options.path,'*.py') ) + for x in glob.glob( os.path.join(self.options.path, '*.py') ) if not x.endswith("/__init__.py") ] self.modules += plugins @@ -116,7 +116,7 @@ class NodeManager: try: callback = getattr(module, 'GetSlivers') module_data = data - if getattr(module,'persistent_data',False): + if getattr(module, 'persistent_data', False): module_data = last_data callback(data, config, plc) except SystemExit as e: @@ -157,7 +157,7 @@ class NodeManager: if att['tagname'] == 'vref': att['value'] = slicefamily continue - sliver['attributes'].append({ 'tagname':'vref','value':slicefamily}) + sliver['attributes'].append({ 'tagname':'vref', 'value':slicefamily}) except: logger.log_exc("nodemanager: Could not overwrite 'vref' attribute from 'GetSliceFamily'", name=sliver['name']) @@ -198,11 +198,11 @@ class NodeManager: try: other_pid = tools.pid_file() if other_pid != None: - print """There might be another instance of the node manager running as pid {}. -If this is not the case, please remove the pid file {}. -- exiting""".format(other_pid, tools.PID_FILE) + print("""There might be another instance of the node manager running as pid {}. +If this is not the case, please remove the pid file {}. -- exiting""".format(other_pid, tools.PID_FILE)) return - except OSError, err: - print "Warning while writing PID file:", err + except OSError as err: + print("Warning while writing PID file:", err) # load modules self.loaded_modules = [] @@ -222,7 +222,7 @@ If this is not the case, please remove the pid file {}. -- exiting""".format(oth # sort on priority (lower first) def module_priority (m): - return getattr(m,'priority',NodeManager.default_priority) + return getattr(m, 'priority', NodeManager.default_priority) self.loaded_modules.sort(key=module_priority) logger.log('ordered modules:') @@ -251,7 +251,7 @@ If this is not the case, please remove the pid file {}. -- exiting""".format(oth try: plc.update_session() logger.log("nodemanager: Authentication Failure. Retrying") - except Exception,e: + except Exception as e: logger.log("nodemanager: Retry Failed. ({}); Waiting..".format(e)) time.sleep(iperiod) logger.log("nodemanager: Authentication Succeeded!") @@ -263,11 +263,11 @@ If this is not the case, please remove the pid file {}. -- exiting""".format(oth logger.log('nodemanager: mainloop - calling GetSlivers - period={} random={}' .format(iperiod, irandom)) self.GetSlivers(config, plc) - delay = iperiod + random.randrange(0,irandom) + delay = iperiod + random.randrange(0, irandom) work_end = time.time() work_duration = int(work_end-work_beg) logger.log('nodemanager: mainloop has worked for {} s - sleeping for {} s' - .format(work_duration,delay)) + .format(work_duration, delay)) time.sleep(delay) except SystemExit: pass