Executing Scripts on Devices Locally with JUISE
Junos Space Network Management Platform comes integrated with the Junos OS User Interface Scripting Environment (JUISE)—that is, juise-0.3.10-1 version, which enables you to execute a script on a remote device from the Junos Space server without having to stage the script on the device. To execute a script on a remote device, the following conditions must be met:
The device should be reachable from the Junos Space server.
The @ISLOCAL annotation marked within the script must be set to true. That is, the script must contain the following text:
/* @ISLOCAL = "true" */
When this annotation is set to false, you have to first stage the script on a device and then execute it. For more information about script annotations, see Script Annotations.
From the Junos Space UI, you can identify the scripts that can be executed locally by looking at the value in the Execution Type column on the Scripts page. For scripts that can be executed locally without being staged from the Junos Space server, the value is Local.
By default, JUISE is installed when you install or upgrade to Junos Space Release 13.1 or later versions.
You can execute only SLAX scripts (*.slax) by using JUISE.
To execute scripts on Junos OS devices with JUISE:
- On the Junos Space Network Management Platform UI, select Images and Scripts > Scripts.
The Scripts page appears, displaying the scripts that you imported into Junos Space Network Management Platform.
- Select the op script that you want to execute on a device.
Identify and select only those scripts that have Local displayed in the Execution Type column.
- Select Execute Script on Devices from the Actions
The Execute Script on Device(s) page appears.
- 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 the comma-separated values (CSV)
file. These options are mutually exclusive. If you select one, the
others are disabled.
By default, the Select by Device option is selected and the complete list of devices is displayed.
To select devices manually:
Click the Select by Device 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 the Junos Space system appears,
displaying two categories of tags—Public and Private.
If no tags are displayed, then it means that 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 tag names to select the desired tags 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. If a match is found, a suggestion is made. 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 decrements accordingly.
The device display table displays the devices associated with the selected tags.
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.
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.
- (Optional) To specify values for the parameters for script execution, click Enter Parameter Value for each parameter.
- 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 respectively to specify the date and time when you want the script to be executed.
- Click Execute.
The selected scripts are executed on the devices, and the Execute Script Information dialog box displays a link to the job.
Perform one of the following actions on the Execute Script Information dialog box:
To verify the status of the job, click the job ID link.
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 device(s).
Failure – Unable to execute the script on the device because 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.
To export details about the execution of a script as a comma-separated values (CSV) file to your computer:
- On the Junos Space Platform UI, select Jobs > Job Management.
The Job Management page appears.
- Double-click the row corresponding to the script execution
The Script Management Job Status page appears. The status of the job is Success, Script Failure, or Failure.
- Click Export as CSV.
You are prompted to save the file.
- Click OK in the File Save dialog box to save the file to your computer.
- After you save the file, to return to the Job Management
page, click OK in the Exporting Script Job dialog
Use an application such as Microsoft Excel to open the file from your computer. Typically, you can view the script output in the Description column of this file.