INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
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_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.
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_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.
We send non-rtc initial updates if not already sent. | 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.
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 handled only after session is established. | 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.
Setup timer for sending initial updates to peer. | 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
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 | 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.
Can be used to send initial updates after we have established session
with `peer`. | 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.
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. | 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 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,... |
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 |
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.
Usage:
======= ================
Method URI
======= ================
POST /vtep/speakers
======= ================
Request parameters:
========== ============================================
... | def add_speaker(self, **kwargs):
"""
Creates a new BGPSpeaker instance.
Usage:
======= ================
Method URI
======= ================
POST /vtep/speakers
======= ================
Request parameters:
===... |
Gets the info of BGPSpeaker instance.
Usage:
======= ================
Method URI
======= ================
GET /vtep/speakers
======= ================
Example::
$ curl -X GET http://localhost:8080/vtep/speakers |
... | 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.
Usage:
======= =====================
Method URI
======= =====================
DELETE /vtep/networks/{vni}
======= =====================
Request parameters:
================ ==========... | 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.
Usage:
======= ===================================
Method URI
======= ===================================
DELETE /vtep/networks/{vni}/clients/{mac}
======= ===================================
... | 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: ... | 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.
Since known paths to `Destination` has changes, we queue it for further
processing. | 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.
Records of `sent_route` from Adj-RIB-out. | 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.
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 participate in RTC address-family. | 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.
Creates the table if it does not exist. | 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.
Creates the table if it does not exist. | 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.
Creates the table if it does not exist. | 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.
Creates the table if it does not exist. | 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.
Creates the table if it does not exist. | 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.
Creates the table if it does not exist. | 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.
Creates the table if it does not exist. | 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.
Creates the table if it does not exist. | 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.
Creates the table if it does not exist. | 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.
Creates the table if it does not exist. | 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.
Iterates over known paths from NC installed in `vrf4_table` and
adds new path with path attributes as per current VRF configuration. | 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`.
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.
Returns created table. | 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.
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 out to NC and other peers. Interesting route targets
... | 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.
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. | 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`.
If `is_withdraw` is False, which is the default, add a BGP route
to the VRF table identified by `route_dist` with the given
`next_hop`.
If `is_withdraw` is True, remove a BGP route from the... | 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.
``flowspec_family`` specifies one of the flowspec family name.
``route_dist`` specifies a route distinguisher value.
``rules`` specifies NLRIs of Flow Specification as
a dictionary type value.
`` actions`` specifies ... | 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`.
If `is_withdraw` is False, which is the default, add a BGP route
to the Global table.
If `is_withdraw` is True, remove a BGP route from the Global table. | 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.
``flowspec_family`` specifies one of the Flow Specification
family name.
``rules`` specifies NLRIs of Flow Specification as
a dictionary type value.
`` actions`` specifies Traffic Filtering Actions of
Flow... | 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.
Routes/paths version number is compared with `peer`s current version
number. | 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.
:param name: Name used to create or access a module object.
:param pathname: Path pointing to the source file.
:return: Loaded and initialized module. | 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).
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 address and port.
:return: IP address... | 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.
Parameters:
- `path`: (Path) RT_NLRI path
- `new_rt_as`: AS value of cloned paths' RT_NLRI | 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`.
Returns dict: <key> - attribute type code, <value> - unknown path-attr. | 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").
:param value: String of Route Target or Route Origin value.
:param subtype: Subtype of Extended Community.
:return: An instance of Route Target or Route Origin Community. | 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.
`` actions`` specifies Traffic Filtering Actions of
Flow Specification as a dictionary type value.
Returns a list of extended community values. | 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 pass... | 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.
For the adding/updating/deleting records function, this decorator
invokes "Session.commit()" after the given function.
If any exception while modifying records raised, this decorator invokes
"Session.rollbac... | 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.
: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 replies are expected. The default is None.
:param reply_multi: True... | 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.
Raises RuntimeConfigError if a context is already active. | 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.
All valid neighbors are loaded.
Miss-configured neighbors are ignored and errors are logged. | 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.
All valid VRFs are loaded.
Miss-configured VRFs are ignored and errors are logged. | 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.
All valid routes are loaded.
Miss-configured routes are ignored and errors are logged. | 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.
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 OVSDB server address.
:return: True... | 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(... |
Parses 'setting_string' as str formatted in <column>[:<key>]=<value>
and returns str type 'column' and json formatted 'value' | def parse_column_key_value(table_schema, setting_string):
"""
Parses 'setting_string' as str formatted in <column>[:<key>]=<value>
and returns str type 'column' and json formatted 'value'
"""
if ':' in setting_string:
# splits <column>:<key>=<value> into <column> and ... |
:type commands: list of VSCtlCommand | def _do_main(self, commands):
"""
:type commands: list of VSCtlCommand
"""
self._reset()
self._init_schema_helper()
self._run_prerequisites(commands)
idl_ = idl.Idl(self.remote, self.schema_helper)
seqno = idl_.change_seqno
while True:
... |
:type commands: list of VSCtlCommand | def _run_command(self, commands):
"""
:type commands: list of VSCtlCommand
"""
all_commands = {
# Open vSwitch commands.
'init': (None, self._cmd_init),
'show': (self._pre_cmd_show, self._cmd_show),
# 'emer-reset':
# Bridge com... |
Executes the given commands and sends OVSDB messages.
``commands`` must be a list of
:py:mod:`ryu.lib.ovs.vsctl.VSCtlCommand`.
If ``timeout_sec`` is specified, raises exception after the given
timeout [sec]. Additionally, if ``exception`` is specified, this
function will wraps ... | def run_command(self, commands, timeout_sec=None, exception=None):
"""
Executes the given commands and sends OVSDB messages.
``commands`` must be a list of
:py:mod:`ryu.lib.ovs.vsctl.VSCtlCommand`.
If ``timeout_sec`` is specified, raises exception after the given
timeou... |
:type column_value: tuple of column and value_json | def _check_value(self, ovsrec_row, column_value):
"""
:type column_value: tuple of column and value_json
"""
column, value_json = column_value
column_schema = ovsrec_row._table.columns[column]
value = ovs.db.data.Datum.from_json(
column_schema.type, value_json... |
:type column_values: list of (column, value_json) | def _find(self, ctx, table_name, column_values):
"""
:type column_values: list of (column, value_json)
"""
result = []
for ovsrec_row in ctx.idl.tables[table_name].rows.values():
LOG.debug('ovsrec_row %s', ovsrec_row_to_string(ovsrec_row))
if all(self._che... |
:type column_values: list of (column, value_json) | def _set(self, ctx, table_name, record_id, column_values):
"""
:type column_values: list of (column, value_json)
"""
vsctl_table = self._get_table(table_name)
ovsrec_row = ctx.must_get_row(vsctl_table, record_id)
for column, value in column_values:
ctx.set_col... |
:type column_values: list of (column, value_json) | def _add(self, ctx, table_name, record_id, column_values):
"""
:type column_values: list of (column, value_json)
"""
vsctl_table = self._get_table(table_name)
ovsrec_row = ctx.must_get_row(vsctl_table, record_id)
for column, value in column_values:
ctx.add_col... |
:type column_values: list of (column, value_json) | def _remove(self, ctx, table_name, record_id, column_values):
"""
:type column_values: list of (column, value_json)
"""
vsctl_table = self._get_table(table_name)
ovsrec_row = ctx.must_get_row(vsctl_table, record_id)
for column, value in column_values:
ctx.remo... |
Decorator for all exceptions that want to set exception class meta-data. | def add_bgp_error_metadata(code, sub_code, def_desc='unknown'):
"""Decorator for all exceptions that want to set exception class meta-data.
"""
# Check registry if we already have an exception with same code/sub-code
if _EXCEPTION_REGISTRY.get((code, sub_code)) is not None:
raise ValueError('BGP... |
Defines a decorator to register a validator with a name for look-up.
If name is not provided we use function name as name of the validator. | def validate(**kwargs):
"""Defines a decorator to register a validator with a name for look-up.
If name is not provided we use function name as name of the validator.
"""
def decorator(func):
_VALIDATORS[kwargs.pop('name', func.__name__)] = func
return func
return decorator |
Pops and returns the first outgoing message from the list.
If message list currently has no messages, the calling thread will
be put to sleep until we have at-least one message in the list that
can be popped and returned. | def next(self):
"""Pops and returns the first outgoing message from the list.
If message list currently has no messages, the calling thread will
be put to sleep until we have at-least one message in the list that
can be popped and returned.
"""
# We pick the first outgoi... |
Executes the given commands and sends OVSDB messages.
``commands`` must be a list of
:py:mod:`ryu.lib.ovs.vsctl.VSCtlCommand`.
The given ``timeout`` and ``exception`` when instantiation will be used
to call :py:mod:`ryu.lib.ovs.vsctl.VSCtl.run_command`. | def run_command(self, commands):
"""
Executes the given commands and sends OVSDB messages.
``commands`` must be a list of
:py:mod:`ryu.lib.ovs.vsctl.VSCtlCommand`.
The given ``timeout`` and ``exception`` when instantiation will be used
to call :py:mod:`ryu.lib.ovs.vsctl... |
Validates the given ``ovsdb_addr`` and connects to OVS instance.
If failed to connect to OVS instance or the given ``datapath_id`` does
not match with the Datapath ID of the connected OVS instance, raises
:py:mod:`ryu.lib.ovs.bridge.OVSBridgeNotFound` exception. | def init(self):
"""
Validates the given ``ovsdb_addr`` and connects to OVS instance.
If failed to connect to OVS instance or the given ``datapath_id`` does
not match with the Datapath ID of the connected OVS instance, raises
:py:mod:`ryu.lib.ovs.bridge.OVSBridgeNotFound` excepti... |
get Bridge name of a given 'datapath_id' | def _get_bridge_name(self):
""" get Bridge name of a given 'datapath_id' """
command = ovs_vsctl.VSCtlCommand(
'find',
('Bridge',
'datapath_id=%s' % dpid_lib.dpid_to_str(self.datapath_id)))
self.run_command([command])
if not isinstance(command.result,... |
Gets the configured OpenFlow controller address.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl get-controller <bridge> | def get_controller(self):
"""
Gets the configured OpenFlow controller address.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl get-controller <bridge>
"""
command = ovs_vsctl.VSCtlCommand('get-controller', [self.br_name])
self.r... |
Sets the OpenFlow controller address.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl set-controller <bridge> <target>... | def set_controller(self, controllers):
"""
Sets the OpenFlow controller address.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl set-controller <bridge> <target>...
"""
command = ovs_vsctl.VSCtlCommand('set-controller', [self.br_name])
... |
Deletes the configured OpenFlow controller address.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl del-controller <bridge> | def del_controller(self):
"""
Deletes the configured OpenFlow controller address.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl del-controller <bridge>
"""
command = ovs_vsctl.VSCtlCommand('del-controller', [self.br_name])
sel... |
Lists 'record' (or all records) in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl list TBL [REC] | def list_db_attributes(self, table, record=None):
"""
Lists 'record' (or all records) in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl list TBL [REC]
"""
command = ovs_vsctl.VSCtlCommand('list', (table, record))
self.... |
Lists records satisfying 'conditions' in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl find TBL CONDITION...
.. Note::
Currently, only '=' condition is supported.
To support other condition is TODO. | def find_db_attributes(self, table, *conditions):
"""
Lists records satisfying 'conditions' in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl find TBL CONDITION...
.. Note::
Currently, only '=' condition is supported.
... |
Gets values of 'column' in 'record' in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl get TBL REC COL[:KEY] | def get_db_attribute(self, table, record, column, key=None):
"""
Gets values of 'column' in 'record' in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl get TBL REC COL[:KEY]
"""
if key is not None:
column = '%s:%s' ... |
Sets 'value' into 'column' in 'record' in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl set TBL REC COL[:KEY]=VALUE | def set_db_attribute(self, table, record, column, value, key=None):
"""
Sets 'value' into 'column' in 'record' in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl set TBL REC COL[:KEY]=VALUE
"""
if key is not None:
c... |
Clears values from 'column' in 'record' in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl clear TBL REC COL | def clear_db_attribute(self, table, record, column):
"""
Clears values from 'column' in 'record' in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl clear TBL REC COL
"""
command = ovs_vsctl.VSCtlCommand('clear', (table, record,... |
Gets values of 'column' in 'record' in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl get TBL REC COL | def db_get_val(self, table, record, column):
"""
Gets values of 'column' in 'record' in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl get TBL REC COL
"""
command = ovs_vsctl.VSCtlCommand('get', (table, record, column))
... |
Gets dict type value of 'column' in 'record' in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl get TBL REC COL | def db_get_map(self, table, record, column):
"""
Gets dict type value of 'column' in 'record' in 'table'.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl get TBL REC COL
"""
val = self.db_get_val(table, record, column)
assert is... |
Deletes a port on the OVS instance.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl --if-exists del-port <bridge> <port> | def delete_port(self, port_name):
"""
Deletes a port on the OVS instance.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl --if-exists del-port <bridge> <port>
"""
command = ovs_vsctl.VSCtlCommand(
'del-port', (self.br_name, ... |
Gets the OpenFlow port number.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl get Interface <port> ofport | def get_ofport(self, port_name):
"""
Gets the OpenFlow port number.
This method is corresponding to the following ovs-vsctl command::
$ ovs-vsctl get Interface <port> ofport
"""
ofport_list = self.db_get_val('Interface', port_name, 'ofport')
assert len(ofpor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.