Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 

Executing Scripts on Devices

 

You can use Junos Space Network Management Platform to trigger the execution of op scripts on one or more devices simultaneously. Commit and event scripts are automatically activated after they are enabled. Commit scripts are triggered every time a commit is called on the device and event scripts are triggered every time an event occurs on the device or at a specific time, if a time is specified.

Note

If a script does not require XPath processing, you can execute such scripts on more than 200 devices at a time. Scripts that do not require XPath processing include scripts without device-specific or entity-specific parameters and with /, //, or /device as context.

Caution

If the filename of the selected script matches that of any script present on the device, then the script on the device is executed regardless of its contents.

To execute an op script on devices:

  1. On the Junos Space Platform UI, select Images and Scripts > Scripts.

    The Scripts page appears, displaying the scripts that you imported into Junos Space Platform.

  2. Select the op script that you want to execute on a device.

  3. Select Execute Script on Devices from the Actions menu. This option is enabled only when the script is staged.

    The Execute Script on Device(s) page appears. If the selected script is already disabled on the devices, then Junos Space displays the following message instead of the Execute Scripts on Device(s) page:

    Disabled script cannot be executed.

    By default, the Execute Script on Device(s) page lists the devices on which the latest version of the script is staged. If no devices are listed, it means that the latest version of the script is not staged yet. If you have staged the previous versions of the script, select one of the staged versions from the Version list. The page displays the list of devices on which this version of the script is staged.

    Note

    To find out which version of the script is staged, select the script and click View from the Associations column on the Scripts page. The Staged Version column displays the version of the script that is staged.

  4. Select the devices on which you want the script to be executed, by using one of the following selection modes—manually, on the basis of tags, or by using a comma-separated values (CSV) file. These options are mutually exclusive. If you select one, the others are disabled.

    Note

    By default, the Select Device Manually option is selected and the list of devices that can be selected is displayed.

    • To select devices manually:

      • Click the Select Device Manually option and select the device(s) that have the script staged on them. The Select Devices status bar shows the total number of devices that you selected; the status bar is dynamically updated as you select the devices.

      • To select all the devices, select the check box in the column header next to the Host Name column.

    • To select devices on the basis of tags:

      1. Click the Select by Tags option. The Select by Tags list is activated.
      2. Click the arrow on the Select by Tags list. A list of tags defined on devices in Junos Space Platform appears, displaying two categories of tags—Public and Private.Note

        No tag is displayed if none of the devices is associated with any tag. You need to tag the devices on the Device Management page before you can use the Select by Tags option.

      3. To select tags, perform one of the following actions:
        • Select the check boxes next to the names of tags that you want to select and and click OK.

        • To search for a specific tag, enter the first few letters of the tag name in the Select by Tags field to the left of the OK button. Suggestions appear if there are matches for the string you enter. Select the suggested match and click OK.

        As you select the tags, the total number of devices associated with the selected tags appears just above the device display table. For example, if there are six devices associated with the selected tags, then 6 items selected is displayed.

        The selected tags appear next to the Tags Selected label. An [X] icon appears after each tag name. You can click the [X] icon to clear any tag from the list. The device count is updated accordingly.

        The device display table displays the devices associated with the selected tags.

    • From Junos Space Platform Release 17.2R1 onward, when you select devices by CSV, you can choose to select all managed devices. Select the Include All Managed Devices check box to list all managed devices for selection.

      To select devices by using a CSV file:

      1. Select the Select by CSV option.
      2. Click Browse to navigate to the file location on your computer and select the CSV file containing the list of devices on which you want to execute the script.Tip

        For a sample CSV file, click the Sample CSV link. You are prompted to save the file. Save the file to your computer and open it by using an application such as Microsoft Excel.

      3. Click Upload to upload the CSV file.

        From Release 16.1R2 onward, when you upload a CSV file to select devices from, Junos Space Platform verifies the devices in the CSV file. If the CSV file contains devices to which the changes do not apply, the following warning message appears: Few devices are not selected due to precondition failure. Please click "View inapplicable devices" for more details.

        Click the View inapplicable devices link to review the list of devices that are excluded from the update. The reason for exclusion is listed as an error message against each device.

    • From Junos Space Platform Release 18.2R1 onward, you can select devices based on saved filters

      To select devices by using a saved filter:

      1. Select the Select by Filter option.
      2. Select the filter from the list of saved filters.

        The devices associated with the selected filter appears in the grid.

  5. (Optional) To specify values for script execution parameters, click Value.

  6. (Optional) To schedule a time to execute the script, select the Schedule at a later time check box and use the calendar icon and drop-down list to specify the date and time, when you want the script to be executed, respectively.

  7. Click Execute.

    The selected scripts are executed on the devices, and the Execute Script Information page displays a link to the job ID.

  8. Perform one of the following actions on the Execute Scripts Information page:

    • To verify the status of this job, click the job ID on this page.

      The Job Management page appears. Double-click the the row corresponding to the script execution job to view the Script Management Job status page. Click the View Results link in the Description column to view the results of script execution. The Script Execution Job Results page allows you to read and understand the script execution results. From Release 17.2R1 onward, the summary of the job of script execution in Junos Space Platform shows the Total requests, Success, and Script Failure counts. The description of possible status for script execution is as follows:

      • Success—Script successfully executed on devices.

      • Failure—Unable to execute the script on the device because the device is down or not reachable.

      • Script Failure—Script executed on the device, but the execution resulted in an error.

      Click the [X] icon to close this page.

    • Click OK to go back to the Scripts page.

You can export details about the execution of a script as a comma-separated values (CSV) file to your local file system:

  1. On the Junos Space Platform UI, select Jobs > Job Management.

    The Job Management page appears.

  2. Double-click the row corresponding to the script execution job.

    The Script Management Job Status page appears. The status of the job is Success, Script Failure, or Failure. If there is an error, the View Job Details page displays an error message. For more information about the error messages, see Common Error Messages in Device-Related Operations.

  3. Click Export as CSV.

    You are prompted to save the file.

  4. Click OK on the File Save page to save the file to your local file system.
  5. After you save the file, to return to the Job Management page, click OK on the Exporting Script Job page.

    Use an application such as Microsoft Excel to open the file from your local system. Typically, you can view the script output in the Description column of this file.

You can view details of script execution tasks from the Device Management page (Devices > Device Management) by selecting one or more devices and selecting View Script Executions from the shortcut menu (Devices > Device Management > Select a device > Device Inventory). This option displays only the results of op scripts executed on the device and not the commit or event scripts.

Release History Table
Release
Description
From Junos Space Platform Release 18.2R1 onward, you can select devices based on saved filters
From Junos Space Platform Release 17.2R1 onward, when you select devices by CSV, you can choose to select all managed devices. Select the Include All Managed Devices check box to list all managed devices for selection.
From Release 17.2R1 onward, the summary of the job of script execution in Junos Space Platform shows the Total requests, Success, and Script Failure counts.