pyaoscx.bgp_router module

class pyaoscx.bgp_router.BgpRouter(session, asn, parent_vrf, uri=None, **kwargs)

Bases: pyaoscx.pyaoscx_module.PyaoscxModule

Provide configuration management for BGP Routers on AOS-CX devices.

aggregate_addresses
Attribute descriptor class to keep track of a list that contains
pyaoscx_module objects simulating a Reference to a resource. If the list changes, then every pyaoscx_module object has to be changed.
apply()
Main method used to either create or update an existing BGP Router.
Checks whether the BGP Router exists in the switch. Calls self.update() if BGP Router is being updated. Calls self.create() if a new BGP Router is being created.
Returns:Boolean, True if object was created or modified.
asn
bgp_neighbors
Attribute descriptor class to keep track of a list that contains
pyaoscx_module objects simulating a Reference to a resource. If the list changes, then every pyaoscx_module object has to be changed.
collection_uri = 'system/vrfs/{name}/bgp_routers'
create()
Perform a POST call to create a new BGP Router table entry. Only
returns if no exception is raised.
Returns:Boolean, True if entry was created.
create_bgp_neighbors(ip_or_ifname_or_group_name, family_type=None, activate=None, inbound_soft_reconfiguration=None, route_reflector_client=None, send_community=None, remote_as=None, update_source=None)
Perform a POST call to create BGP Neighbors to the associated current
BGP Router. With l2vpn_evpn being True, this will also apply EVPN settings to the BGP neighbor configurations.
Parameters:
  • family_type – Alphanumeric to specify what type of neighbor settings to configure. The options are ‘ipv4-unicast’, ‘ipv6-unicast’ and ‘l2vpn-evpn’.
  • ip_or_ifname_or_group_name – IPv4 address or name of group of the neighbors that functions as the BGP Router link. Example IPv4: 10.10.12.11/255.255.255.255
  • activate – Boolean value to activate neighbor in the address family.
  • inbound_soft_reconfiguration – Boolean value that allow inbound soft reconfiguration.
  • route_reflector_client – Boolean value to determine whether this neighbor has route reflector enabled.
  • send_community – Boolean value to determine whether this neighbor has send-community enabled.
  • remote_as – Integer peer ASN.
  • update_source – Source address for the neighbor session.
Returns:

BgpRouter object.

delete()

Perform DELETE call to delete BGP Router.

classmethod from_response(session, parent_vrf, response_data)

Create a BgpRouter object given a response_data related to it.

Parameters:
  • cls – Object’s class.
  • session – pyaoscx.Session object used to represent a logical connection to the device.
  • parent_vrf – Vrf object where BGP Router is stored.
  • response_data – The response must be a dictionary of the form: { <asn>: “/rest/v10.04/system/vrfs/<name>/bgp_routers/<asn>” }
Returns:

BgpRouter object.

classmethod from_uri(session, parent_vrf, uri)

Create a BgpRouter object given a URI.

Parameters:
  • cls – Object’s class.
  • session – pyaoscx.Session object used to represent a logical connection to the device.
  • parent_vrf – Vrf object where BGP Router is stored.
  • uri – a String with a URI.
Returns:

tuple containing both the BgpRouter object and the BGP’s asn.

get(depth=None, selector=None)
Perform a GET call to retrieve data for a BGP Router table entry and
fill the object with the incoming attributes
Parameters:
  • depth – Integer deciding how many levels into the API JSON that references will be returned.
  • selector – Alphanumeric option to select specific information to return.
Returns:

Returns True if there is not an exception raised.

classmethod get_all(session, parent_vrf)
Perform a GET call to retrieve all system BGP Routers inside a VRF, and
create a dictionary containing them.
Parameters:
  • cls – Object’s class.
  • session – pyaoscx.Session object used to represent a logical connection to the device.
  • parent_vrf – Vrf object where BGP Router is stored.
Returns:

Dictionary containing BGP Router IDs as keys and a BGP Router objects as values.

get_info_format()
Method used to obtain correct object format for referencing inside
other objects.
Returns:Object format depending on the API Version.
get_uri()

Method used to obtain the specific BGP Router URI.

Returns:Object’s URI.
indices = ['asn']
modified

Return boolean with whether this object has been modified.

object_uri = 'system/vrfs/{name}/bgp_routers/{asn}'
remove_bgp_neighbor(neighbor)
Update references to BGP Neighbors. If a Neighbor with the same IP,
Interface or group name is found, delete the reference to it.
Parameters:new_neighbor – Neighbor to add reference to.
resource_uri_name = 'bgp_routers'
update()

Perform a PUT call to apply changes to an existing BGP Router.

Returns:True if Object was modified and a PUT request was made.
update_bgp_neighbors(new_neighbor)
Update references to BGP Neighbors. If a Neighbor with the same IP,
Interface or group name is found, update the reference to the new neighbor, otherwise, add reference to the new neighbor.
Parameters:new_neighbor – Neighbor to add reference to.
was_modified()

Getter method for the __modified attribute.

Returns:Boolean True if the object was recently modified.