RouteMap Class
Use this class to create and configure route-map entries.
class RouteMap(object)
Example:
>>> from cisco.routemap import *
>>> rm = RouteMap("TestRouteMap", 10)
Arguments:
- name: The name of the route-map, a string.
- sequence: The sequence number of the RouteMap, an integer.
- type: The type of routemap, can be either 'permit' or 'deny'.
Returns: RouteMap object on success
create
Creates the routemap entry associated with this RouteMap object.
create(self, **kwargs)
Example:
>>> rm.create()
True
Arguments: None
Returns: True on success
delete
Deletes the routemap entry associated with this RouteMap object.
delete(self)
Example:
>>> rm.delete()
True
Arguments: None
Returns: True on success
add_description
Adds a description to the routemap.
add_description(self, description=None, **kwargs)
Example:
>>> rm.add_description("Route Map test.")
True
Arguments:
- description: A string of up to 90 characters describing this RouteMap object.
Optional Arguments:
- no: A boolean, set to true to remove any existing description.
Returns: True on success
match_as_number
Matches BGP Peer AS number.
match_as_number(self, as_number, **kwargs)
Example:
>>> rm.match_as_number(65000)
True
Arguments:
- as_number: A string representing the Autonomous System (AS) number in the following format: ’<1-65535>[.<0-65535>]’
Optional Arguments:
- no: A boolean, set to True to remove a BGP peer from the match list
Returns: True on success
match_as_path
Matches AS path access list(s).
match_as_path(self, lists, **kwargs)
Example:
>>> rm.match_as_path("65001 65002")
True
Arguments:
- lists: A string containing a space separated list of Autonomous System (AS) path list names.
Optional Arguments:
- no: A boolean, set to True to remove an AS path list from the match list
Returns: True on success
match_as_path_list
Matches AS path access list(s).
match_as_path_list(self, lists, **kwargs)
Example:
>>> rm.match_as_path_list("65001 65002")
True
Arguments:
- lists: A string containing a space separated list of AS path list names.
Optional Arguments:
- no: A boolean, set to True to remove an AS path list from the match list
Returns: True on success
match_community
Matches BGP community list(s).
match_community(self, lists, **kwargs)
Example:
>>> rm.match_community("community1 community2")
True
Arguments:
- lists: A string containing a space separated list of community list names
Optional args:
- exact_match: A boolean, set to True to do exact matching of communities
- no: A boolean, set to True to remove a community list from the match list
Returns: True on success
match_extcommunity
Matches BGP Extended community list(s).
match_extcommunity(self, lists, **kwargs)
Example:
>>> rm.match_extcommunity("65001 65002")
True
Arguments:
- lists: A string containing a space separated list of Extended community list names
Optional args:
- exact_match: A boolean, set to True to do exact matching of communities
- no: A boolean, set to True to remove a community list from the match list
Returns: True on success
match_interface
Matches first hop interface of route.
match_interface(self, interface, **kwargs)
Example:
>>> rm.match_interface("eth2/1")
True
Arguments:
- interface: A string representing an interface on the switch. Can be Ethernet, loopback, mgmt, port-channel or a VLAN in either expanded or short forms, such as 'e1/1.2', 'Ethernet1/1.2'
Optional args:
- no: A boolean, set to True to remove an interface from the match list
Returns: True on success
match_ip_access_list
Matches IP access list(s).
match_ip_access_list(self, lists, **kwargs)
Example:
>>> rm.match_ip_access_list("acl1", no=True)
True
Arguments:
- list: An IP access list name.
Optional args:
- no: A boolean, set to True to remove an IP access list from the match list.
Returns: True on success
match_ip_prefix_list
Matches IP prefix list(s).
match_ip_prefix_list(self, lists, **kwargs)
Example:
>>> rm.match_ip_prefix_list("1.1.1.0/24 0.0.0.0/0")
True
Arguments:
- lists: A string containing a space separated list of IP prefix list names.
Optional Arguments:
- no: A boolean, set to True to remove an IP prefix list from the match list.
Returns: True on success
match_ipv6_access_list
Matches IPv6 access list(s).
match_ipv6_access_list(self, list, **kwargs)
Example:
>>> rm.match_ipv6_access_list("aclv61")
True
Arguments:
- list: A IPv6 access list name.
Optional args:
- no: A boolean, set to True to remove an IPv6 access list from the match list.
Returns: True on success
match_ipv6_prefix_list
Matches IPv6 prefix list(s).
match_ipv6_prefix_list(self, lists, **kwargs)
Example:
>>> rm.match_ipv6_prefix_list("1::0/96 0::0/0")
True
Arguments:
- lists: A string containing a space separated list of IPv6 prefix list names.
Optional Arguments:
- no: A boolean, set to True to remove an IPv6 prefix list from the match list.
Returns: True on success
match_mac_list
Matches mac-list(s).
match_mac_list(self, lists, **kwargs)
Example:
>>> rm.match_mac_list("aclmac1 aclmac2")
True
Arguments:
- lists: A string containing a space separated list of mac-list names.
Optional Arguments:
- no: A boolean, set to True to remove a mac-list from the match list.
Returns: True on success
match_packet_length
Matches a range of packet lengths.
match_packet_length(self, min=None, max=None, **kwargs)
Example:
>>> rm.match_packet_length(100,1000)
True
Arguments:
- min: An integer ranging from 0 to 2147483647.
- max: An integer ranging from 0 to 2147483647.
Optional Arguments:
- no: A boolean, set to True to remove packet length matching.
Returns: True on success
match_route_type
Matches route-type of route.
match_route_type(self, **kwargs)
Examples:
>>> rm.match_route_type(external=True)
True
>>> rm.match_route_type(level_2=True)
True
>>> rm.match_route_type(local=True, nssa_external=False)
True
>>> rm.match_route_type(type_1=True, type_2=False)
True
Optional Arguments:
- external: Boolean, set to True to match external routes (BGP, EIGRP and OSPF type 1 or 2)
- internal: Boolean, set to True to match internal routes (including OSPF intra/inter area)
- level_1: Boolean, set to True to match IS-IS level-1 routes
- level_2: Boolean, set to True to match IS_IS level-2 routes
- local: Boolean, set to True to match locally generated routes
- nssa_external: Boolean, set to True to match Nssa-external routes (OSPF type 1 or 2)
- type_1: Boolean, set to True to match OSPF external type 1 routes
- type_2: Boolean, set to True to match OSPF external type 2 routes
- intra_area: Boolean, set to True to match OSPF intra area route
- inter_area: Boolean, set to True to match OSPF inter area route
- no: Boolean, set to True to stop matching the route-type of any other parameter that was sent in
Returns: True on success
match_source_protocol
Matches source protocol.
match_source_protocol(self, lists, **kwargs)
Example:
>>> rm.match_source_protocol("tcp udp ip icmp")
True
Arguments:
- lists: A string containing a space separated list of protocol instance names.
Optional Arguments:
- no: A boolean, set to True to remove a source protocol from the match list.
Returns: True on success.
match_tag
Matches tag of route.
match_tag(self, lists, **kwargs)
Example:
>>> rm.match_tag("10 200 300")
True
Arguments:
- lists: A string containing a space separated list of tags where each tag is <0-4294967295>.
Optional args:
- no: A boolean, set to True to remove a tag from the match list.
Returns: True on success.
match_vlan
Matches VLAN ID(s).
match_vlan(self, lists, **kwargs)
Example:
>>> rm.match_vlan("1-5, 100, 1000")
True
Arguments:
- lists: A string containing a comma separated list of VLANs and/or VLAN ranges where each VLAN can range from <1-3967, 4048-4093>. e.g. 1-5, 10 or 2-5,7-19.
Optional Arguments:
- no: A boolean, set to True to remove a list of VLANs and/or VLAN ranges from the match list.
Returns: True on success.
set_as_path_prepend
Prepends string for a BGP AS-path attribute.
set_as_path_prepend(self, list, **kwargs)
Example:
>>> rm.set_as_path_prepend("100 1000 65000")
True
Arguments:
- list: A string containing a space separated list of autonomous system (AS) numbers where each AS number is in the following format: <1-4294967295>|<1-65535>[.<0-65535>]
Optional Arguments:
- no: A boolean, set to True to remove AS numbers from the prepend string.
Returns: True on success.
set_as_path_tag
Sets the tag as an AS-path attribute.
set_as_path_tag(self, **kwargs)
Example:
>>> rm.set_as_path_tag()
True
Arguments: None
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success.
set_comm_list_delete
Sets BGP community list (for deletion).
set_comm_list_delete(self, list, **kwargs)
Example:
>>> rm.set_comm_list_delete("community1")
True
Arguments:
- list: A string up to 63 characters representing a community list name.
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success.
set_extcomm_list_delete
Sets BGP External community list (for deletion).
set_extcomm_list_delete(self, list, **kwargs)
Example:
>>> rm.set_extcomm_list_delete("community2")
True
Arguments:
- list: A string up to 63 characters representing a external community list name.
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success.
set_forwarding_address
Sets the forwarding address.
set_forwarding_address(self, **kwargs)
Example:
>>> rm.set_forwarding_address()
True
Arguments: None
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success.
set_vrf
Sets the VRF for next-hop resolution.
set_vrf(self, vrf, **kwargs)
Example:
>>> rm.set_vrf("test")
True
Arguments:
- vrf: A string representing an existing VRF on the switch.
Optional Arguments:
- no: A boolean, set to True to remove a VRF from next-hop resolution.
Returns: True on success.
set_weight
Sets BGP weight for routing table. Routes with a higher weight value have preference when multiple routes to the same destination exist.
set_weight(self, weight, **kwargs)
Example:
>>> rm.set_weight(100)
True
Arguments:
- weight: An integer ranging from 1 to 65535
Optional Arguments:
- no: A boolean, set to True to remove this configuration
Returns: True on success.