Scripting How-To: Local script to view, install or delete license keys on devices

By Erdem posted 08-10-2015 17:29



This example demonstrates the powerful functionality now available with Junos Space 13.1R1.6 and the integrration of local scripts. It describes one possible approach for installation of license keys on devices via the Junos Space GUI using a slax script that is executed locally on the Junos Space appliance and does not need to be staged and enabled on the device first.




The slax script "license.slax", can perform three different actions as shown below:


  1. List
    • Lists all currently installed installed licenses on a selected device.
  2. Install
    • Install a license key on a selected device.
  3. Remove
    • Remove a license key from a selected device.

Firstly import the script in Junos Space (Images and Scripts\Scripts, then select the Import Script icon).


Once imported

When a user selects a specific device from within the Devices\Device Management view, and selects the action Device Operations\Execute Scripts, the script will be visible to select.


Once selected the first thing that will become apparent is that there are two parameters that the script implements:


    • Enter the complete license key data when adding a license, or enter the license identifier when removing an existing license.
    • A pull down menu that is used to select the action described earlier (list, install, remove)




As can be seen in the screen shot above, a pull-down menu is available with 3 choices, and a default selection of "list".   This functionality is defined within the slax script using the VARIABLECONTEXT annotation shown below:


1 /* @VARIABLECONTEXT = "[{'name':'ACTION','defaultvalue':'list','selectionvalues':'install,list,remove'}]"*/ 

What this annotation is describing is that there is parameter within the script that is called ACTION, and it will display a default value of "list", and that it will be a selection list based upon the values defined.   When Junos Space imported this particular script, it detects that tis annotation is present (and some others too), and as a result has defined some additional metadata associated with this particular script.  Thereby knowing to display a selection list with the 3 defined choices.  Since the parameter LICENSE does not have any such definition within the annotation the default behaviour for this parameter is that it is a blank text field awaiting user input.


Some of the additional annotations defined in this script are:


1 /* @CONTEXT = "/device" */ 

2 /*