Executing Workflows

This chapter contains the following sections:

Workflow Execution

When you execute a workflow, a service request is created. You can execute a workflow directly, schedule a workflow to run later, or create a trigger to run a workflow when certain conditions are met. You can also create a policy to execute workflows on VMs.

Each of these options is briefly outlined here.

  • Execute a Workflow Directly - You can execute a selected workflow immediately. Navigate to the Policies > Orchestration > Workflows tab or open the Workflow Designer, then choose Execute Now.

  • Schedule a Service Request to be Executed Later - You can schedule execution of a selected workflow. Navigate to the Policies > Orchestration > Workflows tab, choose Schedule.

  • Trigger Conditional Workflow Execution - You can create a trigger to execute a workflow when a set of conditions is met. Navigate to the Policies > Orchestration > Workflows tab, then choose Triggers.

  • Create an Action Policy - You can create a policy to execute workflows on VMs within a virtual data center (vDC). Navigate to the Policies > Orchestration > Workflows tab, choose User VM Action Policy, then add the policy to a vDC.

Detailed instructions and examples are given in the following sections.

Executing a Workflow

You can execute a workflow immediately from either the Workflows page or the Workflow Designer.


    Step 1   Navigate to the Workflows page. From the menu, choose Policies > Orchestration, then choose the Workflows tab.
    Step 2   Select the workflow you want to execute by navigating to it on the Workflows page (it might be in a directory or subdirectory).

    Optionally, open the workflow in the Workflow Designer by clicking the Workflow Designer action.

    Step 3   Click the Execute Workflow action.
    • If you are in the Workflow Designer, the button is near the upper right of the window.
    • If you are on the Workflows page, select the action from the task bar or from the drop-down menu at the right of the task bar.
    Step 4   In the Executing Workflow dialog, choose the version of the workflow you want to run.
    Step 5   Also in the Executing Workflow dialog, set user inputs for the workflow.

    The input controls show the workflow inputs that you are allowed to change as a user.

    If an input is mandatory and has no default input, you must provide a user input.

    Note   

    Workflow inputs can be defined with values (admin inputs) that cannot be overridden at runtime. Admin inputs are not displayed in the Executing Workflow dialog.

    Step 6   Click Submit. The Service Request Submit Status dialog appears.

    What to Do Next

    In the view Service Request Submit Status window, click Show Detail Status to see the progress of the service request.

    Example: Executing a Workflow

    This example demonstrates executing a workflow directly.

    Before You Begin

    Create the example workflow as described in Example: Creating a Workflow.


      Step 1   Navigate to Policies > Orchestration.
      Step 2   Click the Workflows tab.
      Step 3   Locate and select the PowerCycleVM workflow you created in Example: Creating a Workflow.
      Step 4   In the Executing Workflow dialog, click Submit.
      Step 5   In the view Service Request Submit Status window, click Show Detail Status.
      Step 6   In the Service Request dialog, click the Workflow Status tab. On the status page is a graphic of the service request's progress.
      Step 7   Click the Log tab to view the service request log.
      Note   

      Click the Refresh button to view the latest updates to the log.


      What to Do Next

      Click the Workflow Status tab and record the Request ID from the report. You can view the status of a service request by ID at any time; see Viewing Service Requests.

      Click Close to leave the Service Request dialog.

      Creating a Workflow Trigger

      You can define a trigger to execute a workflow when specific conditions are met. These conditions are typically the states of various system components. When you enable a trigger, UCS Director monitors the system state and when the trigger conditions are met executes the workflow you specify.

      To create a workflow trigger, follow these steps:


        Step 1   On the menu bar, choose Policies > Orchestration.
        Step 2   Choose the Triggers tab.
        Step 3   Click Add.
        Step 4   In the Add Trigger: Trigger Information screen, complete the following fields:
        Name Description

        Trigger Name field

        The name of trigger.

        Is Enabled check box

        Enables the trigger. (You can create and save a trigger, then enable it later.)

        Description field

        A description of the trigger.

        Frequency drop-down list

        The period between checks for the trigger rule. The choices for this period span three minutes to one month.

        Trigger Type drop-down list

        Choose the trigger type:

        • Stateful—The last trigger state is recorded and actions are executed when there is a change in the trigger state. (The trigger state is Active when the trigger conditions are met, and Clear otherwise.) You choose workflows for both trigger state transitions: one for when the trigger state changes from Active to Clear, and one for when the trigger state changes from Clear to Active. The trigger state is checked at the frequency specified in the Frequency drop-down list.

        • Stateless—The trigger is executed anytime the trigger conditions are met, at a frequency specified in the Frequency drop-down list.

        Step 5   Click Next.
        Step 6   Specify the trigger conditions.
        1. In the Add Trigger: Specify Conditions screen, do the following: Click (+) to create a condition in the conditions list.
        2. In the Add Entry to Monitor dialog box, complete the following fields:
          Name Description

          Type of Object to Monitor drop-down list

          What type of object to monitor with this condition.

          Object drop-down list

          Choose the particular object to monitor. Entries in this list vary depending on the type of object. You might need to specify additional information (a pod, for example) to filter for the object.

          Parameter drop-down list

          Choose an operational parameter to monitor. Entries in this list vary depending on the object.

          Operation drop-down list

          Choose the relational operation for the trigger comparison. Entries in this list vary depending on the possible states of the parameter.

          Value drop-down list

          Choose the value with which to compare the parameter. When the relation defined by Parameter, Operation, and Value is true, the trigger state is Active; otherwise, the trigger state is Clear.

        3. Click Submit.
        4. Repeat the previous two steps to add more trigger conditions.
        5. Choose one of the two options in the Trigger When drop-down list:
          • Choose All Condition(s) Satisfied to specify that the trigger state is true only when all of the trigger conditions are met.

          • Choose Any Condition(s) Satisfied to specify that the trigger state is true if one or more of the trigger conditions are met.

        Step 7   Click Next.
        Step 8   In the Add Trigger: Specify Workflow screen, choose the workflow or workflows to execute on the trigger:
        1. In the Select Workflow drop-down list under When Trigger State Becomes Active, choose a workflow. This workflow is executed:
          • Whenever the trigger state is Active (polled at a frequency specified in the Frequency drop-down list), if the trigger is stateless.

          • If and only if the trigger state has changed from Clear to Active since last checked one period ago (as specified in the Frequency drop-down list), if the trigger is stateful.

        2. If you chose the stateful trigger type, in the Select Workflow drop-down list under When Trigger State Becomes Clear, choose a workflow. This workflow is executed if and only if the trigger state has changed from Active to Clear since last checked one period ago (as specified in the Frequency drop-down list).
        Step 9   Click Next.
        Step 10   In the Add Trigger: Specify Workflow Inputs screen, enter all the required inputs for the workflow, and any needed optional inputs.
        Note   

        You must enter all inputs that are needed by the workflow. There is no opportunity for user input in a triggered workflow.

        Step 11   Click Submit.

        What to Do Next

        You can enable or disable a trigger by selecting the trigger in the Policies > Orchestration > Triggers tab and checking or unchecking the Is Enabled check box.

        Example: Creating a Trigger to Execute a Workflow

        This example demonstrates creating a trigger to execute a workflow when a set of conditions are met.


          Step 1   Create a workflow with a single task as follows:
          1. Create the workflow as described in the following table.
            Name Description

            Workflow Name text field

            Type VM Power Event Notify.

            Description text box

            Type Sends an email when a VM changes power state.

            Workflow Context drop-down list

            Choose Any.

            Select Folder drop-down list

            Choose Orchestration Examples.

          2. Create an input as described in the following table:
            Name Description

            Input Label text field

            Type Admin Emails.

            Input Description text box

            Type Email addresses to send power event notifications.

            Optional check box

            Leave unchecked.

            Input Type drop-down list

            Choose email_address_list.

            Value Restrictions selections

            Do not select the Admin Input check box.

          3. Do not define any user outputs.
          4. In the Workflow Designer, add a Send Email task to the workflow.
          5. Complete the task information as described in the following table:
            Name Description
            Task Information page

            Task Name text field

            Type VMPowerEventEmail.

            User Input Mapping page

            Email Addresses (Mandatory) heading

            Click the Map to User Input check box.

            Task Inputs page

            Subject text field

            This is the subject line of the notification email. Type VM power event notification.

            Body text box.

            This is the body of the notification email. Type One of the following VMs has had a power -on or power-off event: (list the VMs in your VMPowerCycle workflow).

            Value Restrictions selections

            Do not select the Admin Input check box.

          6. On the User Output Mapping page, do not map any outputs.
          7. Validate the workflow, then exit the Workflow Designer.
          Step 2   Click the Triggers tab.
          Step 3   Click the Add action.
          Step 4   On the Trigger Information page, complete the following fields:
          Name Description

          Trigger Name text field

          Type VMPowerEvent.

          Is Enabled check box

          Leave this box checked.

          Description text box

          Type Executes VMPowerEventEmail when a power-on or power-off occurs on a monitored VM.

          Frequency drop-down list

          To test the trigger, you want a short time between polls. Choose 3 minutes.

          Trigger Type drop-down list

          Choose Stateful. This causes the trigger to activate when a condition changes between polls.

          Step 5   On the Specify Conditions page, add some conditions.
          1. Click the + icon to add a condition as specified in the following table:
            Name Description

            Type of Object to Monitordrop-down list

            Choose VM.

            Object drop-down list

            Select a VM to be monitored.

            Parameter drop-down list

            Choose Power Status.

            Operation drop-down list

            Choose Equals.

            Value drop-down list

            Choose ON.

          2. Repeat the last step to add more VMs to be monitored. Each VM has its own condition.
          3. In the Trigger When drop-down list, select Any Condition(s) Satisfied.
          Step 6   On the Specify Workflow page, complete the fields as specified in the following table:
          Name Description

          Maximum Invocations drop-down list

          For demo purposes, choose 20. You might choose Unlimited in an actual production application.

          When Trigger State Becomes Active heading

          In the Select Workflow drop-down list, choose VMPowerEventNotify. The trigger executes this workflow when any of your monitored VMs changes from OFF to ON as defined on the Specify Conditions page.

          Note   

          Items appear by serially assigned ID number in the drop-down list, so your workflow is at the bottom of list.

          When Trigger State Becomes Clear heading

          In the Select Workflow drop-down list, choose VMPowerEventNotify. The trigger executes this workflow when any of your monitored VMs changes from ON to OFF as defined on the Specify Conditions page.


          What to Do Next

          Test the trigger by turning on or off one of the monitored VMs. Make sure that the VM's state remains changed for at least three minutes. The trigger polls the state, so any change that is not visible at the time of polling (on and back off during the three minute wait interval, for example) does not activate the trigger.

          Scheduling a Service Request

          You can schedule execution of a workflow for a specific time.


            Step 1   On the menu bar, choose Policies > Orchestration.
            Step 2   Choose the Workflows tab.
            Step 3   In the Workflows pane, choose the workflow that you want to schedule.
            Step 4   Click Schedule.
            Step 5   In the Schedule Workflow screen, complete the following fields:
            Name Description

            Recurrence Type drop-down list

            Whether and at what frequency you want the workflow execution to recur. Choose one of the following:

            • No End—Execute the workflow repeatedly without end at intervals defined by Frequency Type and Frequency Interval, starting at Start Time.

            • Only once—Execute the workflow only once, at Start Time.

            • Fixed Number of Times—Execute the workflow a number of times specified by Repeat Count at intervals defined by Frequency Type and Frequency Interval, starting at Start Time.

            • End by Date—Execute the workflow until the defined end time at intervals defined by Frequency Type and Frequency Interval, starting at Start Time.

            Start Time field

            The time at which to start the workflow execution (or the first of a series of recurring executions).

            Frequency Type drop-down list

            The unit of the recurrence frequency interval. Choose hourly, daily, weekly, or monthly.

            Frequency Interval drop-down list

            Choose the interval at which the workflow needs to be executed for the frequency that you chose. For example, if the Frequency Interval is four and the Frequency Type is daily, the workflow is executed every four days.

            User ID field (optional)

            The user ID to run the workflow.

            Note    You must provide inputs with the workflow. Scheduled workflows do not accept user input.

            What to Do Next

            Choose the Workflow Schedules tab to view scheduled workflows.

            In the Workflow Schedules pane, you can modify a scheduled workflow by choosing a workflow and clicking the Edit button. The Modify Workflow Schedule dialog box appears. Modify the fields described in the previous steps. The Modify Workflow Schedule dialog box is identical to the Schedule Workflow dialog box.

            Example: Scheduling Workflow Execution

            This example demonstrates how to schedule a workflow for later execution.

            Before You Begin

            Create the example workflow as described in Example: Creating a Workflow.


              Step 1   Navigate to Policies > Orchestration.
              Step 2   Click the Workflows tab.
              Step 3   Choose the VMPowerCycle workflow.
              Step 4   Click the Schedule action.
              Step 5   In the Schedule Workflow dialog, complete the fields as described in this table:
              Name Description

              Recurrence Typedrop-down list

              Choose Only once. You might choose other values in an actual production application.

              Start Time date and time controls

              Choose today's date and set a time a few minutes later than your current time.

              Use ID text field

              Type the administrator ID you are signed in as.

              Step 6   Click Submit.

              What to Do Next

              Click the Workflow Schedules tab. The scheduled workflow is listed.

              Check the service request queue at the time you specified in the Start Time control. See Viewing Service Requests. A service request is generated for the workflow you specified.

              Using VM Action Policies

              You can create a user VM action policy to apply to virtual data centers (VDCs). The policy contains workflows that can be run on VMs within that VDC.


              Note


              Only one VM action policy can be assigned per VDC.


              To create a VM action policy, do the following:


                Step 1   On the menu bar, choose Policies > Orchestration.
                Step 2   Choose the User VM Action Policy tab.
                Step 3   Click Add.
                Step 4   In the Add Policy: Create New Policy screen, complete the following fields:
                Name Description

                Policy Name field

                The policy name.

                Policy Description field

                A description of the policy.

                Select No of Actions drop-down list

                The number of actions defined by the policy. One action specifies a single workflow.

                Step 5   Click Next.
                Step 6   For each VM Action in the Add Policy: Add VM Actions screen, complete the following fields:
                Name Description

                Action Label field

                The label for the VM action. The action is available when you select a VM that is part of a virtual data center (VDC) to which the action policy is applied.

                Workflow drop-down list

                The workflow represented by this action.

                Authorized User Types drop-down list

                The user types authorized to run the policy workflows.

                Step 7   Click Submit.

                What to Do Next

                After you create a User VM Action policy, as an administrator, you can choose this policy when you create a VDC. All VMs that belong to the VDC can then use the workflows specified in the action policy.