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.
After upgrading to Centos 7, Remote Procedure Calls (RPC) command based scripts are not working in Junos Space Network Management Platform Release 21.1R1 and later versions. It is recommended to replace the RPC based script with CLI based script.
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.
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:
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.
Select the op script that you want to execute on a device.
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.
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:
Click the Select by Tags option. The Select by Tags list is activated.
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.
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:
Select the Select by CSV option.
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.
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:
Select the Select by Filter option.
Select the filter from the list of saved filters.
The devices associated with the selected filter appears in the grid.
(Optional) To specify values for script execution parameters, click Value.
(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.
Click Execute.
The selected scripts are executed on the devices, and the Execute Script Information page displays a link to the job ID.
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:
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.
Change History Table
Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.