INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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 | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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... |
Extracts new paths advertised in the given update message s * MpReachNlri * attribute. | def _extract_and_handle_mpbgp_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 ... |
Extracts withdraws advertised in the given update message s * MpUnReachNlri * attribute. | def _extract_and_handle_mpbgp_withdraws(self, mp_unreach_attr):
"""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
... |
Currently we only handle EOR for RTC address - family. | def _handle_eor(self, route_family):
"""Currently we only handle EOR for RTC address-family.
We send non-rtc initial updates if not already sent.
"""
LOG.debug('Handling EOR for %s', route_family)
# assert (route_family in SUPPORTED_GLOBAL_RF)
# assert self.is_mbgp_cap_v... |
BGP message handler. | def handle_msg(self, msg):
"""BGP message handler.
BGP message handling is shared between protocol instance and peer. Peer
only handles limited messages under suitable state. Here we handle
KEEPALIVE, UPDATE and ROUTE_REFRESH messages. UPDATE and ROUTE_REFRESH
messages are handl... |
Enqueues Enhanced RR EOR if for given SOR a EOR is not already sent. | def _enqueue_eor_msg(self, sor):
"""Enqueues Enhanced RR EOR if for given SOR a EOR is not already
sent.
"""
if self._protocol.is_enhanced_rr_cap_valid() and not sor.eor_sent:
afi = sor.afi
safi = sor.safi
eor = BGPRouteRefresh(afi, safi, demarcation=2... |
Setup timer for sending best - paths for all other address - families that qualify. | def _schedule_sending_init_updates(self):
"""Setup timer for sending best-paths for all other address-families
that qualify.
Setup timer for sending initial updates to peer.
"""
def _enqueue_non_rtc_init_updates():
LOG.debug('Scheduled queuing of initial Non-RTC UPD... |
Un - schedules sending of initial updates | def _unschedule_sending_init_updates(self):
"""Un-schedules sending of initial updates
Stops the timer if set for sending initial updates.
Returns:
- True if timer was stopped
- False if timer was already stopped and nothing was done
"""
LOG.debug('Un-sch... |
Enqueues current routes to be shared with this peer. | def _enqueue_init_updates(self):
"""Enqueues current routes to be shared with this peer."""
assert self.state.bgp_state == const.BGP_FSM_ESTABLISHED
if self.is_mbgp_cap_valid(RF_RTC_UC):
# Enqueues all best-RTC_NLRIs to be sent as initial update to this
# peer.
... |
Shares/ communicates current best paths with this peers. | def comm_all_best_paths(self, global_tables):
"""Shares/communicates current best paths with this peers.
Can be used to send initial updates after we have established session
with `peer`.
"""
LOG.debug('Communicating current best path for all afi/safi except'
'... |
Communicates path to this peer if it qualifies. | def communicate_path(self, path):
"""Communicates `path` to this peer if it qualifies.
Checks if `path` should be shared/communicated with this peer according
to various conditions: like bgp state, transmit side loop, local and
remote AS path, community attribute, etc.
"""
... |
Protocols connection established handler | def connection_made(self):
"""Protocols connection established handler
"""
LOG.info(
'Connection to peer: %s established',
self._neigh_conf.ip_address,
extra={
'resource_name': self._neigh_conf.name,
'resource_id': self._neigh_c... |
Protocols connection lost handler. | def connection_lost(self, reason):
"""Protocols connection lost handler.
"""
LOG.info(
'Connection to peer %s lost, reason: %s Resetting '
'retry connect loop: %s' %
(self._neigh_conf.ip_address, reason,
self._connect_retry_event.is_set()),
... |
Check if * local_as * is already present on path list. | def has_local_as(self, local_as, max_count=0):
"""Check if *local_as* is already present on path list."""
_count = 0
for as_path_seg in self.value:
_count += list(as_path_seg).count(local_as)
return _count > max_count |
Check if leftmost AS matches * remote_as *. | def has_matching_leftmost(self, remote_as):
"""Check if leftmost AS matches *remote_as*."""
if not self.value or not remote_as:
return False
leftmost_seg = self.path_seg_list[0]
if leftmost_seg and leftmost_seg[0] == remote_as:
return True
return False |
Runs a command in an out - of - process shell returning the output of that command. Working directory is ROOT. | def run_command(cmd, redirect_output=True, check_exit_code=True):
"""
Runs a command in an out-of-process shell, returning the
output of that command. Working directory is ROOT.
"""
if redirect_output:
stdout = subprocess.PIPE
else:
stdout = None
proc = subprocess.Popen(cmd,... |
Creates the virtual environment and installs PIP only into the virtual environment | def create_virtualenv(venv=VENV, install_pip=False):
"""Creates the virtual environment and installs PIP only into the
virtual environment
"""
print 'Creating venv...',
install = ['virtualenv', '-q', venv]
run_command(install)
print 'done.'
print 'Installing pip in virtualenv...',
... |
Example: To get datapath_id from Bridge table get_column_value ( Bridge <bridge name > datapath_id ). strip ( ) | def get_column_value(manager, table, record, column):
"""
Example : To get datapath_id from Bridge table
get_column_value('Bridge', <bridge name>, 'datapath_id').strip('"')
"""
row = row_by_name(manager, record, table)
value = getattr(row, column, "")
if isinstance(value, list) and len(valu... |
Creates a new BGPSpeaker instance. | def add_speaker(self, **kwargs):
"""
Creates a new BGPSpeaker instance.
Usage:
======= ================
Method URI
======= ================
POST /vtep/speakers
======= ================
Request parameters:
===... |
Gets the info of BGPSpeaker instance. | def get_speakers(self, **kwargs):
"""
Gets the info of BGPSpeaker instance.
Usage:
======= ================
Method URI
======= ================
GET /vtep/speakers
======= ================
Example::
$ curl -X... |
Deletes the network for the specified VNI. | def del_network(self, **kwargs):
"""
Deletes the network for the specified VNI.
Usage:
======= =====================
Method URI
======= =====================
DELETE /vtep/networks/{vni}
======= =====================
Request... |
Registers a new client to the specified network. | def del_client(self, **kwargs):
"""
Registers a new client to the specified network.
Usage:
======= ===================================
Method URI
======= ===================================
DELETE /vtep/networks/{vni}/clients/{mac}
... |
Imports VPNv4/ 6 or EVPN paths from Global/ VPN table into given VRFv4/ 6 or VRFEVPN table.: param vrf_table: Vrf table to which we import: type vrf_table: VrfTable: param import_rts: import RTs to override default import_rts of vrf table for this import: type import_rts: set of strings | def import_all_vpn_paths_to_vrf(self, vrf_table, import_rts=None):
"""Imports VPNv4/6 or EVPN paths from Global/VPN table into given
VRFv4/6 or VRFEVPN table.
:param vrf_table: Vrf table to which we import
:type vrf_table: VrfTable
:param import_rts: import RTs to override defau... |
Inserts path into correct global table. | def learn_path(self, path):
"""Inserts `path` into correct global table.
Since known paths to `Destination` has changes, we queue it for further
processing.
"""
# Get VPN/Global table
table = self.get_global_table_by_route_family(path.route_family)
gpath_dest = t... |
Records sent_route inside proper table. | def remember_sent_route(self, sent_route):
"""Records `sent_route` inside proper table.
Records of `sent_route` from Adj-RIB-out.
"""
route_family = sent_route.path.route_family
table = self.get_global_table_by_route_family(route_family)
table.insert_sent_route(sent_rout... |
Update global tables as interested RTs changed. | def on_interesting_rts_change(self, new_global_rts, removed_global_rts):
"""Update global tables as interested RTs changed.
Adds `new_rts` and removes `removed_rts` rt nlris. Does not check if
`new_rts` or `removed_rts` are already present. Schedules refresh
request to peers that do not... |
Returns global IPv4 table. | def get_ipv4_table(self):
"""Returns global IPv4 table.
Creates the table if it does not exist.
"""
vpn_table = self._global_tables.get(RF_IPv4_UC)
# Lazy initialize the table.
if not vpn_table:
vpn_table = Ipv4Table(self._core_service, self._signal_bus)
... |
Returns global VPNv6 table. | def get_vpn6_table(self):
"""Returns global VPNv6 table.
Creates the table if it does not exist.
"""
vpn_table = self._global_tables.get(RF_IPv6_VPN)
# Lazy initialize the table.
if not vpn_table:
vpn_table = Vpnv6Table(self._core_service, self._signal_bus)
... |
Returns global VPNv6 table. | def get_vpn4_table(self):
"""Returns global VPNv6 table.
Creates the table if it does not exist.
"""
vpn_table = self._global_tables.get(RF_IPv4_VPN)
# Lazy initialize the table.
if not vpn_table:
vpn_table = Vpnv4Table(self._core_service, self._signal_bus)
... |
Returns global EVPN table. | def get_evpn_table(self):
"""Returns global EVPN table.
Creates the table if it does not exist.
"""
evpn_table = self._global_tables.get(RF_L2_EVPN)
# Lazy initialization of the table.
if not evpn_table:
evpn_table = EvpnTable(self._core_service, self._signal... |
Returns global RTC table. | def get_rtc_table(self):
"""Returns global RTC table.
Creates the table if it does not exist.
"""
rtc_table = self._global_tables.get(RF_RTC_UC)
# Lazy initialization of the table.
if not rtc_table:
rtc_table = RtcTable(self._core_service, self._signal_bus)
... |
Returns global IPv4 Flow Specification table. | def get_ipv4fs_table(self):
"""Returns global IPv4 Flow Specification table.
Creates the table if it does not exist.
"""
ipv4fs_table = self._global_tables.get(RF_IPv4_FLOWSPEC)
# Lazy initialization of the table.
if not ipv4fs_table:
ipv4fs_table = IPv4FlowS... |
Returns global IPv6 Flow Specification table. | def get_ipv6fs_table(self):
"""Returns global IPv6 Flow Specification table.
Creates the table if it does not exist.
"""
ipv6fs_table = self._global_tables.get(RF_IPv6_FLOWSPEC)
# Lazy initialization of the table.
if not ipv6fs_table:
ipv6fs_table = IPv6FlowS... |
Returns global VPNv4 Flow Specification table. | def get_vpnv4fs_table(self):
"""Returns global VPNv4 Flow Specification table.
Creates the table if it does not exist.
"""
vpnv4fs_table = self._global_tables.get(RF_VPNv4_FLOWSPEC)
# Lazy initialization of the table.
if not vpnv4fs_table:
vpnv4fs_table = VPN... |
Returns global VPNv6 Flow Specification table. | def get_vpnv6fs_table(self):
"""Returns global VPNv6 Flow Specification table.
Creates the table if it does not exist.
"""
vpnv6fs_table = self._global_tables.get(RF_VPNv6_FLOWSPEC)
# Lazy initialization of the table.
if not vpnv6fs_table:
vpnv6fs_table = VPN... |
Returns global L2VPN Flow Specification table. | def get_l2vpnfs_table(self):
"""Returns global L2VPN Flow Specification table.
Creates the table if it does not exist.
"""
l2vpnfs_table = self._global_tables.get(RF_L2VPN_FLOWSPEC)
# Lazy initialization of the table.
if not l2vpnfs_table:
l2vpnfs_table = L2V... |
Update mapping from RT to VRF table. | def update_vrf_table_links(self, vrf_table, new_imp_rts,
removed_imp_rts):
"""Update mapping from RT to VRF table."""
assert vrf_table
if new_imp_rts:
self._link_vrf_table(vrf_table, new_imp_rts)
if removed_imp_rts:
self._remove_link... |
Re - installs paths from NC with current BGP policy. | def re_install_net_ctrl_paths(self, vrf_table):
"""Re-installs paths from NC with current BGP policy.
Iterates over known paths from NC installed in `vrf4_table` and
adds new path with path attributes as per current VRF configuration.
"""
assert vrf_table
for dest in vrf... |
Removes any links to given vrf_table. | def _remove_links_to_vrf_table(self, vrf_table):
"""Removes any links to given `vrf_table`."""
assert vrf_table
vrf_conf = vrf_table.vrf_conf
self._remove_links_to_vrf_table_for_rts(vrf_table,
vrf_conf.import_rts) |
Factory method to create VRF table for given vrf_conf. | def create_and_link_vrf_table(self, vrf_conf):
"""Factory method to create VRF table for given `vrf_conf`.
Adds mapping to this table with appropriate scope. Also, adds mapping
for import RT of this VRF to created table to facilitate
importing/installing of paths from global tables.
... |
Marks paths that do not have any route targets of interest for withdrawal. | def _clean_global_uninteresting_paths(self):
"""Marks paths that do not have any route targets of interest
for withdrawal.
Since global tables can have paths with route targets that are not
interesting any more, we have to clean these paths so that appropriate
withdraw are sent ... |
Imports * vpn_path * to qualifying VRF tables. | def import_single_vpn_path_to_all_vrfs(self, vpn_path, path_rts=None):
"""Imports *vpn_path* to qualifying VRF tables.
Import RTs of VRF table is matched with RTs from *vpn4_path* and if we
have any common RTs we import the path into VRF.
"""
LOG.debug('Importing path %s to qual... |
Update a BGP route in the VRF table identified by route_dist with the given next_hop. | def update_vrf_table(self, route_dist, prefix=None, next_hop=None,
route_family=None, route_type=None, tunnel_type=None,
is_withdraw=False, redundancy_mode=None,
pmsi_tunnel_type=None, **kwargs):
"""Update a BGP route in the VRF table id... |
Update a BGP route in the VRF table for Flow Specification. | def update_flowspec_vrf_table(self, flowspec_family, route_dist, rules,
actions=None, is_withdraw=False):
"""Update a BGP route in the VRF table for Flow Specification.
``flowspec_family`` specifies one of the flowspec family name.
``route_dist`` specifies a r... |
Update a BGP route in the Global table for the given prefix with the given next_hop. | def update_global_table(self, prefix, next_hop=None, is_withdraw=False):
"""Update a BGP route in the Global table for the given `prefix`
with the given `next_hop`.
If `is_withdraw` is False, which is the default, add a BGP route
to the Global table.
If `is_withdraw` is True, re... |
Update a BGP route in the Global table for Flow Specification. | def update_flowspec_global_table(self, flowspec_family, rules,
actions=None, is_withdraw=False):
"""Update a BGP route in the Global table for Flow Specification.
``flowspec_family`` specifies one of the Flow Specification
family name.
``rules`` sp... |
Removes old routes from peer from route_family table. | def clean_stale_routes(self, peer, route_family=None):
"""Removes old routes from `peer` from `route_family` table.
Routes/paths version number is compared with `peer`s current version
number.
"""
if route_family is not None:
if route_family not in SUPPORTED_GLOBAL_... |
: returns: old port if learned. ( this may be = port ) None otherwise | def port_add(self, dpid, port, mac):
"""
:returns: old port if learned. (this may be = port)
None otherwise
"""
old_port = self.mac_to_port[dpid].get(mac, None)
self.mac_to_port[dpid][mac] = port
if old_port is not None and old_port != port:
... |
class decorator to Register mf make | def _register_make(cls):
'''class decorator to Register mf make'''
assert cls.nxm_headers is not None
assert cls.nxm_headers is not []
for nxm_header in cls.nxm_headers:
assert nxm_header not in _MF_FIELDS
_MF_FIELDS[nxm_header] = cls.make
return cls |
return a tuple which can be used as * args for ofproto_v1_0_parser. OFPMatch. __init__ (). see Datapath. send_flow_mod. | def match_tuple(self):
"""return a tuple which can be used as *args for
ofproto_v1_0_parser.OFPMatch.__init__().
see Datapath.send_flow_mod.
"""
assert self.flow_format() == ofproto_v1_0.NXFF_OPENFLOW10
wildcards = ofproto_v1_0.OFPFW_ALL
if not self.wc.wildcards ... |
This function provides the backward compatibility for imp. load_source in Python 2. | def load_source(name, pathname):
"""
This function provides the backward compatibility for 'imp.load_source'
in Python 2.
:param name: Name used to create or access a module object.
:param pathname: Path pointing to the source file.
:return: Loaded and initialized module.
"""
if six.PY2... |
Splits a str of IP address and port pair into ( host port ). | def _split_addr(addr):
"""
Splits a str of IP address and port pair into (host, port).
Example::
>>> _split_addr('127.0.0.1:6653')
('127.0.0.1', 6653)
>>> _split_addr('[::1]:6653')
('::1', 6653)
Raises ValueError if invalid format.
:param addr: A pair of IP addres... |
: type packet: ryu. lib. packet. packet. Packet: param packet:: type vlan_id: int ( 0 < = vlan_id < = 4095 ) or None ( = No VLAN ): param vlan_id: | def may_add_vlan(packet, vlan_id):
"""
:type packet: ryu.lib.packet.packet.Packet
:param packet:
:type vlan_id: int (0 <= vlan_id <= 4095) or None (= No VLAN)
:param vlan_id:
"""
if vlan_id is None:
return
e = packet.protocols[0]
assert isinstance(e, ethernet.ethernet)
v... |
: type dpid: datapath id: param dpid:: rtype: ryu. controller. controller. Datapath: returns: datapath corresponding to dpid | def get_dp(app, dpid):
"""
:type dpid: datapath id
:param dpid:
:rtype: ryu.controller.controller.Datapath
:returns: datapath corresponding to dpid
"""
switches = topo_api.get_switch(app, dpid)
if not switches:
return None
assert len(switches) == 1
return switches[0].dp |
Clones given RT NLRI path and updates it with new RT_NLRI AS. | def clone_rtcpath_update_rt_as(path, new_rt_as):
"""Clones given RT NLRI `path`, and updates it with new RT_NLRI AS.
Parameters:
- `path`: (Path) RT_NLRI path
- `new_rt_as`: AS value of cloned paths' RT_NLRI
"""
assert path and new_rt_as
if not path or path.route_family ... |
Convert an IPv4 address string format to a four byte long. | def from_inet_ptoi(bgp_id):
"""Convert an IPv4 address string format to a four byte long.
"""
four_byte_id = None
try:
four_byte_id = ip.ipv4_to_int(bgp_id)
except ValueError:
LOG.debug('Invalid bgp id given for conversion to integer value %s',
bgp_id)
return f... |
Utility method that gives a dict of unknown and unsupported optional transitive path attributes of path. | def get_unknown_opttrans_attr(path):
"""Utility method that gives a `dict` of unknown and unsupported optional
transitive path attributes of `path`.
Returns dict: <key> - attribute type code, <value> - unknown path-attr.
"""
path_attrs = path.pathattr_map
unknown_opt_tran_attrs = {}
for _, ... |
Construct end - of - rib ( EOR ) Update instance. | def create_end_of_rib_update():
"""Construct end-of-rib (EOR) Update instance."""
mpunreach_attr = BGPPathAttributeMpUnreachNLRI(RF_IPv4_VPN.afi,
RF_IPv4_VPN.safi,
[])
eor = BGPUpdate(path_attributes=[mpunr... |
Creates an instance of the BGP Route Target Community ( if subtype = 2 ) or Route Origin Community ( subtype = 3 ). | def create_rt_extended_community(value, subtype=2):
"""
Creates an instance of the BGP Route Target Community (if "subtype=2")
or Route Origin Community ("subtype=3").
:param value: String of Route Target or Route Origin value.
:param subtype: Subtype of Extended Community.
:return: An instance... |
Create list of traffic filtering actions for Ipv4 Flow Specification and VPNv4 Flow Specification. | def create_v4flowspec_actions(actions=None):
"""
Create list of traffic filtering actions
for Ipv4 Flow Specification and VPNv4 Flow Specification.
`` actions`` specifies Traffic Filtering Actions of
Flow Specification as a dictionary type value.
Returns a list of extended community values.
... |
Create list of traffic filtering actions for L2VPN Flow Specification. | def create_l2vpnflowspec_actions(actions=None):
"""
Create list of traffic filtering actions for L2VPN Flow Specification.
"""
from ryu.services.protocols.bgp.api.prefix import (
FLOWSPEC_ACTION_TRAFFIC_RATE,
FLOWSPEC_ACTION_TRAFFIC_ACTION,
FLOWSPEC_ACTION_REDIRECT,
FLOWS... |
Override method for the Length/ Type field ( self. ethertype ). The Length/ Type field means Length or Type interpretation same as ethernet IEEE802. 3. If the value of Length/ Type field is less than or equal to 1500 decimal ( 05DC hexadecimal ) it means Length interpretation and be passed to the LLC sublayer. | def get_packet_type(cls, type_):
"""Override method for the Length/Type field (self.ethertype).
The Length/Type field means Length or Type interpretation,
same as ethernet IEEE802.3.
If the value of Length/Type field is less than or equal to
1500 decimal(05DC hexadecimal), it mea... |
Decorator for wrapping the given function in order to manipulate ( CRUD ) the records safely. | def sql_function(func):
"""
Decorator for wrapping the given function in order to manipulate (CRUD)
the records safely.
For the adding/updating/deleting records function, this decorator
invokes "Session.commit()" after the given function.
If any exception while modifying records raised, this de... |
Send an OpenFlow message and wait for reply messages. | def send_msg(app, msg, reply_cls=None, reply_multi=False):
"""
Send an OpenFlow message and wait for reply messages.
:param app: Client RyuApp instance
:param msg: An OpenFlow controller-to-switch message to send
:param reply_cls: OpenFlow message class for expected replies.
None means no r... |
Starts new context using provided configuration. | def start(**kwargs):
"""Starts new context using provided configuration.
Raises RuntimeConfigError if a context is already active.
"""
if CORE_MANAGER.started:
raise RuntimeConfigError('Current context has to be stopped to start '
'a new context.')
try:
... |
Validates the given ip for use as RPC server address. | def validate_rpc_host(ip):
"""
Validates the given ip for use as RPC server address.
"""
if not is_valid_ipv4(ip) and not is_valid_ipv6(ip):
raise ApplicationException(
desc='Invalid RPC ip address: %s' % ip)
return ip |
Validates the given file for use as the settings file for BGPSpeaker and loads the configuration from the given file as a module instance. | def load_config(config_file):
"""
Validates the given file for use as the settings file for BGPSpeaker
and loads the configuration from the given file as a module instance.
"""
if not config_file or not os.path.isfile(config_file):
raise ApplicationException(
desc='Invalid config... |
Starts BGPSpeaker using the given settings. | def _start_speaker(self, settings):
"""
Starts BGPSpeaker using the given settings.
"""
# Check required settings.
_required_settings = (
LOCAL_AS,
ROUTER_ID,
)
for required in _required_settings:
if required not in settings:
... |
Add BGP neighbors from the given settings. | def _add_neighbors(self, settings):
"""
Add BGP neighbors from the given settings.
All valid neighbors are loaded.
Miss-configured neighbors are ignored and errors are logged.
"""
for neighbor_settings in settings:
LOG.debug('Adding neighbor settings: %s', ne... |
Add BGP VRFs from the given settings. | def _add_vrfs(self, settings):
"""
Add BGP VRFs from the given settings.
All valid VRFs are loaded.
Miss-configured VRFs are ignored and errors are logged.
"""
for vrf_settings in settings:
LOG.debug('Adding VRF settings: %s', vrf_settings)
try:
... |
Add BGP routes from given settings. | def _add_routes(self, settings):
"""
Add BGP routes from given settings.
All valid routes are loaded.
Miss-configured routes are ignored and errors are logged.
"""
for route_settings in settings:
if 'prefix' in route_settings:
prefix_add = sel... |
Returns True if the given addr is valid OVSDB server address otherwise False. | def valid_ovsdb_addr(addr):
"""
Returns True if the given addr is valid OVSDB server address, otherwise
False.
The valid formats are:
- ``unix:file``
- ``tcp:ip:port``
- ``ssl:ip:port``
If ip is IPv6 address, wrap ip with brackets (e.g., ssl:[::1]:6640).
:param addr: str value of... |
: type settings: list of ( column value_json ) where column is str value_json is json that is represented by Datum. to_json () | def add_port(self, br_name, port_name, may_exist, fake_iface,
iface_names, settings=None):
"""
:type settings: list of (column, value_json)
where column is str,
value_json is json that is represented
... |
Parses setting_string as str formatted in <column > [: <key > ] and returns str type column and key | def parse_column_key(setting_string):
"""
Parses 'setting_string' as str formatted in <column>[:<key>]
and returns str type 'column' and 'key'
"""
if ':' in setting_string:
# splits <column>:<key> into <column> and <key>
column, key = setting_string.split(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.