diff --git a/trunk/daemon/core/api/data.py b/trunk/daemon/core/api/data.py index bcc859c6..c8893586 100644 --- a/trunk/daemon/core/api/data.py +++ b/trunk/daemon/core/api/data.py @@ -282,6 +282,7 @@ event_types = dict(enumerate([ "CORE_EVENT_FILE_OPEN", "CORE_EVENT_FILE_SAVE", "CORE_EVENT_SCHEDULED", + "CORE_EVENT_RECONFIGURE", ])) enumdict(event_types) diff --git a/trunk/daemon/core/mobility.py b/trunk/daemon/core/mobility.py index 708e53cd..8335cf37 100644 --- a/trunk/daemon/core/mobility.py +++ b/trunk/daemon/core/mobility.py @@ -36,18 +36,25 @@ class MobilityManager(ConfigurableManager): self.session.broker.handlers += (self.physnodehandlelink, ) self.register() - def startup(self): + def startup(self, nodenums=None): ''' Session is transitioning from instantiation to runtime state. Instantiate any mobility models that have been configured for a WLAN. ''' - for nodenum in self.configs: - v = self.configs[nodenum] + if nodenums is None: + nodenums = self.configs.keys() + + for nodenum in nodenums: try: n = self.session.obj(nodenum) except KeyError: self.session.warn("Skipping mobility configuration for unknown" "node %d." % nodenum) continue + if nodenum not in self.configs: + self.session.warn("Missing mobility configuration for node " + "%d." % nodenum) + continue + v = self.configs[nodenum] for model in v: try: cls = self._modelclsmap[model[0]] @@ -60,6 +67,7 @@ class MobilityManager(ConfigurableManager): self.installphysnodes(n) if n.mobility: self.session.evq.add_event(0.0, n.mobility.startup) + return () def reset(self): diff --git a/trunk/daemon/core/service.py b/trunk/daemon/core/service.py index d43fea1b..d7113279 100644 --- a/trunk/daemon/core/service.py +++ b/trunk/daemon/core/service.py @@ -626,6 +626,18 @@ class CoreServices(ConfigurableManager): node.warn("error starting command %s" % cmd) if eventtype == coreapi.CORE_EVENT_PAUSE: self.validatenodeservice(node, s, services) + if eventtype == coreapi.CORE_EVENT_RECONFIGURE: + if s._custom: + cfgfiles = s._configs + else: + cfgfiles = s.getconfigfilenames(node.objid, services) + for filename in cfgfiles: + if filename[:7] == "file:///": + raise NotImplementedError # TODO + cfg = self.getservicefiledata(s, filename) + if cfg is None: + cfg = s.generateconfig(node, filename, services) + node.nodefile(filename, cfg) class CoreService(object): diff --git a/trunk/daemon/sbin/core-daemon b/trunk/daemon/sbin/core-daemon index 25128ccf..d74bad35 100755 --- a/trunk/daemon/sbin/core-daemon +++ b/trunk/daemon/sbin/core-daemon @@ -1047,11 +1047,26 @@ class CoreRequestHandler(SocketServer.BaseRequestHandler): def handleeventmsg(self, msg): ''' Event Message handler ''' - eventtype = msg.tlvdata[coreapi.CORE_TLV_EVENT_TYPE] + eventtype = msg.gettlv(coreapi.CORE_TLV_EVENT_TYPE) + if eventtype is None: + raise NotImplementedError, "Event message missing event type" + node = msg.gettlv(coreapi.CORE_TLV_EVENT_NODE) + if self.verbose: self.info("EVENT %d: %s at %s" % \ (eventtype, coreapi.event_types[eventtype], time.ctime())) if eventtype <= coreapi.CORE_EVENT_SHUTDOWN_STATE: + if node is not None: + try: + n = self.session.obj(node) + except KeyError: + raise KeyError, "Event message for unknown node %d" % node + if eventtype == coreapi.CORE_EVENT_INSTANTIATION_STATE: + # configure mobility models for WLAN added during runtime + if isinstance(n, pycore.nodes.WlanNode): + return (self.session.mobility.startup(nodenums=(n.objid,))) + self.warn("dropping unhandled Event message with node number") + return () self.session.setstate(state=eventtype, info=True, sendevent=False) if eventtype == coreapi.CORE_EVENT_DEFINITION_STATE: @@ -1080,8 +1095,8 @@ class CoreRequestHandler(SocketServer.BaseRequestHandler): if self.session.master: self.warn("Unexpected event message: SHUTDOWN state received " \ "at session master") - elif eventtype >= coreapi.CORE_EVENT_START and \ - eventtype <= coreapi.CORE_EVENT_RESTART: + elif eventtype in (coreapi.CORE_EVENT_START, coreapi.CORE_EVENT_RESTART, \ + coreapi.CORE_EVENT_RECONFIGURE): name = msg.gettlv(coreapi.CORE_TLV_EVENT_NAME) # TODO: register system for event message handlers, like confobjs if name[:8] == "service:":