INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
This method gets in - bound filters of the specified neighbor. | def in_filter_get(self, address):
"""This method gets in-bound filters of the specified neighbor.
``address`` specifies the IP address of the neighbor.
Returns a list object containing an instance of Filter sub-class
"""
func_name = 'neighbor.in_filter.get'
param = {
... |
This method registers a new BMP ( BGP monitoring Protocol ) server. The BGP speaker starts to send BMP messages to the server. Currently only one BMP server can be registered. | def bmp_server_add(self, address, port):
"""This method registers a new BMP (BGP monitoring Protocol)
server. The BGP speaker starts to send BMP messages to the
server. Currently, only one BMP server can be registered.
``address`` specifies the IP address of a BMP server.
``por... |
This method unregister the registered BMP server. | def bmp_server_del(self, address, port):
""" This method unregister the registered BMP server.
``address`` specifies the IP address of a BMP server.
``port`` specifies the listen port number of a BMP server.
"""
func_name = 'bmp.stop'
param = {
'host': addr... |
This method sets attribute mapping to a neighbor. attribute mapping can be used when you want to apply attribute to BGPUpdate under specific conditions. | def attribute_map_set(self, address, attribute_maps,
route_dist=None, route_family=RF_VPN_V4):
"""This method sets attribute mapping to a neighbor.
attribute mapping can be used when you want to apply
attribute to BGPUpdate under specific conditions.
``address`... |
This method gets in - bound filters of the specified neighbor. | def attribute_map_get(self, address, route_dist=None,
route_family=RF_VPN_V4):
"""This method gets in-bound filters of the specified neighbor.
``address`` specifies the IP address of the neighbor.
``route_dist`` specifies route distinguisher that has attribute_maps.
... |
check prefix s route_family and if the address is IPv6 address return IPv6 route_family and normalized IPv6 address. If the address is IPv4 address return IPv4 route_family and the prefix itself. | def _check_rf_and_normalize(prefix):
""" check prefix's route_family and if the address is
IPv6 address, return IPv6 route_family and normalized IPv6 address.
If the address is IPv4 address, return IPv4 route_family
and the prefix itself.
"""
addr, masklen = prefix.split(... |
Configure remote ethernet and IP addresses. | def set_remote_addr(self, dst_mac, dst_ip):
"""
Configure remote ethernet and IP addresses.
"""
self.dst_mac = dst_mac
self.dst_ip = dst_ip
if not (dst_mac == "FF:FF:FF:FF:FF:FF" or dst_ip == "255.255.255.255"):
self._remote_addr_config = True
LOG.in... |
BFD packet receiver. | def recv(self, bfd_pkt):
"""
BFD packet receiver.
"""
LOG.debug("[BFD][%s][RECV] BFD Control received: %s",
hex(self._local_discr), six.binary_type(bfd_pkt))
self._remote_discr = bfd_pkt.my_discr
self._remote_state = bfd_pkt.state
self._remote_de... |
Set the state of the BFD session. | def _set_state(self, new_state, diag=None):
"""
Set the state of the BFD session.
"""
old_state = self._session_state
LOG.info("[BFD][%s][STATE] State changed from %s to %s.",
hex(self._local_discr),
bfd.BFD_STATE_NAME[old_state],
... |
A loop to check timeout of receiving remote BFD packet. | def _recv_timeout_loop(self):
"""
A loop to check timeout of receiving remote BFD packet.
"""
while self._detect_time:
last_wait = time.time()
self._lock = hub.Event()
self._lock.wait(timeout=self._detect_time)
if self._lock.is_set():
... |
Update transmission period of the BFD session. | def _update_xmit_period(self):
"""
Update transmission period of the BFD session.
"""
# RFC5880 Section 6.8.7.
if self._desired_min_tx_interval > self._remote_min_rx_interval:
xmit_period = self._desired_min_tx_interval
else:
xmit_period = self._re... |
A loop to proceed periodic BFD packet transmission. | def _send_loop(self):
"""
A loop to proceed periodic BFD packet transmission.
"""
while self._enable_send:
hub.sleep(self._xmit_period)
# Send BFD packet. (RFC5880 Section 6.8.7.)
if self._remote_discr == 0 and not self._active_role:
... |
BFD packet sender. | def _send(self):
"""
BFD packet sender.
"""
# If the switch was not connected to controller, exit.
if self.datapath is None:
return
# BFD Flags Setup
flags = 0
if self._pending_final:
flags |= bfd.BFD_FLAG_FINAL
self._... |
Generate BFD packet with Ethernet/ IPv4/ UDP encapsulated. | def bfd_packet(src_mac, dst_mac, src_ip, dst_ip, ipv4_id,
src_port, dst_port,
diag=0, state=0, flags=0, detect_mult=0,
my_discr=0, your_discr=0, desired_min_tx_interval=0,
required_min_rx_interval=0,
required_min_echo_rx_inte... |
Parse raw packet and return BFD class from packet library. | def bfd_parse(data):
"""
Parse raw packet and return BFD class from packet library.
"""
pkt = packet.Packet(data)
i = iter(pkt)
eth_pkt = next(i)
assert isinstance(eth_pkt, ethernet.ethernet)
ipv4_pkt = next(i)
assert isinstance(ipv4_pkt, ipv4.ip... |
Generate ARP packet with ethernet encapsulated. | def arp_packet(opcode, src_mac, src_ip, dst_mac, dst_ip):
"""
Generate ARP packet with ethernet encapsulated.
"""
# Generate ethernet header first.
pkt = packet.Packet()
eth_pkt = ethernet.ethernet(dst_mac, src_mac, ETH_TYPE_ARP)
pkt.add_protocol(eth_pkt)
... |
Parse ARP packet return ARP class from packet library. | def arp_parse(data):
"""
Parse ARP packet, return ARP class from packet library.
"""
# Iteratize pkt
pkt = packet.Packet(data)
i = iter(pkt)
eth_pkt = next(i)
# Ensure it's an ethernet frame.
assert isinstance(eth_pkt, ethernet.ethernet)
a... |
Establish a new BFD session and return My Discriminator of new session. | def add_bfd_session(self, dpid, ofport, src_mac, src_ip,
dst_mac="FF:FF:FF:FF:FF:FF", dst_ip="255.255.255.255",
auth_type=0, auth_keys=None):
"""
Establish a new BFD session and return My Discriminator of new session.
Configure the BFD session wit... |
Prepare a VRRP packet. | def create_packet(self, primary_ip_address, vlan_id=None):
"""Prepare a VRRP packet.
Returns a newly created ryu.lib.packet.packet.Packet object
with appropriate protocol header objects added by add_protocol().
It's caller's responsibility to serialize().
The serialized packet w... |
Adds * prefix * from VRF identified by * route_dist * and sets the source as network controller. | def add_local(route_dist, prefix, next_hop, route_family=VRF_RF_IPV4):
"""Adds *prefix* from VRF identified by *route_dist* and sets the source as
network controller.
"""
try:
# Create new path and insert into appropriate VRF table.
tm = CORE_MANAGER.get_core_service().table_manager
... |
Deletes/ withdraws * prefix * from VRF identified by * route_dist * and source as network controller. | def delete_local(route_dist, prefix, route_family=VRF_RF_IPV4):
"""Deletes/withdraws *prefix* from VRF identified by *route_dist* and
source as network controller.
"""
try:
tm = CORE_MANAGER.get_core_service().table_manager
tm.update_vrf_table(route_dist, prefix,
... |
Adds EVPN route from VRF identified by * route_dist *. | def add_evpn_local(route_type, route_dist, next_hop, **kwargs):
"""Adds EVPN route from VRF identified by *route_dist*.
"""
if(route_type in [EVPN_ETH_AUTO_DISCOVERY, EVPN_ETH_SEGMENT]
and kwargs['esi'] == 0):
raise ConfigValueError(conf_name=EVPN_ESI,
conf_val... |
Deletes/ withdraws EVPN route from VRF identified by * route_dist *. | def delete_evpn_local(route_type, route_dist, **kwargs):
"""Deletes/withdraws EVPN route from VRF identified by *route_dist*.
"""
try:
tm = CORE_MANAGER.get_core_service().table_manager
tm.update_vrf_table(route_dist,
route_family=VRF_RF_L2_EVPN,
... |
Adds Flow Specification route from VRF identified by * route_dist *. | def add_flowspec_local(flowspec_family, route_dist, rules, **kwargs):
"""Adds Flow Specification route from VRF identified by *route_dist*.
"""
try:
# Create new path and insert into appropriate VRF table.
tm = CORE_MANAGER.get_core_service().table_manager
tm.update_flowspec_vrf_tabl... |
Deletes/ withdraws Flow Specification route from VRF identified by * route_dist *. | def del_flowspec_local(flowspec_family, route_dist, rules):
"""Deletes/withdraws Flow Specification route from VRF identified
by *route_dist*.
"""
try:
tm = CORE_MANAGER.get_core_service().table_manager
tm.update_flowspec_vrf_table(
flowspec_family=flowspec_family, route_dist... |
Wrapper for socket. create_connection () function. | def create_connection(address):
"""
Wrapper for socket.create_connection() function.
If *address* (a 2-tuple ``(host, port)``) contains a valid IPv4/v6
address, passes *address* to socket.create_connection().
If *host* is valid path to Unix Domain socket, tries to connect to
the server listenin... |
Sends ZEBRA_IPV4/ v6_ROUTE_ADD message to Zebra daemon. | def send_ip_route_add(
self, prefix, nexthops=None,
safi=packet_safi.UNICAST, flags=zebra.ZEBRA_FLAG_INTERNAL,
distance=None, metric=None, mtu=None, tag=None):
"""
Sends ZEBRA_IPV4/v6_ROUTE_ADD message to Zebra daemon.
:param prefix: IPv4/v6 Prefix to adverti... |
Request the application to be automatically loaded. | def require_app(app_name, api_style=False):
"""
Request the application to be automatically loaded.
If this is used for "api" style modules, which is imported by a client
application, set api_style=True.
If this is used for client application module, set api_style=False.
"""
iterable = (in... |
Returns a list of handlers for the specific event. | def get_handlers(self, ev, state=None):
"""Returns a list of handlers for the specific event.
:param ev: The event to handle.
:param state: The current state. ("dispatcher")
If None is given, returns all handlers for the event.
Otherwise, returns only... |
Make a synchronous request. Set req. sync to True send it to a Ryu application specified by req. dst and block until receiving a reply. Returns the received reply. The argument should be an instance of EventRequestBase. | def send_request(self, req):
"""
Make a synchronous request.
Set req.sync to True, send it to a Ryu application specified by
req.dst, and block until receiving a reply.
Returns the received reply.
The argument should be an instance of EventRequestBase.
"""
... |
Send the specified event to the RyuApp instance specified by name. | def send_event(self, name, ev, state=None):
"""
Send the specified event to the RyuApp instance specified by name.
"""
if name in SERVICE_BRICKS:
if isinstance(ev, EventRequestBase):
ev.src = self.name
LOG.debug("EVENT %s->%s %s",
... |
Send the specified event to all observers of this RyuApp. | def send_event_to_observers(self, ev, state=None):
"""
Send the specified event to all observers of this RyuApp.
"""
for observer in self.get_observers(ev, state):
self.send_event(observer, ev, state) |
Send a reply for a synchronous request sent by send_request. The first argument should be an instance of EventRequestBase. The second argument should be an instance of EventReplyBase. | def reply_to_request(self, req, rep):
"""
Send a reply for a synchronous request sent by send_request.
The first argument should be an instance of EventRequestBase.
The second argument should be an instance of EventReplyBase.
"""
assert isinstance(req, EventRequestBase)
... |
Run a set of Ryu applications | def run_apps(app_lists):
"""Run a set of Ryu applications
A convenient method to load and instantiate apps.
This blocks until all relevant apps stop.
"""
app_mgr = AppManager.get_instance()
app_mgr.load_apps(app_lists)
contexts = app_mgr.create_contexts()
... |
list_cap <peer > | def do_list_cap(self, line):
"""list_cap <peer>
"""
def f(p, args):
for i in p.netconf.server_capabilities:
print(i)
self._request(line, f) |
raw_get <peer > | def do_raw_get(self, line):
"""raw_get <peer>
"""
def f(p, args):
result = p.raw_get()
tree = ET.fromstring(result)
validate(tree)
print(et_tostring_pp(tree))
self._request(line, f) |
raw_get_config <peer > <source > | def do_raw_get_config(self, line):
"""raw_get_config <peer> <source>
"""
def f(p, args):
try:
source = args[0]
except:
print("argument error")
return
result = p.raw_get_config(source)
tree = ET.froms... |
get <peer > eg. get sw1 | def do_get(self, line):
"""get <peer>
eg. get sw1
"""
def f(p, args):
print(p.get())
self._request(line, f) |
commit <peer > eg. commit sw1 | def do_commit(self, line):
"""commit <peer>
eg. commit sw1
"""
def f(p, args):
print(p.commit())
self._request(line, f) |
discard <peer > eg. discard sw1 | def do_discard(self, line):
"""discard <peer>
eg. discard sw1
"""
def f(p, args):
print(p.discard_changes())
self._request(line, f) |
get_config <peer > <source > eg. get_config sw1 startup | def do_get_config(self, line):
"""get_config <peer> <source>
eg. get_config sw1 startup
"""
def f(p, args):
try:
source = args[0]
except:
print("argument error")
return
print(p.get_config(source))
... |
delete_config <peer > <source > eg. delete_config sw1 startup | def do_delete_config(self, line):
"""delete_config <peer> <source>
eg. delete_config sw1 startup
"""
def f(p, args):
try:
source = args[0]
except:
print("argument error")
return
print(p.delete_config(sou... |
copy_config <peer > <source > <target > eg. copy_config sw1 running startup | def do_copy_config(self, line):
"""copy_config <peer> <source> <target>
eg. copy_config sw1 running startup
"""
def f(p, args):
try:
source, target = args
except:
print("argument error")
return
print(p.c... |
list_port <peer > | def do_list_port(self, line):
"""list_port <peer>
"""
def f(p, args):
o = p.get()
for p in o.resources.port:
print('%s %s %s' % (p.resource_id, p.name, p.number))
self._request(line, f) |
get_config_port <peer > <source > <port > eg. get_port_config sw1 running LogicalSwitch7 - Port2 | def do_get_port_config(self, line):
"""get_config_port <peer> <source> <port>
eg. get_port_config sw1 running LogicalSwitch7-Port2
"""
def f(p, args):
try:
source, port = args
except:
print("argument error")
return
... |
set_port_config <peer > <target > <port > <key > <value > eg. set_port_config sw1 running LogicalSwitch7 - Port2 admin - state down eg. set_port_config sw1 running LogicalSwitch7 - Port2 no - forward false | def do_set_port_config(self, line):
"""set_port_config <peer> <target> <port> <key> <value>
eg. set_port_config sw1 running LogicalSwitch7-Port2 admin-state down
eg. set_port_config sw1 running LogicalSwitch7-Port2 no-forward false
"""
def f(p, args):
try:
... |
list_queue <peer > | def do_list_queue(self, line):
"""list_queue <peer>
"""
def f(p, args):
o = p.get()
if o.resources.queue:
for q in o.resources.queue:
print('%s %s' % (q.resource_id, q.port))
self._request(line, f) |
get_queue_port <peer > <source > <queue > eg. get_queue_config sw1 running LogicalSwitch7 - Port1 - Queue922 | def do_get_queue_config(self, line):
"""get_queue_port <peer> <source> <queue>
eg. get_queue_config sw1 running LogicalSwitch7-Port1-Queue922
"""
def f(p, args):
try:
source, queue = args
except:
print("argument error")
... |
set_queue_config <peer > <target > <queue > <key > <value > eg. set_queue_config sw1 running LogicalSwitch7 - Port1 - Queue922 \ max - rate 100 | def do_set_queue_config(self, line):
"""set_queue_config <peer> <target> <queue> <key> <value>
eg. set_queue_config sw1 running LogicalSwitch7-Port1-Queue922 \
max-rate 100
"""
def f(p, args):
try:
target, queue, key, value = args
except:
... |
add_queue <peer > <target > <logical - switch > <queue > eg. add_queue sw1 running LogicalSwitch7 NameOfNewQueue | def do_add_queue(self, line):
"""add_queue <peer> <target> <logical-switch> <queue>
eg. add_queue sw1 running LogicalSwitch7 NameOfNewQueue
"""
def f(p, args):
try:
target, lsw, queue = args
except:
print("argument error")
... |
list_logical_switch <peer > | def do_list_logical_switch(self, line):
"""list_logical_switch <peer>
"""
def f(p, args):
o = p.get()
for s in o.logical_switches.switch:
print('%s %s' % (s.id, s.datapath_id))
self._request(line, f) |
show_logical_switch <peer > <logical switch > | def do_show_logical_switch(self, line):
"""show_logical_switch <peer> <logical switch>
"""
def f(p, args):
try:
(lsw,) = args
except:
print("argument error")
return
o = p.get()
for s in o.logical_swi... |
get_logical_switch_config <peer > <source > <logical switch > | def do_get_logical_switch_config(self, line):
"""get_logical_switch_config <peer> <source> <logical switch>
"""
def f(p, args):
try:
source, lsw = args
except:
print("argument error")
return
o = p.get_config(sou... |
set_logical_switch_config <peer > <logical switch > <key > <value > eg. set_logical_switch_config sw1 running LogicalSwitch7 \ lost - connection - behavior failStandaloneMode | def do_set_logical_switch_config(self, line):
"""set_logical_switch_config <peer> <logical switch> <key> <value>
eg. set_logical_switch_config sw1 running LogicalSwitch7 \
lost-connection-behavior failStandaloneMode
"""
def f(p, args):
try:
target, lsw, key, ... |
A convenient wrapper for IPv4 ARP for Ethernet. | def arp_ip(opcode, src_mac, src_ip, dst_mac, dst_ip):
"""A convenient wrapper for IPv4 ARP for Ethernet.
This is an equivalent of the following code.
arp(ARP_HW_TYPE_ETHERNET, ether.ETH_TYPE_IP, \
6, 4, opcode, src_mac, src_ip, dst_mac, dst_ip)
"""
return arp(ARP_HW_TYPE_ETHERNE... |
A decorator for Ryu application to declare an event handler. | def set_ev_cls(ev_cls, dispatchers=None):
"""
A decorator for Ryu application to declare an event handler.
Decorated method will become an event handler.
ev_cls is an event class whose instances this RyuApp wants to receive.
dispatchers argument specifies one of the following negotiation phases
... |
Register the ryu application specified by service as a provider of events defined in the calling module. | def register_service(service):
"""
Register the ryu application specified by 'service' as
a provider of events defined in the calling module.
If an application being loaded consumes events (in the sense of
set_ev_cls) provided by the 'service' application, the latter
application will be automat... |
Returns neighbor configuration for given neighbor ip address. | def _get_neighbor_conf(neigh_ip_address):
"""Returns neighbor configuration for given neighbor ip address.
Raises exception if no neighbor with `neigh_ip_address` exists.
"""
neigh_conf = \
CORE_MANAGER.neighbors_conf.get_neighbor_conf(neigh_ip_address)
if not neigh_conf:
raise Runt... |
Returns a neighbor in_filter for given ip address if exists. | def get_neighbor_in_filter(neigh_ip_address):
"""Returns a neighbor in_filter for given ip address if exists."""
core = CORE_MANAGER.get_core_service()
peer = core.peer_manager.get_by_addr(neigh_ip_address)
return peer.in_filters |
Returns a neighbor in_filter for given ip address if exists. | def set_neighbor_in_filter(neigh_ip_address, filters):
"""Returns a neighbor in_filter for given ip address if exists."""
core = CORE_MANAGER.get_core_service()
peer = core.peer_manager.get_by_addr(neigh_ip_address)
peer.in_filters = filters
return True |
Returns a neighbor out_filter for given ip address if exists. | def get_neighbor_out_filter(neigh_ip_address):
"""Returns a neighbor out_filter for given ip address if exists."""
core = CORE_MANAGER.get_core_service()
ret = core.peer_manager.get_by_addr(neigh_ip_address).out_filters
return ret |
Sets the out_filter of a neighbor. | def set_neighbor_out_filter(neigh_ip_address, filters):
"""Sets the out_filter of a neighbor."""
core = CORE_MANAGER.get_core_service()
peer = core.peer_manager.get_by_addr(neigh_ip_address)
peer.out_filters = filters
return True |
set attribute_maps to the neighbor. | def set_neighbor_attribute_map(neigh_ip_address, at_maps,
route_dist=None, route_family=VRF_RF_IPV4):
"""set attribute_maps to the neighbor."""
core = CORE_MANAGER.get_core_service()
peer = core.peer_manager.get_by_addr(neigh_ip_address)
at_maps_key = const.ATTR_MAPS_LABE... |
Returns a neighbor attribute_map for given ip address if exists. | def get_neighbor_attribute_map(neigh_ip_address, route_dist=None,
route_family=VRF_RF_IPV4):
"""Returns a neighbor attribute_map for given ip address if exists."""
core = CORE_MANAGER.get_core_service()
peer = core.peer_manager.get_by_addr(neigh_ip_address)
at_maps_key = c... |
Decorator for registering API function. | def register(**kwargs):
"""Decorator for registering API function.
Does not do any check or validation.
"""
def decorator(func):
_CALL_REGISTRY[kwargs.get(API_SYM, func.__name__)] = func
return func
return decorator |
Calls/ executes BGPS public API identified by given symbol and passes given kwargs as param. | def call(symbol, **kwargs):
"""Calls/executes BGPS public API identified by given symbol and passes
given kwargs as param.
"""
LOG.info("API method %s called with args: %s", symbol, str(kwargs))
# TODO(PH, JK) improve the way api function modules are loaded
from . import all # noqa
if not ... |
This method is registered as ofp_error_code_to_str ( type_ code ) method into ryu. ofproto. ofproto_v1_ * modules. And this method returns the error code as a string value for given type and code defined in ofp_error_msg structure. | def _error_code_to_str(mod, type_, code):
"""
This method is registered as ofp_error_code_to_str(type_, code) method
into ryu.ofproto.ofproto_v1_* modules.
And this method returns the error code as a string value for given
'type' and 'code' defined in ofp_error_msg structure.
Example::
... |
This method is registered as ofp_error_to_jsondict ( type_ code ) method into ryu. ofproto. ofproto_v1_ * modules. And this method returns ofp_error_msg as a json format for given type and code defined in ofp_error_msg structure. | def _error_to_jsondict(mod, type_, code):
"""
This method is registered as ofp_error_to_jsondict(type_, code) method
into ryu.ofproto.ofproto_v1_* modules.
And this method returns ofp_error_msg as a json format for given
'type' and 'code' defined in ofp_error_msg structure.
Example::
>... |
Returns a copy of current settings. | def settings(self):
"""Returns a copy of current settings.
As some of the attributes are themselves containers, we clone the
settings to provide clones for those containers as well.
"""
# Shallow copy first
cloned_setting = self._settings.copy()
# Don't want clon... |
Updates this VrfConf settings. | def update(self, **kwargs):
"""Updates this `VrfConf` settings.
Notifies listeners if any settings changed. Returns `True` if update
was successful. This vrfs' route family, id and route dist settings
cannot be updated/changed.
"""
# Update inherited configurations
... |
Removes any matching VrfConf for given route_dist or vrf_id | def remove_vrf_conf(self, route_dist=None, vrf_id=None,
vrf_rf=None):
"""Removes any matching `VrfConf` for given `route_dist` or `vrf_id`
Parameters:
- `route_dist`: (str) route distinguisher of a configured VRF
- `vrf_id`: (str) vrf ID
- `vr... |
PacketIn event handler. when the received packet was IGMP proceed it. otherwise send a event. | def packet_in_handler(self, evt):
"""PacketIn event handler. when the received packet was IGMP,
proceed it. otherwise, send a event."""
msg = evt.msg
dpid = msg.datapath.id
req_pkt = packet.Packet(msg.data)
req_igmp = req_pkt.get_protocol(igmp.igmp)
if req_igmp:
... |
StateChange event handler. | def state_change_handler(self, evt):
"""StateChange event handler."""
datapath = evt.datapath
assert datapath is not None
if datapath.id == self._querier.dpid:
if evt.state == MAIN_DISPATCHER:
self._querier.start_loop(datapath)
elif evt.state == DE... |
set a flow entry. | def _set_flow_entry(self, datapath, actions, in_port, dst, src=None):
"""set a flow entry."""
set_flow = self._set_flow_func.get(datapath.ofproto.OFP_VERSION)
assert set_flow
set_flow(datapath, actions, in_port, dst, src) |
remove a flow entry. | def _del_flow_entry(self, datapath, in_port, dst, src=None):
"""remove a flow entry."""
del_flow = self._del_flow_func.get(datapath.ofproto.OFP_VERSION)
assert del_flow
del_flow(datapath, in_port, dst, src) |
send a packet. | def _do_packet_out(self, datapath, data, in_port, actions):
"""send a packet."""
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
out = parser.OFPPacketOut(
datapath=datapath, buffer_id=ofproto.OFP_NO_BUFFER,
data=data, in_port=in_port, actions=actions... |
convert ip v4 string to integer. | def _ipv4_text_to_int(self, ip_text):
"""convert ip v4 string to integer."""
if ip_text is None:
return None
assert isinstance(ip_text, str)
return struct.unpack('!I', addrconv.ipv4.text_to_bin(ip_text))[0] |
set the datapath to work as a querier. note that you can set up only the one querier. when you called this method several times only the last one becomes effective. | def set_querier_mode(self, dpid, server_port):
"""set the datapath to work as a querier. note that you can set
up only the one querier. when you called this method several
times, only the last one becomes effective."""
self.dpid = dpid
self.server_port = server_port
if se... |
the process when the querier received IGMP. | def packet_in_handler(self, req_igmp, msg):
"""the process when the querier received IGMP."""
ofproto = msg.datapath.ofproto
if ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
in_port = msg.in_port
else:
in_port = msg.match['in_port']
if (igmp.IGMP_TYPE_R... |
start QUERY thread. | def start_loop(self, datapath):
"""start QUERY thread."""
self._datapath = datapath
self._querier_thread = hub.spawn(self._send_query)
self.logger.info("started a querier.") |
stop QUERY thread. | def stop_loop(self):
"""stop QUERY thread."""
hub.kill(self._querier_thread)
self._querier_thread = None
self._datapath = None
self.logger.info("stopped a querier.") |
send a QUERY message periodically. | def _send_query(self):
""" send a QUERY message periodically."""
timeout = 60
ofproto = self._datapath.ofproto
parser = self._datapath.ofproto_parser
if ofproto_v1_0.OFP_VERSION == ofproto.OFP_VERSION:
send_port = ofproto.OFPP_NONE
else:
send_port ... |
the process when the querier received a REPORT message. | def _do_report(self, report, in_port, msg):
"""the process when the querier received a REPORT message."""
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
if ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
size = 65535
else... |
the process when the querier received a LEAVE message. | def _do_leave(self, leave, in_port, msg):
"""the process when the querier received a LEAVE message."""
datapath = msg.datapath
parser = datapath.ofproto_parser
self._mcast.setdefault(leave.address, {})
if in_port in self._mcast[leave.address]:
self._del_flow_entry(
... |
change log format. | def _set_logger(self):
"""change log format."""
self.logger.propagate = False
hdl = logging.StreamHandler()
fmt_str = '[querier][%(levelname)s] %(message)s'
hdl.setFormatter(logging.Formatter(fmt_str))
self.logger.addHandler(hdl) |
the process when the snooper received IGMP. | def packet_in_handler(self, req_pkt, req_igmp, msg):
"""the process when the snooper received IGMP."""
dpid = msg.datapath.id
ofproto = msg.datapath.ofproto
if ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
in_port = msg.in_port
else:
in_port = msg.match... |
the process when the snooper received a QUERY message. | def _do_query(self, query, iph, eth, in_port, msg):
"""the process when the snooper received a QUERY message."""
datapath = msg.datapath
dpid = datapath.id
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
# learn the querier.
self._to_querier[dpid] = {... |
the process when the snooper received a REPORT message. | def _do_report(self, report, in_port, msg):
"""the process when the snooper received a REPORT message."""
datapath = msg.datapath
dpid = datapath.id
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
if ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
... |
the process when the snooper received a LEAVE message. | def _do_leave(self, leave, in_port, msg):
"""the process when the snooper received a LEAVE message."""
datapath = msg.datapath
dpid = datapath.id
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
# check whether the querier port has been specified.
if n... |
the process when the snooper received a message of the outside for processing. | def _do_flood(self, in_port, msg):
"""the process when the snooper received a message of the
outside for processing. """
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
actions = [parser.OFPActionOutput(ofproto.OFPP_FLOOD)]
sel... |
the process when the QUERY from the querier timeout expired. | def _do_timeout_for_query(self, timeout, datapath):
"""the process when the QUERY from the querier timeout expired."""
dpid = datapath.id
hub.sleep(timeout)
outport = self._to_querier[dpid]['port']
remove_dsts = []
for dst in self._to_hosts[dpid]:
if not sel... |
the process when the QUERY from the switch timeout expired. | def _do_timeout_for_leave(self, timeout, datapath, dst, in_port):
"""the process when the QUERY from the switch timeout expired."""
parser = datapath.ofproto_parser
dpid = datapath.id
hub.sleep(timeout)
outport = self._to_querier[dpid]['port']
if self._to_hosts[dpid][ds... |
remove flow entries about the group and send a LEAVE message if exists. | def _remove_multicast_group(self, datapath, outport, dst):
"""remove flow entries about the group and send a LEAVE message
if exists."""
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
dpid = datapath.id
self._send_event(
EventMulticastGroupStateC... |
Syncs RT NLRIs for new and removed RTC_ASes. | def update_rtc_as_set(self):
"""Syncs RT NLRIs for new and removed RTC_ASes.
This method should be called when a neighbor is added or removed.
"""
# Compute the diffs in RTC_ASes
curr_rtc_as_set = self._neighbors_conf.rtc_as_set
# Always add local AS to RTC AS set
... |
Does book - keeping of local RT NLRIs based on all configured VRFs. | def update_local_rt_nlris(self):
"""Does book-keeping of local RT NLRIs based on all configured VRFs.
Syncs all import RTs and RT NLRIs.
The method should be called when any VRFs are added/removed/changed.
"""
current_conf_import_rts = set()
for vrf in self._vrfs_conf.vr... |
Computes current global interested RTs for global tables. | def _compute_global_interested_rts(self):
"""Computes current global interested RTs for global tables.
Computes interested RTs based on current RT filters for peers. This
filter should be used to check if for RTs on a path that is installed
in any global table (expect RT Table).
... |
Updates interested RT list. | def update_interested_rts(self):
"""Updates interested RT list.
Check if interested RTs have changes from previous check.
Takes appropriate action for new interesting RTs and removal of un-
interesting RTs.
"""
prev_global_rts = self._global_interested_rts
curr_g... |
Converts binary or int type representation to human readable IPv4 string.: param ip: binary or int type representation of IPv4 address: return: IPv4 address string | def ipv4_to_str(ip):
"""
Converts binary or int type representation to human readable IPv4 string.
:param ip: binary or int type representation of IPv4 address
:return: IPv4 address string
"""
if isinstance(ip, numbers.Integral):
return addrconv.ipv4.bin_to_text(struct.pack("!I", ip))
... |
Converts binary or int type representation to human readable IPv6 string.: param ip: binary or int type representation of IPv6 address: return: IPv6 address string | def ipv6_to_str(ip):
"""
Converts binary or int type representation to human readable IPv6 string.
:param ip: binary or int type representation of IPv6 address
:return: IPv6 address string
"""
if isinstance(ip, numbers.Integral):
return addrconv.ipv6.bin_to_text(type_desc.Int16.from_user... |
Converts binary representation to human readable IPv4 or IPv6 string.: param ip: binary representation of IPv4 or IPv6 address: return: IPv4 or IPv6 address string | def bin_to_text(ip):
"""
Converts binary representation to human readable IPv4 or IPv6 string.
:param ip: binary representation of IPv4 or IPv6 address
:return: IPv4 or IPv6 address string
"""
if len(ip) == 4:
return ipv4_to_str(ip)
elif len(ip) == 16:
return ipv6_to_str(ip)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.