Junos Automation Scripts Overview
Learn about Junos automation and the different types of Junos automation scripts.
Junos Automation Scripts
Junos automation consists of a suite of tools used to automate operational and configuration tasks on network devices running Junos OS or Junos OS Evolved. The Junos automation toolkit is part of the standard software package for all Junos devices. Junos automation tools, which leverage the native XML capabilities of Junos OS, include:
-
Commit scripts and macros
-
Operation (op) scripts
-
Event policies and event scripts
-
SNMP scripts
Junos automation simplifies complex configurations and reduces potential configuration errors. It saves time by automating operational and configuration tasks. It also speeds troubleshooting and maximizes network uptime by warning of potential problems and automatically responding to system events. Junos automation can also capture the knowledge and expertise of experienced network operators and administrators. Businesses can then leverage this combined expertise across the organization.
You can write Junos automation scripts in the following scripting languages. We recommend using Python or SLAX for automation scripts.
-
Python
-
Stylesheet Language Alternative syntaX (SLAX)
-
Extensible Stylesheet Language Transformations (XSLT)
Python is a commonly-used, open-source programming language with extensive standard and community libraries. On Junos devices, Python automation scripts can leverage Junos PyEZ to simplify many operational and configuration tasks.
XSLT is a standard for processing Extensible Markup Language (XML) data and is designed to convert one XML document into another. SLAX is an alternative to XSLT. It has a simple syntax that follows the style of C and PERL, but retains the same semantics as XSLT. Programmers who are familiar with C often find it easier to learn and use SLAX. You can easily convert SLAX scripts into XSLT and convert XSLT scripts into SLAX.
Junos Configuration Automation: Commit Scripts
Junos configuration automation uses commit scripts to automate the commit process. Commit scripts enforce custom configuration rules. When you commit a candidate configuration, it is inspected by each active commit script. If a configuration violates your custom rules, the script can instruct Junos OS to take appropriate action. A commit script can perform the following actions:
Generate and display custom warning messages to the user
Generate and log custom system log (syslog) messages
Change the configuration to conform to the custom configuration rules
Generate a commit error and halt the commit operation
Commit scripts, when used in conjunction with macros, allow you to simplify the Junos configuration and extend it with your own custom configuration syntax.
Junos Operations Automation: Op Scripts
Junos operations automation uses op scripts to automate operational tasks and network troubleshooting. You can invoke op scripts in a number of ways—manually in the CLI, upon user login, through a call from another script, or through an API call. You can construct op scripts to process user arguments and you can use the scripts to:
Create custom operational mode commands
Execute a series of operational mode commands
Customize the output of operational mode commands
Shorten troubleshooting time by gathering operational information and iteratively narrowing down the cause of a network problem
Perform controlled configuration changes
Monitor the overall status of a device by periodically checking network warning parameters, such as high CPU usage.
Junos Event Automation: Event Scripts and Event Policy
Junos event automation uses event policies and event scripts to instruct Junos OS to perform actions in response to system events.
Event Policy
An event policy is an if-then-else construct that defines actions that the software should execute on receipt of an event such as a system log message or SNMP trap. Event policies can be executed in response to a single system event or to correlated system events. For each policy, you can configure multiple actions including:
Upload a file to a specified destination
Execute operational mode commands
Execute event scripts
Modify the configuration
-
Ignore the event
Event Scripts
Event scripts are triggered automatically by defined event policies in response to a system event. Event scripts can instruct the software to take immediate action. An event script automates network troubleshooting and network management by:
-
Monitoring the overall status of a device
Automatically diagnosing and fixing problems in the network
Running automatically as part of an event policy that detects periodic error conditions
Changing the configuration in response to a problem
Junos SNMP Automation: SNMP Scripts
SNMP scripts provide the flexibility to support custom MIBs. SNMP scripts trigger automatically when the SNMP manager requests information from the SNMP agent for an unsupported object identifier (OID) that is mapped to an SNMP script. The script acts like an SNMP subagent, and the system sends the return value from the script to the network management system (NMS).