ipmininet.router.config.bgp module¶
Base classes to configure a BGP daemon
-
ipmininet.router.config.bgp.
AF_INET
(*args, **kwargs)¶ The ipv4 (unicast) address family
-
ipmininet.router.config.bgp.
AF_INET6
(*args, **kwargs)¶ The ipv6 (unicast) address family
-
class
ipmininet.router.config.bgp.
AS
(asn: int, routers=(), **props)¶ Bases:
ipmininet.overlay.Overlay
An overlay class that groups routers by AS number
Parameters: - asn – The number for this AS
- routers – an initial set of routers to add to this AS
- props – key-values to set on all routers of this AS
-
asn
¶
-
class
ipmininet.router.config.bgp.
AbstractBGP
(node: IPNode, template_lookup: mako.lookup.TemplateLookup = <mako.lookup.TemplateLookup object>, **kwargs)¶ Bases:
abc.ABC
,ipmininet.router.config.base.RouterDaemon
Parameters: - node – The node for which we build the config
- template_lookup – The TemplateLookup object of the template directory
- kwargs – Pre-set options for the daemon, see defaults()
-
afi
¶
-
class
ipmininet.router.config.bgp.
AddressFamily
(af_name: str, redistribute: Sequence[str] = (), networks: Sequence[Union[str, ipaddress.IPv4Network, ipaddress.IPv6Network]] = (), routes=())¶ Bases:
object
An address family that is exchanged through BGP
-
extend
(af: ipmininet.router.config.bgp.AddressFamily)¶
-
family
¶ the AddressFamily to be used in FRRouting configuration
Type: return
-
-
class
ipmininet.router.config.bgp.
BGP
(node, port=179, *args, **kwargs)¶ Bases:
ipmininet.router.config.zebra.QuaggaDaemon
,ipmininet.router.config.bgp.AbstractBGP
This class provides the configuration skeletons for BGP routers.
-
DEPENDS
= (<class 'ipmininet.router.config.zebra.Zebra'>,)¶
-
KILL_PATTERNS
= ('bgpd',)¶
-
NAME
= 'bgpd'¶
-
STARTUP_LINE_EXTRA
¶ We add the port to the standard startup line
-
build
()¶ Build the configuration tree for this daemon
Returns: ConfigDict-like object describing this configuration
-
build_access_list
() → List[ipmininet.router.config.zebra.AccessList]¶ Build and return a list of access_filter :return:
-
build_community_list
() → List[ipmininet.router.config.zebra.CommunityList]¶ Build and return a list of community_filter
-
build_prefix_list
()¶
-
build_route_map
(neighbors: Sequence[Peer]) → List[ipmininet.router.config.zebra.RouteMap]¶ Build and return a list of route map for the current node
-
classmethod
get_config
(topo: IPTopo, node: RouterDescription, **kwargs)¶ Returns a config object for the daemon if any
-
set_defaults
(defaults)¶ Parameters: - debug – the set of debug events that should be logged
- address_families – The set of AddressFamily to use
-
-
class
ipmininet.router.config.bgp.
BGPConfig
(topo: IPTopo, router: RouterDescription)¶ Bases:
object
-
add_set_action
(peer: str, set_action: ipmininet.router.config.zebra.RouteMapSetAction, name: Optional[str], matching: Sequence[Union[ipmininet.router.config.zebra.AccessList, ipmininet.router.config.zebra.CommunityList]], direction: str) → ipmininet.router.config.bgp.BGPConfig¶ Add a ‘RouteMapSetAction’ to a BGP peering between two nodes
Parameters: - name – if set, define the name of the route map, the action
- peer – The peer to which the route map is applied
- set_action – The RouteMapSetAction to set
- matching – A list of filter, can be empty
- direction – direction of the route map: ‘in’, ‘out’ or ‘both’
Returns: self
-
deny
(name: Optional[str] = None, from_peer: Optional[str] = None, to_peer: Optional[str] = None, matching: Sequence[Union[ipmininet.router.config.zebra.AccessList, ipmininet.router.config.zebra.CommunityList]] = (), order=10) → ipmininet.router.config.bgp.BGPConfig¶ - Deny all routes received from ‘from_peer’
- and routes sent to ‘to_peer’ matching all of the access and community lists in ‘matching’
Parameters: - name – The name of the route-map
- from_peer – The peer on which received routes have to have the community
- to_peer – The peer on which sent routes have to have the community
- matching – A list of AccessList and/or CommunityList
- order – The order in which route-maps are applied, i.e., lower order means applied before
Returns: self
-
filter
(name: Optional[str] = None, policy='deny', from_peer: Optional[str] = None, to_peer: Optional[str] = None, matching: Sequence[Union[ipmininet.router.config.zebra.AccessList, ipmininet.router.config.zebra.CommunityList, ipmininet.router.config.zebra.PrefixList]] = (), order=10) → ipmininet.router.config.bgp.BGPConfig¶ - Either accept or deny all routes received from ‘from_peer’
- and routes sent to ‘to_peer’ matching any access/prefix lists or community lists in ‘matching’
Parameters: - name – The name of the route-map. If no name is given, the filter will be appended to the main route map responsible for the importation (resp. exportation) of routes received (resp. sent) from “from_peer” (resp. “to_peer”). If the name is set, the freshly created route-map will be created but not used unless explicitly called with the route-map “call” command from the main importation/exportation RM.
- policy – Either ‘deny’ or ‘permit’
- from_peer – Is set, the filter will be applied on the routes received from “from_peer”.
- to_peer – Is set, the filter will be applied on the routes sent to “to_peer”.
- matching – A list of AccessList and/or CommunityList and/or PrefixList
- order – The order in which route-maps are applied, i.e., lower order means applied before
Returns: self
-
filters_to_match_cond
(filter_list: Sequence[Union[ipmininet.router.config.zebra.AccessList, ipmininet.router.config.zebra.CommunityList, ipmininet.router.config.zebra.PrefixList]], family: str)¶
-
permit
(name: Optional[str] = None, from_peer: Optional[str] = None, to_peer: Optional[str] = None, matching: Sequence[Union[ipmininet.router.config.zebra.AccessList, ipmininet.router.config.zebra.CommunityList]] = (), order=10) → ipmininet.router.config.bgp.BGPConfig¶ - Accept all routes received from ‘from_peer’
- and routes sent to ‘to_peer’ matching all of the access and community lists in ‘matching’
Parameters: - name – The name of the route-map
- from_peer – The peer on which received routes have to have the community
- to_peer – The peer on which sent routes have to have the community
- matching – A list of AccessList and/or CommunityList
- order – The order in which route-maps are applied, i.e., lower order means applied before
Returns: self
-
static
rm_name
(peer: str, family: str, direction: str)¶
-
set_community
(community: Union[str, int], from_peer: Optional[str] = None, to_peer: Optional[str] = None, matching: Sequence[Union[ipmininet.router.config.zebra.AccessList, ipmininet.router.config.zebra.CommunityList]] = (), name: Optional[str] = None) → ipmininet.router.config.bgp.BGPConfig¶ - Set community on a routes received from ‘from_peer’
- and routes sent to ‘to_peer’ on routes matching all of the access and community lists in ‘matching’
Parameters: - name –
- community – The community value to set
- from_peer – The peer on which received routes have to have the community
- to_peer – The peer on which sent routes have to have the community
- matching – A list of AccessList and/or CommunityList
Returns: self
-
set_local_pref
(local_pref: int, from_peer: str, matching: Sequence[Union[ipmininet.router.config.zebra.AccessList, ipmininet.router.config.zebra.CommunityList]] = (), name: Optional[str] = None) → ipmininet.router.config.bgp.BGPConfig¶ - Set local pref on a peering with ‘from_peer’ on routes
- matching all of the access and community lists in ‘matching’
Parameters: - name –
- local_pref – The local pref value to set
- from_peer – The peer on which the local pref is applied
- matching – A list of AccessList and/or CommunityList
Returns: self
-
set_med
(med: int, to_peer: str, matching: Sequence[Union[ipmininet.router.config.zebra.AccessList, ipmininet.router.config.zebra.CommunityList]] = (), name: Optional[str] = None) → ipmininet.router.config.bgp.BGPConfig¶ - Set MED on a peering with ‘to_peer’ on routes
- matching all of the access and community lists in ‘matching’
Parameters: - name –
- med – The local pref value to set
- to_peer – The peer to which the med is applied
- matching – A list of AccessList and/or CommunityList
Returns: self
-
-
class
ipmininet.router.config.bgp.
Peer
(base: Router, node: str, v6=False)¶ Bases:
object
A BGP peer
Parameters: - base – The base router that has this peer
- node – The actual peer
-
class
PQNode
(key, extra_val)¶ Bases:
object
Class representing an element of the priority queue used in _find_peer_address
-
ipmininet.router.config.bgp.
bgp_fullmesh
(topo, routers: Sequence[str])¶ Establish a full-mesh set of BGP peerings between routers
Parameters: - topo – The current topology
- routers – The set of routers peering within each other
-
ipmininet.router.config.bgp.
bgp_peering
(topo: IPTopo, a: RouterDescription, b: RouterDescription)¶ Register a BGP peering between two nodes
-
ipmininet.router.config.bgp.
ebgp_session
(topo: IPTopo, a: RouterDescription, b: RouterDescription, link_type: Optional[str] = None)¶ Register an eBGP peering between two nodes, and disable IGP adjacencies between them.
Parameters: - topo – The current topology
- a – Local router
- b – Peer router
- link_type – Can be set to SHARE or CLIENT_PROVIDER. In this case ebgp_session will create import and export filter and set local pref based on the link type
-
ipmininet.router.config.bgp.
filter_allows_all_routes
(a: RouterDescription, b: RouterDescription)¶
-
class
ipmininet.router.config.bgp.
iBGPFullMesh
(asn: int, routers=(), **props)¶ Bases:
ipmininet.router.config.bgp.AS
An overlay class to establish iBGP sessions in full mesh between BGP routers.
Parameters: - asn – The number for this AS
- routers – an initial set of routers to add to this AS
- props – key-values to set on all routers of this AS
-
apply
(topo)¶ Apply the Overlay properties to the given topology
-
ipmininet.router.config.bgp.
set_rr
(topo: IPTopo, rr: str, peers: Sequence[str] = ())¶ Set rr as route reflector for all router r
Parameters: - topo – The current topology
- rr – The route reflector
- peers – Clients of the route reflector