INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
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... |
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 would looks like the ones described in
the following sections.
... | 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... |
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) |
Run a set of Ryu applications
A convenient method to load and instantiate apps.
This blocks until all relevant apps stop. | 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()
... |
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] |
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) |
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:
... |
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 handlers that are interested
... | 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... |
This method deletes an advertised Flow Specification route.
``flowspec_family`` specifies one of the flowspec family name.
``rules`` specifies NLRIs of Flow Specification as
a dictionary type value.
``route_dist`` specifies a route distinguisher value. | def flowspec_prefix_del(self, flowspec_family, rules, route_dist=None):
""" This method deletes an advertised Flow Specification route.
``flowspec_family`` specifies one of the flowspec family name.
``rules`` specifies NLRIs of Flow Specification as
a dictionary type value.
``... |
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(... |
This method returns the BGP adj-RIB-in/adj-RIB-out information
in a json format.
``route_type`` This parameter is necessary for only received-routes
and sent-routes.
- received-routes : paths received and not withdrawn by given peer
- sent-routes : paths sent and not withdrawn ... | def neighbor_get(self, route_type, address, format='json'):
""" This method returns the BGP adj-RIB-in/adj-RIB-out information
in a json format.
``route_type`` This parameter is necessary for only received-routes
and sent-routes.
- received-routes : paths received and not withd... |
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,
... |
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... |
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... |
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 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... |
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) |
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) |
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... |
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.
``route_family`` specifies route family of the VRF.
This parameter must be one of the following.
... | 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.
... |
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_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) |
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. | 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
... |
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... |
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) | 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... |
Decorator for registering API function.
Does not do any check or validation. | 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 |
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)
... |
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
(or a list of them) for which events should be genera... | 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
... |
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.") |
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,
... |
This method gets out-filter setting from the specified neighbor.
``address`` specifies the IP address of the peer.
Returns a list object containing an instance of Filter sub-class | def out_filter_get(self, address):
""" This method gets out-filter setting from the specified neighbor.
``address`` specifies the IP address of the peer.
Returns a list object containing an instance of Filter sub-class
"""
func_name = 'neighbor.out_filter.get'
param = ... |
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) |
Establish a new BFD session and return My Discriminator of new session.
Configure the BFD session with the following arguments.
================ ======================================================
Argument Description
================ ========================================... | 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... |
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:
... |
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... |
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 ... |
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 |
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... |
This method deletes an advertised EVPN route.
``route_type`` specifies one of the EVPN route type name.
``route_dist`` specifies a route distinguisher value.
``esi`` is an value to specify the Ethernet Segment Identifier.
``ethernet_tag_id`` specifies the Ethernet Tag ID.
``... | def evpn_prefix_del(self, route_type, route_dist, esi=0,
ethernet_tag_id=None, mac_addr=None, ip_addr=None,
ip_prefix=None):
""" This method deletes an advertised EVPN route.
``route_type`` specifies one of the EVPN route type name.
``route_dist`... |
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... |
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... |
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)
... |
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... |
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 automatically loaded.
This mechanism is used ... | 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... |
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::
>>> ofproto.ofp_error_code_to_str(4, 9)
'OFPB... | 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::
... |
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._... |
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
- `vrf_rf`: (str) route family of the VRF configuration
If only `route_dist` is given, removes `VrfCon... | 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... |
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::
>>> ofproto.ofp_error_to_jsondict(4, 9)
{'code'... | 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::
>... |
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... |
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... |
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) |
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.") |
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, ... |
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. | 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... |
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... |
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.
This method should be called when a neighbor is added or removed. | 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.
Syncs all import RTs and RT NLRIs.
The method should be called when any VRFs are added/removed/changed. | 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.
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). | 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.
Check if interested RTs have changes from previous check.
Takes appropriate action for new interesting RTs and removal of un-
interesting RTs. | 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)
... |
request <peer> <method> <params>
send a msgpack-rpc request and print a response.
<params> is a python code snippet, it should be eval'ed to a list. | def do_request(self, line):
"""request <peer> <method> <params>
send a msgpack-rpc request and print a response.
<params> is a python code snippet, it should be eval'ed to a list.
"""
def f(p, method, params):
result = p.call(method, params)
print("RESULT... |
notify <peer> <method> <params>
send a msgpack-rpc notification.
<params> is a python code snippet, it should be eval'ed to a list. | def do_notify(self, line):
"""notify <peer> <method> <params>
send a msgpack-rpc notification.
<params> is a python code snippet, it should be eval'ed to a list.
"""
def f(p, method, params):
p.send_notification(method, params)
self._request(line, f) |
Returns a dict expressing the flow match. | def to_jsondict(self):
"""
Returns a dict expressing the flow match.
"""
# XXX old api compat
if self._composed_with_old_api():
# copy object first because serialize_old is destructive
o2 = OFPMatch()
o2.fields = self.fields[:]
# se... |
Returns an object which is generated from a dict.
Exception raises:
KeyError -- Unknown match field is defined in dict | def from_jsondict(cls, dict_):
"""
Returns an object which is generated from a dict.
Exception raises:
KeyError -- Unknown match field is defined in dict
"""
fields = [ofproto.oxm_from_jsondict(f) for f
in dict_['oxm_fields']]
o = OFPMatch(_orde... |
Append a match field.
========= =======================================================
Argument Description
========= =======================================================
header match field header ID which is defined automatically in
``ofproto``
value ... | def append_field(self, header, value, mask=None):
"""
Append a match field.
========= =======================================================
Argument Description
========= =======================================================
header match field header ID which is ... |
This method evaluates attributes of the path.
Returns the cause and result of matching.
Both cause and result are returned from filters
that this object contains.
``path`` specifies the path. | def evaluate(self, path):
""" This method evaluates attributes of the path.
Returns the cause and result of matching.
Both cause and result are returned from filters
that this object contains.
``path`` specifies the path.
"""
result = False
cause = None
... |
This method clones AttributeMap object.
Returns AttributeMap object that has the same values with the
original one. | def clone(self):
""" This method clones AttributeMap object.
Returns AttributeMap object that has the same values with the
original one.
"""
cloned_filters = [f.clone() for f in self.filters]
return self.__class__(cloned_filters, self.attr_type, self.attr_value) |
Returns total number of UPDATE, NOTIFICATION and ROUTE_REFRESH
message sent to this peer. | def total_msg_sent(self):
"""Returns total number of UPDATE, NOTIFICATION and ROUTE_REFRESH
message sent to this peer.
"""
return (self.get_count(PeerCounterNames.SENT_REFRESH) +
self.get_count(PeerCounterNames.SENT_UPDATES)) |
Returns total number of UPDATE, NOTIFICATION and ROUTE_REFRESH
messages received from this peer. | def total_msg_recv(self):
"""Returns total number of UPDATE, NOTIFICATION and ROUTE_REFRESH
messages received from this peer.
"""
return (self.get_count(PeerCounterNames.RECV_UPDATES) +
self.get_count(PeerCounterNames.RECV_REFRESH) +
self.get_count(PeerCou... |
Returns basic stats.
Returns a `dict` with various counts and stats, see below. | def get_stats_summary_dict(self):
"""Returns basic stats.
Returns a `dict` with various counts and stats, see below.
"""
uptime = time.time() - self._established_time \
if self._established_time != 0 else -1
return {
stats.UPDATE_MSG_IN: self.get_count(Pe... |
Implements neighbor configuration change listener. | def on_update_enabled(self, conf_evt):
"""Implements neighbor configuration change listener.
"""
enabled = conf_evt.value
# If we do not have any protocol bound and configuration asks us to
# enable this peer, we try to establish connection again.
if enabled:
... |
Sends given message `rr_msg` to peer.
Parameters:
- rr_msg: (RouteRefresh) route refresh message to send to peer.
Update appropriate counters and set appropriate timers. | def _send_outgoing_route_refresh_msg(self, rr_msg):
"""Sends given message `rr_msg` to peer.
Parameters:
- rr_msg: (RouteRefresh) route refresh message to send to peer.
Update appropriate counters and set appropriate timers.
"""
assert rr_msg.type == BGP_MSG_ROUTE_R... |
Constructs `Update` message from given `outgoing_route` and sends
it to peer.
Also, checks if any policies prevent sending this message.
Populates Adj-RIB-out with corresponding `SentRoute`. | def _send_outgoing_route(self, outgoing_route):
"""Constructs `Update` message from given `outgoing_route` and sends
it to peer.
Also, checks if any policies prevent sending this message.
Populates Adj-RIB-out with corresponding `SentRoute`.
"""
path = outgoing_route.pa... |
Request route refresh to peer for given `route_families`.
If no `route_families` are given, we make request for all supported
route families with this peer.
Parameters:
- `route_families`: list of route families to request route
refresh for.
If this peer is cu... | def request_route_refresh(self, *route_families):
"""Request route refresh to peer for given `route_families`.
If no `route_families` are given, we make request for all supported
route families with this peer.
Parameters:
- `route_families`: list of route families to reque... |
Returns nexthop address relevant to current session
Nexthop used can depend on capabilities of the session. If VPNv6
capability is active and session is on IPv4 connection, we have to use
IPv4 mapped IPv6 address. In other cases we can use connection end
point/local ip address. | def _session_next_hop(self, path):
"""Returns nexthop address relevant to current session
Nexthop used can depend on capabilities of the session. If VPNv6
capability is active and session is on IPv4 connection, we have to use
IPv4 mapped IPv6 address. In other cases we can use connectio... |
Marge AS_PATH and AS4_PATH attribute instances into
a single AS_PATH instance. | def _construct_as_path_attr(self, as_path_attr, as4_path_attr):
"""Marge AS_PATH and AS4_PATH attribute instances into
a single AS_PATH instance."""
def _listify(li):
"""Reconstruct AS_PATH list.
Example::
>>> _listify([[1, 2, 3], {4, 5}, [6, 7]])
... |
Translates Four-Octet AS number to AS_TRANS and separates
AS_PATH list into AS_PATH and AS4_PATH lists if needed.
If the neighbor does not support Four-Octet AS number,
this method constructs AS4_PATH list from AS_PATH list and swaps
non-mappable AS number in AS_PATH with AS_TRANS, then... | def _trans_as_path(self, as_path_list):
"""Translates Four-Octet AS number to AS_TRANS and separates
AS_PATH list into AS_PATH and AS4_PATH lists if needed.
If the neighbor does not support Four-Octet AS number,
this method constructs AS4_PATH list from AS_PATH list and swaps
no... |
Construct update message with Outgoing-routes path attribute
appropriately cloned/copied/updated. | def _construct_update(self, outgoing_route):
"""Construct update message with Outgoing-routes path attribute
appropriately cloned/copied/updated.
"""
update = None
path = outgoing_route.path
# Get copy of path's path attributes.
pathattr_map = path.pathattr_map
... |
In the current greenlet we try to establish connection with peer.
This greenlet will spin another greenlet to handle incoming data
from the peer once connection is established. | def _connect_loop(self, client_factory):
"""In the current greenlet we try to establish connection with peer.
This greenlet will spin another greenlet to handle incoming data
from the peer once connection is established.
"""
# If current configuration allow, enable active sessio... |
Tries to bind given protocol to this peer.
Should only be called by `proto` trying to bind.
Once bound this protocol instance will be used to communicate with
peer. If another protocol is already bound, connection collision
resolution takes place. | def bind_protocol(self, proto):
"""Tries to bind given protocol to this peer.
Should only be called by `proto` trying to bind.
Once bound this protocol instance will be used to communicate with
peer. If another protocol is already bound, connection collision
resolution takes pla... |
Create `Open` message using current settings.
Current setting include capabilities, timers and ids. | def create_open_msg(self):
"""Create `Open` message using current settings.
Current setting include capabilities, timers and ids.
"""
asnum = self.local_as
# If local AS number is not Two-Octet AS number, swaps with AS_TRANS.
if not is_valid_old_asn(asnum):
a... |
Validate update message as per RFC.
Here we validate the message after it has been parsed. Message
has already been validated against some errors inside parsing
library. | def _validate_update_msg(self, update_msg):
"""Validate update message as per RFC.
Here we validate the message after it has been parsed. Message
has already been validated against some errors inside parsing
library.
"""
# TODO(PH): finish providing implementation, curre... |
Extracts and processes new paths or withdrawals in given
`update_msg`.
Parameter:
- `update_msg`: update message to process.
- `valid_rts`: current valid/interesting rts to the application
according to configuration of all VRFs.
Assumes Multiprotocol Extensi... | def _handle_update_msg(self, update_msg):
"""Extracts and processes new paths or withdrawals in given
`update_msg`.
Parameter:
- `update_msg`: update message to process.
- `valid_rts`: current valid/interesting rts to the application
according to configurati... |
Extracts advertised AS path attributes in the given update message
and reconstructs AS_PATH from AS_PATH and AS4_PATH if needed. | def _extract_and_reconstruct_as_path(self, update_msg):
"""Extracts advertised AS path attributes in the given update message
and reconstructs AS_PATH from AS_PATH and AS4_PATH if needed."""
umsg_pattrs = update_msg.pathattr_map
as_aggregator = umsg_pattrs.get(BGP_ATTR_TYPE_AGGREGATOR, ... |
Extracts path attributes from the given UPDATE message and checks
if the given attributes have loops or not.
:param update_msg: UPDATE message instance.
:return: True if attributes have loops. Otherwise False. | def _is_looped_path_attrs(self, update_msg):
"""
Extracts path attributes from the given UPDATE message and checks
if the given attributes have loops or not.
:param update_msg: UPDATE message instance.
:return: True if attributes have loops. Otherwise False.
"""
... |
Extracts new paths advertised in the given update message's
*MpReachNlri* attribute.
Assumes MPBGP capability is enabled and message was validated.
Parameters:
- update_msg: (Update) is assumed to be checked for all bgp
message errors.
- valid_rts: (iterable... | def _extract_and_handle_bgp4_new_paths(self, update_msg):
"""Extracts new paths advertised in the given update message's
*MpReachNlri* attribute.
Assumes MPBGP capability is enabled and message was validated.
Parameters:
- update_msg: (Update) is assumed to be checked for a... |
Extracts withdraws advertised in the given update message's
*MpUnReachNlri* attribute.
Assumes MPBGP capability is enabled.
Parameters:
- update_msg: (Update) is assumed to be checked for all bgp
message errors.
Extracted withdraws are added to appropriate *Des... | def _extract_and_handle_bgp4_withdraws(self, withdraw_list):
"""Extracts withdraws advertised in the given update message's
*MpUnReachNlri* attribute.
Assumes MPBGP capability is enabled.
Parameters:
- update_msg: (Update) is assumed to be checked for all bgp
me... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.