def consume_userdata(self, frequency=per_instance): self.get_userdata() data = self cdir = get_cpath("handlers") idir = self.get_ipath("handlers") # add the path to the plugins dir to the top of our list for import # instance dir should be read before cloud-dir sys.path.insert(0, cdir) sys.path.insert(0, idir) part_handlers = {} # add handlers in cdir for fname in glob.glob("%s/*.py" % cdir): if not os.path.isfile(fname): continue modname = os.path.basename(fname)[0:-3] try: mod = __import__(modname) handler_register(mod, part_handlers, data, frequency) log.debug("added handler for [%s] from %s" % (mod.list_types(), fname)) except: log.warn("failed to initialize handler in %s" % fname) util.logexc(log) # add the internal handers if their type hasn't been already claimed for (btype, bhand, bfreq) in self.builtin_handlers: if btype in part_handlers: continue handler_register(InternalPartHandler(bhand, [btype], bfreq), part_handlers, data, frequency) # walk the data pdata = { 'handlers': part_handlers, 'handlerdir': idir, 'data': data, 'frequency': frequency } UserDataHandler.walk_userdata(self.get_userdata(), partwalker_callback, data=pdata) # give callbacks opportunity to finalize called = [] for (_mtype, mod) in part_handlers.iteritems(): if mod in called: continue handler_call_end(mod, data, frequency)
def consume_userdata(self, frequency=per_instance): self.get_userdata() data = self cdir = get_cpath("handlers") idir = self.get_ipath("handlers") # add the path to the plugins dir to the top of our list for import # instance dir should be read before cloud-dir sys.path.insert(0, cdir) sys.path.insert(0, idir) part_handlers = {} # add handlers in cdir for fname in glob.glob("%s/*.py" % cdir): if not os.path.isfile(fname): continue modname = os.path.basename(fname)[0:-3] try: mod = __import__(modname) handler_register(mod, part_handlers, data, frequency) log.debug("added handler for [%s] from %s" % (mod.list_types(), fname)) except: log.warn("failed to initialize handler in %s" % fname) util.logexc(log) # add the internal handers if their type hasn't been already claimed for (btype, bhand, bfreq) in self.builtin_handlers: if btype in part_handlers: continue handler_register(InternalPartHandler(bhand, [btype], bfreq), part_handlers, data, frequency) # walk the data pdata = {'handlers': part_handlers, 'handlerdir': idir, 'data': data, 'frequency': frequency} UserDataHandler.walk_userdata(self.get_userdata(), partwalker_callback, data=pdata) # give callbacks opportunity to finalize called = [] for (_mtype, mod) in part_handlers.iteritems(): if mod in called: continue handler_call_end(mod, data, frequency)
def get_userdata(self): if self.userdata == None: self.userdata = ud.preprocess_userdata(self.userdata_raw) return self.userdata