def run(self): try: if self.options.daemon: tools.daemon() # set log level if (self.options.verbose): logger.set_level(logger.LOG_VERBOSE) # Load /etc/planetlab/plc_config config = Config(self.options.config) try: other_pid = tools.pid_file() if other_pid != None: print """There might be another instance of the node manager running as pid %d. If this is not the case, please remove the pid file %s. -- exiting""" % (other_pid, tools.PID_FILE) return except OSError, err: print "Warning while writing PID file:", err # load modules self.loaded_modules = [] for module in self.modules: try: m = __import__(module) logger.verbose("nodemanager: triggering %s.start"%m.__name__) m.start() self.loaded_modules.append(m) except ImportError, err: print "Warning while loading module %s:" % module, err
def run(self): # make sure to create /etc/planetlab/virt so others can read that # used e.g. in vsys-scripts's sliceip tools.get_node_virt() try: if self.options.daemon: tools.daemon() # set log level if (self.options.verbose): logger.set_level(logger.LOG_VERBOSE) # Load /etc/planetlab/plc_config config = Config(self.options.config) try: other_pid = tools.pid_file() if other_pid != None: print """There might be another instance of the node manager running as pid %d. If this is not the case, please remove the pid file %s. -- exiting""" % ( other_pid, tools.PID_FILE) return except OSError, err: print "Warning while writing PID file:", err # load modules self.loaded_modules = [] for module in self.modules: try: m = __import__(module) logger.verbose("nodemanager: triggering %s.start" % m.__name__) m.start() self.loaded_modules.append(m) except ImportError, err: logger.log_exc( "ERROR while loading module %s - skipping:" % module) # if we fail to load any of these, it's really no need to go on any further if module in NodeManager.core_modules: logger.log("FATAL : failed to load core module %s" % module) except AttributeError, err: # triggered when module doesn't have a 'start' method logger.log_exc( "ERROR while starting module %s - skipping:" % module) # if we fail to load any of these, it's really no need to go on any further if module in NodeManager.core_modules: logger.log("FATAL : failed to start core module %s" % module)
def run(self): # make sure to create /etc/planetlab/virt so others can read that # used e.g. in vsys-scripts's sliceip tools.get_node_virt() try: if self.options.daemon: tools.daemon() # set log level if (self.options.verbose): logger.set_level(logger.LOG_VERBOSE) # Load /etc/planetlab/plc_config config = Config(self.options.config) try: other_pid = tools.pid_file() if other_pid != None: print """There might be another instance of the node manager running as pid %d. If this is not the case, please remove the pid file %s. -- exiting""" % (other_pid, tools.PID_FILE) return except OSError, err: print "Warning while writing PID file:", err # load modules self.loaded_modules = [] for module in self.modules: try: m = __import__(module) logger.verbose("nodemanager: triggering %s.start"%m.__name__) m.start() self.loaded_modules.append(m) except ImportError, err: logger.log_exc ("ERROR while loading module %s - skipping:" % module) # if we fail to load any of these, it's really no need to go on any further if module in NodeManager.core_modules: logger.log("FATAL : failed to load core module %s"%module) except AttributeError, err: # triggered when module doesn't have a 'start' method logger.log_exc ("ERROR while starting module %s - skipping:" % module) # if we fail to load any of these, it's really no need to go on any further if module in NodeManager.core_modules: logger.log("FATAL : failed to start core module %s"%module)
def run(self): # make sure to create /etc/planetlab/virt so others can read that # used e.g. in vsys-scripts's sliceip tools.get_node_virt() try: if self.options.daemon: tools.daemon() # set log level if self.options.verbose: logger.set_level(logger.LOG_VERBOSE) tools.init_signals() # Load /etc/planetlab/plc_config config = Config(self.options.config) try: other_pid = tools.pid_file() if other_pid is not 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)) return except OSError as err: print("Warning while writing PID file:", err) # load modules self.loaded_modules = [] for module in self.modules: try: m = __import__(module) logger.verbose("nodemanager: triggering {}.start".format(m.__name__)) try: m.start() except Exception: logger.log("WARNING: module {} did not start".format(m.__name__)) self.loaded_modules.append(m) except Exception: if module not in NodeManager.core_modules: logger.log_exc("ERROR while loading module {} - skipped" .format(module)) else: logger.log("FATAL : failed to start core module {}".format(module)) sys.exit(1) # sort on priority (lower first) def module_priority(module): return getattr(module, 'priority', NodeManager.default_priority) self.loaded_modules.sort(key=module_priority) logger.log('ordered modules:') for module in self.loaded_modules: logger.log('{}: {}' .format(getattr(module, 'priority', NodeManager.default_priority), module.__name__)) # Load /etc/planetlab/session if os.path.exists(self.options.session): with open(self.options.session) as feed: session = feed.read().strip() else: session = None # get random periods iperiod = int(self.options.period) irandom = int(self.options.random) # Initialize XML-RPC client plc = PLCAPI(config.plc_api_uri, config.cacert, session, timeout=iperiod/2) #check auth logger.log("nodemanager: Checking Auth.") while not plc.check_authentication(): try: plc.update_session() logger.log("nodemanager: Authentication Failure. Retrying") except Exception as exc: logger.log("nodemanager: Retry Failed. ({}); Waiting.." .format(exc)) time.sleep(iperiod) logger.log("nodemanager: Authentication Succeeded!") while True: # Main nodemanager Loop work_beg = time.time() logger.log('nodemanager: mainloop - calling GetSlivers - period={} random={}' .format(iperiod, irandom)) self.GetSlivers(config, plc) 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)) time.sleep(delay) except SystemExit: pass except: logger.log_exc("nodemanager: failed in run")