Actions¶
add_config¶
- main(attributes)[source]¶
Adds startup-config section.
Appends config section to startup config based on the value of the ‘url’ attribute.
This action is dual-supervisor compatible.
- Accepts:
- A list of attributes; use attributes.get(<ATTRIBUTE_NAME>) to read attribute values
Parameters: - url – path to config snippet/template
- substitution_mode – loose|strict Default: loose
- variables – A list of variable: value substitutions
- Special_attributes – node: attributes.get(‘NODE’) API: see documentation
Example
- action: add_config attributes: url: files/templates/ma1.template variables: ipaddress: allocate('mgmt_subnet') name: "configure ma1" onstart: "Starting to configure ma1" onsuccess: "SUCCESS: ma1 configure" onfailure: "FAIL: IM provisioning@example.com for help"
copy_file¶
- main(attributes)[source]¶
Copies file to the switch.
Copies file based on the values of ‘src_url’ and ‘dst_url’ attributes (‘dst_url’ should point to the detination folder). If ‘overwrite’ is set to:
- ‘replace’: the file is copied to the switch regardless of whether there is already a file with the same name at the destination;
- ‘if-missing’: the file is copied to the switch only if there is not already a file with the same name at the destination; if there is, then the action is a no-op;
- ‘backup’: the file is copied to the switch; if there is already another file at the destination, that file is renamed by appending the ‘.backup’ suffix
If ‘overwrite’ is not set, then ‘replace’ is the default behaviour.
This action is NOT dual-supervisor compatible.
Parameters: - attributes – list of attributes; use attributes.get(<ATTRIBUTE_NAME>) to read attribute values
- node (internernal) – attributes.get(‘NODE’) API: see documentation
- src_url – Source location
- dst_url – Destination
- mode – Octal mode
- overwrite – Overwrite existing files? <replace|if-missing|backup> Default: replace
Example
- action: copy_file always_execute: true attributes: dst_url: /mnt/flash/ mode: 777 overwrite: if-missing src_url: files/automate/bgpautoinf.py name: "automate BGP peer interface config"
install_cli_plugin¶
- main(attributes)[source]¶
Installs EOS CliPlugin.
Installs CliPlugin based on the value of the ‘url’ attribute.
This action is NOT dual-supervisor compatible.
Parameters: - attributes (list) – list of attributes; use attributes.get(<ATTRIBUTE_NAME>) to read attribute values
- node (internal) – attributes.get(‘NODE’) API: see documentation
- url – path to the cli plugin
Example
- action: install_image always_execute: true attributes: url: files/my_cli_plugin name: "install cli plugin"
install_extension¶
- main(attributes)[source]¶
Installs EOS extension.
Installs extension based on the value of the ‘url’ attribute. If ‘force’ is set, then the dependency checks are overridden.
This action is NOT dual-supervisor compatible.
Parameters: - attributes (list) – list of attributes; use attributes.get(<ATTRIBUTE_NAME>) to read attribute values
- node (internal) – attributes.get(‘NODE’) API: see documentation
- url – path to the rpm or swix extension
- force – Force installation regardless of checks. Default: False
Example
- action: install_image always_execute: true attributes: url: files/telemetry-1.0-1.rpm name: "Install Telemetry"
install_image¶
- main(attributes)[source]¶
Installs software image on the switch.
If the current software image is the same as the ‘version’ attribute value, then this action is a no-op. Otherwise, the action will replace the existing software image.
For dual supervisor systems, the image on the active supervisor is used as reference.
This action is dual-supervisor compatible.
Parameters: - attributes (list) – list of attributes; use attributes.get(<ATTRIBUTE_NAME>) to read attribute values
- node (internal) – attributes.get(‘NODE’) API: see documentation
- url – path to .swi file
- version – target version of the .swi file.
Example
- action: install_image always_execute: true attributes: url: files/images/vEOS.swi version: 4.13.5F name: "validate image" onstart: "Starting to install image" onsuccess: "SUCCESS: 4.13.5F installed" onfailure: "FAIL: IM nick@example.com for help"
replace_config¶
- main(attributes)[source]¶
Replaces stratup-config on the switch.
Replaces/adds /mnt/flash/startup-config based on the value of the ‘url’ attribute.
This action is dual-supervisor compatible.
Parameters: - attributes (list) – list of attributes; use attributes.get(<ATTRIBUTE_NAME>) to read attribute values
- node (internal) – attributes.get(‘NODE’) API: see documentation
- url – path to config/template
send_email¶
- main(attributes)[source]¶
Sends an email using an SMTP relay host
Generates an email from the bootstrap process and routes it through a smarthost. The parameters value expects a dictionary with the following values in order for this function to work properly.
{ 'smarthost': <hostname of smarthost>, 'sender': <from email address> 'receivers': [ <array of recipients to send email to> ], 'subject': <subject line of the message>, 'body': <the message body>, 'attachments': [ <array of files to attach> ], 'commands': [ <array of commands to run and attach> ] }
The required fields for this function are smarthost, sender, and receivers. All other fields are optional.
This action is dual-supervisor compatible.
Parameters: - attributes (list) – list of attributes; use attributes.get(<ATTRIBUTE_NAME>) to read attribute values
- node (internal) – attributes.get(‘NODE’) API: see documentation
- smarthost – hostname of smarthos>,
- sender – from email addres>
- receivers – [ <array of recipients to send email to> ]
- subject – subject line of the message
- body – the message body
- attachments – [ <array of files to attach> ]
- commands – [ <array of commands to run and attach> ]
Example
- action: send_mail attributes: smarthost: smtp.example.com from: noreply@example.com subject: This is a test message from a switch in ZTP receivers: bob@exmple.com helen@example.com body: Please see the attached 'show version' commands: show version