def remove_flows(self, datapath, table_id):
"""Removing all flow entries."""
parser = datapath.ofproto_parser
ofproto = datapath.ofproto
empty_match = parser.OFPMatch()
instructions = []
flow_mod = self.remove_table_flows(datapath, table_id,
empty_match, instructions)
print "deleting all flow entries in table ", table_id
datapath.send_msg(flow_mod)
def remove_table_flows(self, datapath, table_id, match, instructions):
"""Create OFP flow mod message to remove flows from table."""
ofproto = datapath.ofproto
flow_mod = datapath.ofproto_parser.OFPFlowMod(datapath, 0, 0, table_id,
ofproto.OFPFC_DELETE, 0,
0,
1,
ofproto.OFPCML_NO_BUFFER,
ofproto.OFPP_ANY,
OFPG_ANY, 0,
match, instructions)
With Best Regards,
M A MOYEEN
________________________________
From: Soe Ye Htet <soeyehtet1...@gmail.com>
Sent: Thursday, July 19, 2018 7:17:44 AM
To: Ryu-devel@lists.sourceforge.net
Subject: [Ryu-devel] Cannot detect the node failure
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<http://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<http://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