Script commands Visibility and Usability
You can control many aspects of how the orchestration commands appear and behave in CloudShell by editing the script from the Scripts management page.
To demonstrate these capabilities, we’ll create a simple script, which we’ll later customize. The script essentially prints out the parameters it receives and then sets the status of the sandbox to ‘Online’.
- Create a new Python file and name it customization_test.py. Add the following code:
Note that you can get the Sandbox id by using sandbox.id. The Sandbox name is also available using the sandbox.name property.
-
In CloudShell Portal, open the Manage dashboard.
-
Navigate to the Scripts sub section and select Blueprint.
-
Add the script into CloudShell by dragging the script into the Scripts – Blueprint page or add the customization_test.py script.
-
To customize the script, click the Edit button.
Setting display name, descriptions and category
-
You can set the script’s display name or alias by editing the Alias field in the edit form. Note that if you try to execute this script as a command from the API, you’ll still need to reference it by its name. Set the alias to Customization Script.
-
The Description is also easy to set via the edit form. Enter any text here, it will be displayed as a reference under the script name in the commands pane.
-
Categories help improve usability by grouping commands with a similar role or domain under a folder in the sandbox’s command pane. This grouping is for visual purposes only and does not affect API calls. For this example, let’s set the category name to ‘Customization’.
Adding parameters
Our script expects two parameters, but CloudShell has no way of knowing that. We need to add these parameters in this same form.
-
Click the Add Parameter link at the bottom of the form.
-
Set the Name as ‘first_param’ and the Default Value as ‘None’. Note that if the command parameters don’t have default values, they will become mandatory and the user won’t be able to execute the command without filling in values for them.
-
Then, enter a meaningful Description.
-
Repeat the process, this time for the second param, which the script expects to be named “second_param”.
Test the new look and feel
To test the script, we need to add it to a blueprint.
-
In CloudShell Portal, click Lab Management.
The Blueprints Catalog is displayed.
-
Create a new blueprint or select an existing one.
-
In the blueprint’s Properties page, associate the script with the blueprint.
-
Reserve the blueprint and open the Commands pane in the sandbox.