def handle_switch_up(self, ev): dp = ev.msg.datapath ofp_parser = dp.ofproto_parser ofp = dp.ofproto self.logger.info("Switch "+str(dp.id)+" says hello.") switch = self.nib.save_switch(dp) self.logger.info("Connected to Switch: "+self.nib.switch_description(dp)) if self.mc != None: # This will block until the controller actually becomes a primary self.mc.handle_datapath(ev) # Start background thread to monitor switch-to-controller heartbeat self.last_heartbeat = time.time() if not self.heartbeat_monitor_started: thread.start_new_thread( self.heartbeat_monitor, (self, ) ) self.heartbeat_monitor_started = True OpenflowUtils.delete_all_rules(dp) OpenflowUtils.send_table_miss_config(dp) self.l2_learning_switch_handler.install_fixed_rules(dp) self.cross_campus_handler.install_fixed_rules(dp) self.arp_handler.install_fixed_rules(dp) self.path_selection_handler.install_fixed_rules(dp)
def handle_switch_up(self, ev): dp = ev.msg.datapath parser = dp.ofproto_parser ofproto = dp.ofproto switch = self.nib.save_switch(dp) self.logger.info("Connected to Switch: "+self.nib.switch_description(dp)) # This will block until the controller actually becomes a primary self.mc.handle_datapath(ev) # Start background thread to monitor switch-to-controller heartbeat self.last_heartbeat = time.time() if not self.heartbeat_monitor_started: thread.start_new_thread( self.heartbeat_monitor, (self, ) ) self.heartbeat_monitor_started = True OpenflowUtils.delete_all_rules(dp) OpenflowUtils.send_table_miss_config(dp) # Table 0, the Source Mac table, has table miss=Goto Controller so it can learn # newly-connected macs match_all = parser.OFPMatch() actions = [ parser.OFPActionOutput(ofproto.OFPP_CONTROLLER) ] OpenflowUtils.add_flow(dp, priority=0, match=match_all, actions=actions, table_id=0, cookie=self.LEARN_NEW_MACS_RULE) # Table 1, the Dest Mac table, has table-miss = Flood. If the destination exists, # it'll send a reply packet that'll get learned in table 0. We can afford to do a # sloppy non-spanning-tree flood because there's only one switch in our topology actions = [ parser.OFPActionOutput(ofproto.OFPP_FLOOD) ] OpenflowUtils.add_flow(dp, priority=0, match=match_all, actions=actions, table_id=1)