Dear,

Please kindly suggest me how to detect node failure. I follow the following
code to detect the node failure by writing the event.EventSwitchLeave but I
can only detect the switch enter. When I shut down the node, the leaved
switch cannot be detected.

from operator import attrgetter
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER,
DEAD_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_3
from ryu.controller import dpset
from ryu.lib.packet import ipv4
from ryu.lib.packet import tcp
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.lib.packet import ether_types
from ryu.topology import event, switches
from ryu.lib import hub
from ryu.topology.switches import LLDPPacket
from ryu import topology
import numpy
from ryu.topology.api import get_switch, get_link, get_all_link, get_all_switch
from ryu.lib import dpid
from threading import Lock
from collections import defaultdict
import copy
import os
import time

class SimpleSwitch13(app_manager.RyuApp):
    OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]

    def __init__(self, *args, **kwargs):
        super(SimpleSwitch13, self).__init__(*args, **kwargs)
        self.datapaths = {}
        self.mac_to_port = {}
        self.switches={}

    @set_ev_cls(event.EventSwitchEnter)
    def switch_enter_handler(self,event):
        switch = event.switch.dp.id
        switch_ip = event.switch.dp.address
        self.switches[switch] = switch_ip
#        print("List of switches", self.switches)

    @set_ev_cls(event.EventSwitchLeave)
    def switch_leave_handler(self,event):
        switch = event.switch.dp.id
        switch_ip = event.switch.dp.address
        print("deleted switch ID",switch)
        if switch in switches:
            del self.switches[switch]
            print("deleted switch",self.switches)


Best regards,
Soe Ye Htet
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to