Life Cycle Actions
    • 06 Nov 2024
    • 10 Minutes to read

    Life Cycle Actions


    Article summary

    Life Cycle Actions are actions that are executed when specific events occur within a lab's life cycle. These actions can be used to send a web request, send a notification to a user, send an e-mail to a user, or execute a script. This guide will walk you through how to create Life Cycle Actions in a lab. For an overview of how automations is Skillable work please see Overview of How Lab Automation Works.

    Best Practices for Using Life Cycle Actions

    • When executing scripts, be sure to include proper error handling within your script.

    • Refrain from outputting data in your LCA.

    • If a Cloud Platform is specified, and the LCA depends on cloud resources to deploy and/or become available, adjust LCA execution time with either a Delay or the Fabric Build Sequence feature under the Advanced tab to make sure resources are available before the LCA attempts to run.

    Life Cycle Configuration

    Life Cycle Actions are configured to execute an action at a specified event during the life cycle of the lab.

    Add Life Cycle Actions

    To add Life Cycle Action to your lab profile, follow these steps for every Action:

    1. Select the Advanced tab, and in the new Life Cycle Actions section, select Add Life Cycle Action.

    2. From the Action Type dropdown, select the action you want performed.

    3. From the Event dropdown, select the event when you want the Action to be triggered.

    4. In the Delay box, set the number of seconds after the Life Cycle Event occurs that the Action should trigger, if wanted.

    5. In the Error Action dropdown, select the type of action to Skillable Studio will take if an error occurs.

      1. If you select Notify User as the Error Action, an Error Notification field will appear. Type the text the user will receive in the Notifications toast notification in the lab interface.

    6. Uncheck Enabled if necessary.

    7. Select OK to add the Life Cycle Action.

    Events

    Life Cycle Events include:

    Event

    Description

    Pre-Build

    the lab components are being deployed, as well as any cloud resources.

    Post-Build

    the lab environment has been built, but components like virtual machines may still be starting.

    First Displayable

    all components of the lab are now running and the user can now interact with the lab.

    Saving

    the lab is in the process of being saved.

    Saved

    the lab is in a saved state and no longer active.

    Resuming

    the lab is resuming from a saved state.

    Resumed

    the lab has been resumed from a saved state and the user can interact with the lab again.

    Scoring

    the lab has begun the process of scoring. This triggers immediately when scoring is initiated in the lab, before platform scoring is performed. If the action is blocking, this will allow the action to complete before platform scoring occurs.

    Scored

    the lab has been scored. This triggers immediately after platform scoring completes. If the action is blocking, this will allow the action to complete before the lab is torn down or returned to a running state.

    Tearing Down

    the lab environment is being torn down.

    Torn Down

    the lab environment is fully torn down.

    Optional Settings

    There are additional settings that can optionally be configured for a Life Cycle Action:

    Optional Setting

    Description

    Blocking

    this allows you to block further execution of the lab life cycle until the action completes. You can use this to sequence actions that depend on each other.

    Delay

    allows you to introduce a delay between the moment the life cycle event occurs and the action is executed.

    Timeout

    (applies to execution of cloud platform scripts and custom scripts) Controls how long Skillable Studio will wait for the script to execute before giving up. Timeouts will trigger an error that can be defined in the Error Action field.

    Repeat

    (applies to execution of cloud platform scripts and custom scripts) The life cycle action script can be repeated one or more times until it returns a value of true. This can be useful when checking the state of a remote resource. For instance, if a previous action began as an asynchronous deployment in an external platform, this action could be used to check for completion of that deployment. By returning false if the deployment is still under way and true if the deployment is complete, repeating the script will hold up the lab deployment process until your remote resource is ready.

    Note: The script must return true/false to trigger the repeat feature.

    Retries

    The number of times that script execution will be retried in the event of a script-level error. If after the specified number of attempts the script still fails to execute, it will not be attempted again. The error thrown by the script will be logged and can be retrieved on the lab instance details page. For languages that support error handling, you may catch errors to give the user a different message.

    Note: Retries should not be used in place of proper error handling within your script. Platform managed retries can have side effects such as duplicated object creating and excessively long script execution times.

    Error Action

    controls how Skillable Studio will handle errors that occur when executing this action. All errors are logged against the lab instance by default. You can also choose to notify the user about the error or to end the lab. To prevent users from losing their work, only events early in the lifecycle (Pre-build, Post-build, First Displayable, Running, etc) allow you to end the lab when an error occurs.

    Actions

    Life Cycle Actions include:

    Actions

    Description

    Send a web request

    Sends a web request to the URL specified. The URL can optionally contain placeholders that will be replaced by live data, with @lab replacement tokens.

    Send a notification to the user

    Sends a toast notification to the user during the specified event.

    Send an email to the user

    Sends an email to the user during the specified event. The subject and content of the e-mail will be the same for each lab user.

    Execute Script in Virtual Machine

    Sends a PowerShell, Bash or Shell script to a virtual machine. The user is required to be logged into a virtual machine that has the Skillable Studio integration service installed.

    Execute Script in Container

    Sends a Bash script to a container.

    Execute Script in Cloud Platform

    Sends a PowerShell script to the cloud platform.

    Execute Custom Script

    Executes a custom script that does not target a virtual machine, cloud platform, or container.

    Send Web Request

    A Web Request is used to send a URL request. The URL can optionally contain placeholders that will be replaced by live data.

    Placeholders include:

    • @lab.LabProfile.Id

    • @lab.LabInstance.Id

    • @lab.LabInstance.GlobalId

    • @lab.User.Id

    • @lab.User.ExternalId (if launched via API)

    • @lab.User.email

    • @lab.User.FirstName

    • @lab.User.LastName

    • @lab.Tag (if included when launched by API)

    Lab data can be appended to the URL.

    When Append Lab Data is enabled, the following lab data will be appended to the URL as URL parameters in the name=value format.

    • labProfileId

    • labInstanceId

    • globalLabInstanceId

    • userId

    • userExternalId (if launched via API)

    • email

    • firstName

    • lastName

    • tag (if included when launched via API)

    Web Requests have multiple verb options

    • GET

    • POST

    • DELETE

    • PUT

    Headers

    You can optionally include HTTP headers. Each header should be on a separate line and in the name=value format.

    Send Notification to User

    This will send a notification to the lab user's lab, during the specified event. This can contain plain text, or @lab replacement tokens. When the notification is sent to the lab user, information will be replaced by the @lab replacement token.

    For example, if you were to configure the notification to the below, the notification will say "Hello" followed by the lab user's first name.

    Hello, @lab.User.FirstName

    You can give the notification a name. If a name is provided, only one copy of the notification with that name will be displayed in the lab client. This allows you to replace a notification with updated text.

    Send E-mail to user

    This will send an E-mail to the lab user, during the specified event. This can contain plain text,or @lab replacement tokens. When the notification is sent to the lab user, information will be replaced by the @lab replacement token.

    Execute Script in Virtual Machine

    Scripts can be used to target a virtual machine with a PowerShell, Bash or Shell script.

    Scripts support Blocking, which allows you to block further execution of the lab life cycle until the action completes. You can use this to sequence actions that depend on each other. It is recommended to use the blocking feature if the script in the LCA will take very long to complete. Scripts also support @lab replacement tokens, that can be used in PowerShell, Bash and Shell scripts.

    Multiple script types are available:

    • PowerShell: PowerShell script execution without UI shown to the lab user.

    • PowerShell with UI: PowerShell script execution with PowerShell UI visible to the lab user.

    • Windows Command Shell: Shell script execution without UI shown to the lab user.

    • Windows Command Shell with UI: Shell script execution with Command Prompt UI visible to the lab user.

    • Bash: Bash script execution without UI shown to the lab user.

    Execute Script in Container

    Scripts can be used to target a container with a Bash script.

    Scripts support Blocking, which allows you to block further execution of the lab life cycle until the action completes. You can use this to sequence actions that depend on each other. It is recommended to use the blocking feature if the script in the LCA will take very long to complete. Scripts also support @lab replacement tokens, that can be used Bash scripts.

    Execute Script in Cloud Platform

    Cloud Platform scripts are used to target a cloud platform such as Microsoft Azure or Amazon Web Services with a PowerShell, Python, C# or JavaScript script.

    Along with traditional syntax, there is additional syntax that can be used to interact with Skillable Studio.

    • Setting Lab Variables: sets a variable that can be recalled in subsequent lab instructions using @lab replacement tokens, as many times as necessary.

    • Sending Lab Notifications: Sends a a popup notification to the lab, using the text specified in the syntax.

    Cloud Platform scripts support Blocking, which allows you to block further execution of the lab life cycle until the action completes. You can use this to sequence actions that depend on each other. It is recommended to use the blocking feature if the script in the LCA will take very long to complete.

    Cloud Platform scripts also support @lab replacement tokens, that can be used in PowerShell scripts.

    Language options include:

    Azure

    • Legacy PowerShell: uses PowerShell version 5.1.

      • Azure: Azure RM 6.8.1.

    • PowerShell: uses PowerShell version 7.1.3.

      • Azure:

        • Azure AZ 5.7.0.

        • Azure-CLI 2.22.1.

    • Python: uses Python version 3.9.4.

      • Azure: AZ SKY 1.13.0.

    • C#: (Azure Only) uses C# .NET 5.

      • Azure: Azure.Core 1.13.0.

    AWS

    • Legacy PowerShell: uses PowerShell version 5.1.

      • AWS: AWSPowerShell.netcore 4.1.3.0.

    • PowerShell: uses PowerShell version 7.1.3.

      • AWS:

        • AWS CLI 2.1.39.

        • AWS.Tools 4.1.10.0.

    • Python: uses Python version 3.9.4.

      • AWS: AWS Boto3 1.17.50.

    • JavaScript (AWS Only): uses node.js 14

      • AWS: AWS SDK for JS 3

      If a cloud platform script encounters an error, and that error is not caught, Skillable Studio will attempt to execute the script from the beginning every 60 seconds until true for up to 30 minutes. If after 30 minutes the script still fails to execute, it will not be attempted again. The error thrown by the script will be logged and can be retrieved on the lab instance details page. For languages that support error handling, you may catch errors to give the user a different message.

    Execute Custom Script

    Custom scripts allow you to execute scripts during the life cycle of a lab, using a specific package for the selected language or using native syntax for the selected language.

    Scripts executed using this method are typically used to target outside of Skillable Studio. As a best practice, it is recommended to use Execute Script in Virtual Machine to target virtual machines and Execute Script in Cloud Platform to target cloud environments.

    • PowerShell: PowerShell Gallery

    • Python: PyPi

      • Add NuGet Package

    • JavaScript: NPM

      • Add NPM Package

    • C#: Nuget

      • Add PyPI package

      If a Life Cycle Action custom script encounters an error, and that error is not caught, Skillable Studio will attempt to execute the script from the beginning every 60 seconds until true for up to 30 minutes. If after 30 minutes the script still fails to execute, it will not be attempted again. The error thrown by the script will be logged and can be retrieved on the lab instance details page. For languages that support error handling, you may catch errors to give the user a different message.

    For more information about the available languages, see our Automating Activities.

    Life Cycle Actions Management

    Once you have added Life Cycle Actions to your lab, they will be listed on the Life Cycle tab of the lab profile, organized by event. If there are more than one LCA per Event, they can be arranged in the order they should execute when the Event happens.

    To change the order, select the Up or Down arrow on the right side of the Action that you want to move. You can only move Actions within an Event. Life Cycle Actions can be edited or deleted from the buttons on the right side of it as well.

    Child Lab Profile LCA inheritance

    When a child lab profile is configured to inherit the lab environment from a parent lab profile, LCAs can optionally be set to inherit from the parent lab profile.

    To inherit Life Cycle Actions, select the checkbox on the Life Cycle tab of the child lab profile, to enable inheritance. Once inheritance is enabled, no other LCA configuration will be available on the child lab profile. All LCA changes must be made on the parent lab profile.

    Related Topics


    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.