On Mon, 27 Jan 2014 11:47:59 +0900 (JST) yamam...@valinux.co.jp (YAMAMOTO Takashi) wrote:
>> 2014/1/24 YAMAMOTO Takashi <yamam...@valinux.co.jp> >> >>> Signed-off-by: YAMAMOTO Takashi <yamam...@valinux.co.jp> >>> --- >>> ryu/app/ofctl/service.py | 18 ++++++++++++++---- >>> 1 file changed, 14 insertions(+), 4 deletions(-) >>> >>> diff --git a/ryu/app/ofctl/service.py b/ryu/app/ofctl/service.py >>> index eac8d68..0b53d99 100644 >>> --- a/ryu/app/ofctl/service.py >>> +++ b/ryu/app/ofctl/service.py >>> @@ -45,16 +45,26 @@ class OfctlService(app_manager.RyuApp): >>> datapath = ev.msg.datapath >>> id = datapath.id >>> assert isinstance(id, (int, long)) >>> - self.logger.info('add dpid %s datapath %s' % (id, datapath)) >>> - self._switches[datapath.id] = _SwitchInfo(datapath=datapath) >>> + old_info = self._switches.get(id, None) >>> + new_info = _SwitchInfo(datapath=datapath) >>> + self.logger.info('add dpid %s datapath %s new_info %s old_info >>> %s' % >>> + (id, datapath, new_info, old_info)) >>> + self._switches[id] = new_info >>> >>> @set_ev_cls(ofp_event.EventOFPStateChange, DEAD_DISPATCHER) >>> def _handle_dead(self, ev): >>> datapath = ev.datapath >>> id = datapath.id >>> self.logger.info('del dpid %s datapath %s' % (id, datapath)) >>> - datapath2 = self._switches.pop(id) >>> - assert datapath2 == datapath >>> + if id is None: >>> + return >>> + try: >>> + info = self._switches[id] >>> + except KeyError: >>> + return >>> >> >> Probably, this might want to use pre-check. >> >> if not id in self._switches: >> return > > sounds like a matter of prefence/style. > i have no strong preference for either ways. > do we (ryu project) have any? I thought that someone told me something about a style about this but I can't recall. Looks like the existing code uses both so this patch is fine by me. ------------------------------------------------------------------------------ CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel