Managing Assets
Assets overview
An asset is a script that runs automation in CloudShell sandboxes. CloudShell supports two types of scripts:
- Python scripts that run on the resource/App/blueprint level: 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.
- Repository Assets are Configuration Management scripts (bash/PowerShell) or Ansible playbooks that run on resources. For Configuration Management that runs on deployed Apps, see Adding App templates.
For brevity, the term "script" denotes both Python scripts and repository assets, unless indicated otherwise.
Out-of-the-box orchestration 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 Getting Started with Orchestration Scripts.
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.
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:
-
In the Manage dashboard, from the left sidebar, select Assets > Blueprint, or Assets > Resource.
The respective script catalog opens, displaying the blueprint or resource scripts/assets that were previously added to CloudShell, and related details, including: Name, Type, Version, Blueprints or resource Models, Type, Domains, and Modified by date and time.
noteClicking Manage > Assets opens the Script/Blueprint catalog by default.
-
To filter the list by domain, from the Domain dropdown list, select All Domains or a particular domain.
-
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.
-
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.
- The script is added to the domain you are currently in. To expose the script to all domains, add the script in the Global domain
- By default, new scripts are added into CloudShell as Python 3 scripts. Therefore, if you're adding a Python 2 script, make sure to change the script's Type, as explained in Editing scripts.
To add blueprint and resource scripts:
-
In the Manage dashboard, from the left sidebar, select Assets > Blueprint or Assets > Resource to open the respective script catalog.
noteRepository assets only apply to resource-level components.
-
In the toolbar, click + Add Python Script to add a Python script or + Add Repository Asset to add a Configuration Management script/playbook.
A dialog box is displayed, prompting you to select a script to upload.
-
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
This section explains how to edit a Python script or repository asset's default parameters.
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.
To edit Python scripts:
-
In the Manage dashboard, from the left pane, select Assets > Blueprint or Assets > Resource to open the respective script catalog.
-
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.
-
Edit the relevant fields, as described in the following table:
Field | Description |
---|---|
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:
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:
|
Type | Select the Python version of the script. Options are Python 2 or Python 3. The default setting is Python 3, but the CloudShell admin can change it via the Notes
|
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. |
-
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.
-
Click Apply to apply the changes and keep the window open.
-
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.
To edit repository assets:
-
In the Manage dashboard, from the left pane, select Assets > Resource to open the Resource Assets catalog.
-
Click the Name of the repository asset you want to edit.
Or-
Click the asset's More actions button and select Edit.
The Edit Script dialog box is displayed.
-
Edit the relevant fields, as described in the following table:
Field | Description |
---|---|
Name | The name of the asset. Edit as required. |
Visibility | Determines who can see the asset in the diagram's Commands pane:
|
Description | Type the relevant text to clearly describe the asset. |
Select Tool | Select the resource's installation and configuration tool.
Depending on the selection, additional options may become available. |
Connection Method | The method to use to connect to the resource. Select:
note To run configuration management on a Windows machine, the machine must have WinRM enabled. For details, see Enable WinRM on Windows VMs to Support Configuration Management. |
URL | Details of the Ansible playbook or custom script. Unlike for Apps, resources support only one Configuration Management script or playbook.
tip The URL can accept parameters defined on the App, enabling you to test new versions of scripts without affecting consumer-ready versions. For example, you can have an App everyone is using, but if you want to test a version you're developing, simply change the value of the URL parameter in the test blueprint.
|
User/Password | (For private repositories) Access credentials or token to the script/playbook's online repository. |
Token | (For private repositories) Access token to the script/playbook's online repository. For GitHub and GitLab, specify the API token. For BitBucket Data Center, specify the personal access token. |
Inventory Groups | (For Ansible) Specify the host groups for the Configuration Management to be installed, separated by semicolons (;), thus allowing plays that target these groups to run on the resource. For example: |
Models | From the dropdown list, select the relevant resource models associated with the asset. |
Category | Type the category name. In an active sandbox, in the Resource Commands pane, the resource is arranged according to these categories. |
Alias | The alias for the repository asset. Edit as required. In an active sandbox, in the Resource Commands pane, the asset appears under this alias. |
-
To add additional parameters to the asset, 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 asset.
These parameters will be available for editing when running the asset in an active sandbox.
To edit and delete the asset parameters, click the adjacent Edit or Delete button.
-
Click Apply to apply the changes and keep the window open.
-
Click Save to save the changes and close the window.
The details of the update asset are displayed in the Resource Assets catalog.
Downloading scripts
You can download uploaded scripts to save them in your system.
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:
-
In the Manage dashboard, from the left pane, select Assets > Blueprint or Assets > Resource.
The respective blueprint or resource script catalog is displayed.
-
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.
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:
-
In the Manage dashboard, from the left pane, select Assets > Blueprint or Assets > Resource.
The respective blueprint or resource script catalog is displayed.
-
Select the check boxes next to the relevant scripts that you want to delete.
-
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?.