Online Help

This help article applies to CloudShell 9.3. To see the latest, click here.

Managing Scripts

In this article:

Scripts overview

A script is a single command on the blueprint or resource/App level. You can add many scripts to your blueprint or resources. CloudShell runs the scripts, which actually are processed in an external environment such as Python, which then returns the results to CloudShell.

Sandbox environment automation and enhanced orchestration is available with CloudShell Premium Tier.

Out-of-the-box scripts

CloudShell provides the following orchestration scripts out-of-the-box. These scripts are included in the CloudShell Sandbox Template but can also be added and removed from blueprints as appropriate.

  • Default Sandbox Setup
  • Default Sandbox Teardown
  • Default Sandbox Save
  • Default Sandbox Restore

To learn how to develop scripts for CloudShell, see the CloudShell Developer Guide.

Viewing scripts

In the Manage dashboard, you can view a repository of the blueprint and resource scripts that were uploaded in your domain. You can filter, sort, and search the repository for scripts.

Note: Global admins can see all scripts in CloudShell, including scripts that were added to other domains, while domain admins can only see scripts that were added to the domain they're currently in.

To view existing blueprint and resource scripts:

  1. In the Manage dashboard, from the left sidebar, select Scripts > Blueprint, or Scripts > Resource.

    The respective script catalog opens, displaying the blueprint or resource scripts that were previously added to CloudShell, and related details, including: Name, TypeVersion, Blueprints or resource Models, Type, Domains, and Modified by date and time.

    Note: Clicking Manage > Scripts opens the Script/Blueprint catalog by default.

  2. To filter the list by domain, from the Domain dropdown list, select All Domains or a particular domain.
  3. To sort the list, from the Sort By dropdown list, select Modified to sort the list by date and time in chronological order, or select Name to sort the list by script name in alphabetical order.
  4. To search for particular scripts, type the relevant text in the search box at the top of the left sidebar. For example, you can search by name, type, model, or owner.

Adding scripts

Scripts give you the flexibility to customize a blueprint and make extra features available, for example, adding specialized commands that can be run in a sandbox. You can add commands through Python scripts and upload them to CloudShell Portal to be used when configuring blueprint orchestration, including PY, PYC, and ZIP files containing several Python files.

Use the steps in the following procedure to add blueprint and resource scripts to the CloudShell Portal.

Note: The script will be added to the domain you are currently in. To expose the script to all domains, add the script in the Global domain.

To add blueprint and resource scripts:

  1. In the Manage dashboard, from the left sidebar, select Scripts > Blueprint or Scripts > Resource to open the respective script catalog.
  2. In the toolbar, click +Add New Script.

    A dialog box is displayed, prompting you to select a script to upload.

  3. Browse and select a script file to upload to CloudShell, and click Open.

    The Uploading Completed message is displayed at the top of the script catalog, indicating the upload status. When completed, the Edit button is displayed on the right. For more information, see Editing scripts.

Editing scripts

You can edit a script to modify its default parameters.

To edit blueprint and resource scripts:

  1. In the Manage dashboard, from the left pane, select Scripts > Blueprint or Scripts > Resource to open the respective script catalog.

    Note: Global admins can edit any script in CloudShell while domain admins can only edit scripts that were added to the domain they are currently in.

  2. Click the Name of the script you want to edit.

    Or-

    Click the script's More actions button and select Edit.

    The Edit Script dialog box for the respective blueprint or resource script is displayed.

  3. Edit the relevant fields, as described in the following table:

    FieldDescription

    Script File

    The script file. To replace the current script file with another one, browse to the location where the required PY or PYC file is located, select the file, and click Open.

    Name

    The name of the script. Edit as required.

    Script Type

    From the dropdown list, select an option:

    • Default
    • Setup
    • Teardown
    • Save
    • Restore

      If you select Setup, Teardown, Save, or Restore, you cannot specify Category, Alias or parameters for the script.

    Note: This field is relevant for blueprint scripts only.

    Version

    Type the script version number. Remember to increment the number the next time you upload a new version of the script.

    Visibility

    (Hidden for blueprint scripts that have a Script Type defined) Determines who can see the script in the diagram's Commands pane:

    • Admin Only: Only domain admins and system admins
    • Everyone: (Default) All user types
    Type

    Select the Python version of the script. Options are Python 2 or Python 3.

    The default setting is defined by the DefaultPythonVersion configuration key.

    Note: This does not affect existing scripts, whose python version remains as is.

    Important: Python 3 automation requires Microsoft Visual C++ Redistributable 2015 to be installed on the Execution Server(s).

    Description

    Type the relevant text to clearly describe the script.

    Models

    (Relevant for resource scripts) From the dropdown list, select the relevant resource models associated with the resource script.

    Associate App installation scripts to the relevant Installation Options model(s).

    Blueprints(Relevant for blueprint scripts) Lists the blueprints that use the script. This field is only visible if the script is included in any blueprints.

    Category

    Type the category name. In an active sandbox, in the Blueprint Commands pane, the scripts are arranged according to these categories.

    Alias

    The alias for the script. Edit as required. In an active sandbox, in the Blueprint Commands pane, the scripts appear under this alias.

  4. To add additional parameters to the script, click the Add Parameter link at the bottom of the dialog box, and type the Name, Default Value, and Description of the parameter. Make sure you add parameters that are relevant for your script.

    These parameters will be available for editing when running the script in an active sandbox.

    To edit and delete the script parameters, click the adjacent Edit or Delete button.

  5. Click Apply to apply the changes and keep the window open.
  6. Click Save to save the changes and close the window.

    The updated details of the edited script are displayed in the relevant blueprint or resource script catalog.

Downloading scripts

You can download uploaded scripts to save them in your system.

Note: Global admins can download any script in CloudShell while domain admins can only download scripts that were added to the domain they are currently in.

To download blueprint and resource scripts:

  1. In the Manage dashboard, from the left pane, select Scripts > Blueprint or Scripts > Resource.

    The respective blueprint or resource script catalog is displayed.

  2. Click the script's More actions button and select Download.

    A dialog box is displayed, prompting you to open or save the file.

Deleting scripts

You can delete scripts you no longer require.

Note: Global admins can delete any script in CloudShell while domain admins can only delete scripts that were added to the domain they are currently in.

To delete scripts:

  1. In the Manage dashboard, from the left pane, select Scripts > Blueprint or Scripts > Resource.

    The respective blueprint or resource script catalog is displayed.

  2. Select the check boxes next to the relevant scripts that you want to delete.
  3. In the toolbar, click the Delete Selected button.

    Or-

    Click the script's More actions button and select Remove.

    A message is displayed, prompting you to confirm the deletion.

    The selected scripts are removed from the respective blueprint or resource script catalog.

Requirements, script dependencies, virtual environments

Each Python script's dependencies are listed in the requirements.txt file that is included in the zip file that contains the script. The dependencies are installed on the execution server by the pip installation when CloudShell prepares the Python virtual environment for the script. To use offline execution servers, the admin will need to perform several additional configurations.

For additional information, see What are Python Virtual Environments?.

Related Topics