Vrrp¶
Module for working with EOS VRRP resources
The Vrrp resource provides configuration management of interface specific vrrp resources on and EOS node. It provides the following class implementations:
Vrrp - Configure vrrps in EOS
- Vrrp Attributes:
enable (boolean): The shutdown state of the vrrp
primary_ip (string): The ip address of the vrrp
- secondary_ip (dict): The secondary ip addresses configured for the vrrp
This is a dictionary in the format:
{ key: [ list of ip addresses ] }
where key is ‘add’, ‘remove’, or ‘exists’. ‘add’ is used to add the list of secondary ip addresses to the vrrp. ‘remove’ will remove the list of secondary ip addresses from the vrrp. ‘exists’ is a report only key for retrieving the current secondary ip addresses on a vrrp.
priority (int): The priority rank of the vrrp
description (string): The description for the vrrp
ip_version (int): The ip version value for the vrrp
timers_advertise (int): The timers advertise setting for the vrrp
- mac_addr_adv_interval (int): The mac-address advertisement-interval
setting for the vrrp
preempt (boolean): The preempt state of the vrrp
preempt_delay_min (int): The preempt delay minimum setting for the vrrp
preempt_delay_reload (int): The preempt delay reload setting for the vrrp
delay_reload (int): The delay reload setting for the vrrp
track (list): The object tracking settings for the vrrp
bfd_ip (string): The bfd ip set for the vrrp
Notes
The get method will return a dictionary of all the currently configured vrrps on a single interface, with the VRID of each vrrp as the keys in the dictionary:
{
vrrp1: { data },
vrrp2: { data },
}
The getall method will return a dictionary of all the currently configured vrrps on the node, with the interface name as the top-level keys, with the VRIDs for each vrrp on an interface as a sub-key of that interface:
{
interface1: {
vrrp1: { data },
vrrp2: { data },
},
interface2: {
vrrp1: { data },
vrrp2: { data },
}
}
The data for a configured vrrp is a dictionary with the following format:
{
enable: <True|False>
primary_ip: <string>
priority: <int>
description: <string|None>
secondary_ip: {
exists: [ <ip string1>, <ip string2> ]
}
ip_version: <int>
timers_advertise: <int>
mac_addr_adv_interval: <int>
preempt: <True|False>
preempt_delay_min: <int>
preempt_delay_reload: <int>
delay_reload: <int>
track: [
{
name: <string>
action: <shutdown|decrement>
amount: <int>|default|no|None
},
{
name: <string>
action: <shutdown|decrement>
amount: <int>|default|no|None
},
]
bfd_ip: <string>
}
The create and method accepts a kwargs dictionary which defines the properties to be applied to the new or existing vrrp configuration. The available keywords and values are as follows:
enable: True to enable (no shutdown)|False to disable (shutdown)
primary_ip: <ip_string>|no|default|None
priority: <int>|no|default|None
description: <string>|no|default|None
- secondary_ip: <dict> may include the following
add: <list of ip address strings>
remove: <list of ip address strings>
ip_version: <int>|no|default|None
timers_advertise: <int>|no|default|None
mac_addr_adv_interval: <int>|no|default|None
preempt: True to enable (preempt)|False to disable (no preempt)
preempt_delay_min: <int>|no|default|None
preempt_delay_reload: <int>|no|default|None
delay_reload: <int>|no|default|None
track: <list> of dicts in the following format:
{ name: <string> action: <shutdown|decrement> amount: <int>|default|no|None }bfd_ip: <ip string>|no|default|None
- class pyeapi.api.vrrp.Vrrp(node)[source]¶
Bases:
pyeapi.api.abstract.EntityCollection
The Vrrp class provides management of the VRRP configuration
The Vrrp class is derived from EntityCollection and provides an API for working with the node’s vrrp configurations.
- create(interface, vrid, **kwargs)[source]¶
Creates a vrrp instance from an interface
Note
This method will attempt to create a vrrp in the node’s operational config. If the vrrp already exists on the interface, then this method will set the properties of the existing vrrp to those that have been passed in, if possible.
- Parameters
interface (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be created.
kwargs (dict) – A dictionary specifying the properties to be applied to the new vrrp instance. See library documentation for available keys and values.
- Returns
True if the vrrp could be created otherwise False (see Node)
- default(interface, vrid)[source]¶
Defaults a vrrp instance from an interface
Note
This method will attempt to default the vrrp on the node’s operational config. Default results in the deletion of the specified vrrp . If the vrrp does not exist on the interface then this method will not perform any changes but still return True
- Parameters
interface (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be defaulted.
- Returns
True if the vrrp could be defaulted otherwise False (see Node)
- delete(interface, vrid)[source]¶
Deletes a vrrp instance from an interface
Note
This method will attempt to delete the vrrp from the node’s operational config. If the vrrp does not exist on the interface then this method will not perform any changes but still return True
- Parameters
interface (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be deleted.
- Returns
True if the vrrp could be deleted otherwise False (see Node)
- get(name)[source]¶
Get the vrrp configurations for a single node interface
- Parameters
name (string) – The name of the interface for which vrrp configurations will be retrieved.
- Returns
A dictionary containing the vrrp configurations on the interface. Returns None if no vrrp configurations are defined or if the interface is not configured.
- getall()[source]¶
Get the vrrp configurations for all interfaces on a node
- Returns
A dictionary containing the vrrp configurations on the node, keyed by interface.
- set_bfd_ip(name, vrid, value=None, disable=False, default=False, run=True)[source]¶
Set the bfd_ip property of the vrrp
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
value (string) – The bfd ip address to be set.
disable (boolean) – Unset bfd ip if True.
default (boolean) – Set bfd ip to default if True.
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- set_delay_reload(name, vrid, value=None, disable=False, default=False, run=True)[source]¶
Set the preempt_delay_min property of the vrrp
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
value (integer) – Preempt delay reload value to set on the vrrp.
disable (boolean) – Unset preempt delay reload if True.
default (boolean) – Set preempt delay reload to default if True.
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- set_description(name, vrid, value=None, disable=False, default=False, run=True)[source]¶
Set the description property of the vrrp
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
value (string) – Description to assign to the vrrp.
disable (boolean) – Unset description if True.
default (boolean) – Set description to default if True.
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- set_enable(name, vrid, value=False, run=True)[source]¶
Set the enable property of the vrrp
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
value (boolean) – True to enable the vrrp, False to disable.
run (boolean) – True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure
If run is False, returns the formatted command string which can be passed to the node
- set_ip_version(name, vrid, value=None, disable=False, default=False, run=True)[source]¶
Set the ip_version property of the vrrp
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
value (integer) – IP version to assign to the vrrp.
disable (boolean) – Unset ip_version if True.
default (boolean) – Set ip_version to default if True.
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- set_mac_addr_adv_interval(name, vrid, value=None, disable=False, default=False, run=True)[source]¶
Set the mac_addr_adv_interval property of the vrrp
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
value (integer) – mac-address advertisement-interval value to assign to the vrrp.
disable (boolean) – Unset mac-address advertisement-interval if True.
default (boolean) – Set mac-address advertisement-interval to default if True.
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- set_preempt(name, vrid, value=None, disable=False, default=False, run=True)[source]¶
Set the preempt property of the vrrp
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
value (boolean) – True to enable preempt, False to disable preempt on the vrrp.
disable (boolean) – Unset preempt if True.
default (boolean) – Set preempt to default if True.
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- set_preempt_delay_min(name, vrid, value=None, disable=False, default=False, run=True)[source]¶
Set the preempt_delay_min property of the vrrp
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
value (integer) – Preempt delay minimum value to set on the vrrp.
disable (boolean) – Unset preempt delay minimum if True.
default (boolean) – Set preempt delay minimum to default if True.
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- set_preempt_delay_reload(name, vrid, value=None, disable=False, default=False, run=True)[source]¶
Set the preempt_delay_min property of the vrrp
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
value (integer) – Preempt delay reload value to set on the vrrp.
disable (boolean) – Unset preempt delay reload if True.
default (boolean) – Set preempt delay reload to default if True.
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- set_primary_ip(name, vrid, value=None, disable=False, default=False, run=True)[source]¶
Set the primary_ip property of the vrrp
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
value (string) – IP address to be set.
disable (boolean) – Unset primary ip if True.
default (boolean) – Set primary ip to default if True.
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- set_priority(name, vrid, value=None, disable=False, default=False, run=True)[source]¶
Set the primary_ip property of the vrrp
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
value (integer) – Priority to assign to the vrrp.
disable (boolean) – Unset priority if True.
default (boolean) – Set priority to default if True.
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- set_secondary_ips(name, vrid, secondary_ips, run=True)[source]¶
Configure the secondary_ip property of the vrrp
Notes
set_secondary_ips takes a list of secondary ip addresses which are to be set on the virtal router. An empty list will remove any existing secondary ip addresses from the vrrp. A list containing addresses will configure the virtual router with only the addresses specified in the list - any existing addresses not included in the list will be removed.
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
secondary_ips (list) – A list of secondary ip addresses to be assigned to the virtual router.
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- set_timers_advertise(name, vrid, value=None, disable=False, default=False, run=True)[source]¶
Set the ip_version property of the vrrp
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
value (integer) – Timers advertise value to assign to the vrrp.
disable (boolean) – Unset timers advertise if True.
default (boolean) – Set timers advertise to default if True.
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- set_tracks(name, vrid, tracks, run=True)[source]¶
Configure the track property of the vrrp
Notes
set_tracks takes a list of tracked objects which are to be set on the virtual router. An empty list will remove any existing tracked objects from the vrrp. A list containing track entries configures the virtual router to track only the objects specified in the list - any existing tracked objects on the vrrp not included in the list will be removed.
- Parameters
name (string) – The interface to configure.
vrid (integer) – The vrid number for the vrrp to be managed.
tracks (list) –
A list of track definition dictionaries. Each dictionary is a definition of a tracked object in one of the two formats:
{'name': tracked_object_name, 'action': 'shutdown'} {'name': tracked_object_name, 'action': 'decrement', 'amount': amount_of_decrement}
run (boolean) – Set to True to execute the command, False to return a string with the formatted command.
- Returns
If run is True, returns True if the command executed successfully, error if failure.
If run is False, returns the formatted command string which can be passed to the node
- vrconf_format(vrconfig)[source]¶
Formats a vrrp configuration dictionary to match the information as presented from the get and getall methods. vrrp configuration dictionaries passed to the create method may contain data for setting properties which results in a default value on the node. In these instances, the data for setting or changing the property is replaced with the value that would be returned from the get and getall methods.
Intended for validating updated vrrp configurations.