[ Contents] [ Prev] [ Next] [ Index] [ Report an Error]

Automating Network Management and Troubleshooting with Operation Scripts

Operation scripts are scripts that you write to automate network management and troubleshooting tasks. They can perform any function available through JUNOScript remote procedure calls (RPCs).

This section contains the following topics:

Operation Script Overview

You can execute operation scripts from the JUNOS CLI or from within an event policy. For information about event policies, see Running Self-Diagnostics with Event Policies.

Operation scripts allow you to perform various actions, including the following:

The scripting language you use for writing operation scripts is Extensible Stylesheet Language Transformations (XSLT). XSLT operation scripts are based on JUNOScript Extensible Markup Language (XML).

Enabling Operation Scripts

To enable operation scripts:

  1. Write an operation script.

    For information about writing operation scripts, see the JUNOS Configuration and Diagnostic Automation Guide.

  2. Copy the script to the /var/db/scripts/op directory.

    Only users with superuser privileges can access and edit files in the /var/db/scripts/op directory.

  3. Navigate to the top of the configuration hierarchy in either the J-Web or CLI configuration editor.
  4. Perform the configuration tasks described in Table 49.
  5. If you are finished configuring the network, commit the configuration.

Table 49: Enabling Operation Scripts

Task

J-Web Configuration Editor

CLI Configuration Editor

Navigate to the Op level in the configuration hierarchy.

  1. In the J-Web interface, select CLI Tools>Point and Click CLI.
  2. Next to System, click Configure or Edit.
  3. Next to Scripts, click Configure or Edit.
  4. Next to Op, click Configure or Edit.

From the [edit] hierarchy level, enter

edit system scripts op

Enable the operation script file—for example, op-script.xsl.

  1. Next to File, click Add new entry.
  2. In the Name box, type op-script.xsl.
  3. Click OK.

Set the script file name:

set file op-script.xsl

Executing Operation Scripts

You can execute the enabled operation scripts from the CLI or from within an event policy. For information about event policy, see Running Self-Diagnostics with Event Policies.

This section describes how you can execute operation scripts from the command line.

To execute an operation script from the CLI:

  1. Enter configuration mode in the CLI.
  2. Execute the script with the following command:

    user@host# op filename.xsl

Disabling Operation Scripts

If you do not want an operation script to run, you can disable it by deleting or deactivating it in the configuration. Deleting an operation script permanently removes it from the configuration. To run the script later, you must reenable the script as described in Enabling Operation Scripts. Deactivating an operation script disables the script until you activate it later.

To delete an operation script, do the following:

  1. From configuration mode in the CLI, enter the following command:

    user@host# delete system scripts op filename.xsl
  2. Commit the configuration:

    user@host# commit
    commit complete

To deactivate an operation script:

  1. From configuration mode in the CLI, enter the following command:

    user@host# deactivate system scripts op filename.xsl
  2. Commit the configuration:

    user@host# commit
    commit complete

    Note: You can later reactivate the operation script using the activate system scripts op filename.xsl command.


[ Contents] [ Prev] [ Next] [ Index] [ Report an Error]