UCSD Power off many VM's via Loop and possible schedule

Version 2
    Task NamePower off many VM's
    Description
    1. Power off any vm's via loop
    Prerequisites
    1. Tested on 5.3
    CategoryWorkflow
    Components
    User Inputs

    Instructions for Regular Workflow Use:

    1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
    2. Unzip the file on your computer. Should end up with a .WFD file.
    3. Log in to UCS Director as a user that has "system-admin" privileges.
    4. Navigate to "Policies-->Orchestration" and click on "Import".
    5. Click "Browse" and navigate to the location on your computer where the .WFD file resides. Choose the .WFD file and click "Open".
    6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
    7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
    8. Click "Submit".
    9. A new folder should appear in "Policies-->Orchestration-->Tools" that contains the imported workflow. You will now need to update the included tasks with information about the specific environment.

     

    The request was from a very large power handler in Texas to be able to power down many VM's every Sunday.

     

    The workflow:

     

    Screen Shot 2015-11-03 at 6.06.28 AM.png

     

    Global variables and their Admin input values:

    Screen Shot 2015-11-03 at 6.07.15 AM.png

    VM_Selector_Many:  Contains the list of VM ID for the loop to run through

    VM_ID_From_Loop: Is the loop index

    Cloud:  The vCenter the workflow will collect inventory from

     

     

    The admin input selection:

     

    Screen Shot 2015-11-03 at 5.44.58 AM.png

     

    If a admin filter is selected:

     

    Screen Shot 2015-11-03 at 5.41.02 AM.png

     

    At run time this will look like this:

     

    Screen Shot 2015-11-03 at 5.42.08 AM.png

     

     

    The result at run time in vCenter:

     

    Screen Shot 2015-11-03 at 5.38.07 AM.png

     

    The case when the power off errors out since the VM is already power off:

     

    Screen Shot 2015-11-03 at 5.51.38 AM.png

     

    The resulting e-mails to the submitter:

     

    Screen Shot 2015-11-03 at 6.12.31 AM.png

     

    Things to point out in the e-mail task:

     

    Screen Shot 2015-11-03 at 6.13.20 AM.png

     

    The internal variable ${SUBMITTER_EMAIL}

    and the loop output variable

     

    Screen Shot 2015-11-03 at 6.03.48 AM.png

     

    The variables in the loop:

     

    Screen Shot 2015-11-03 at 6.14.42 AM.png

     

    Screen Shot 2015-11-03 at 6.14.49 AM.png

     

    Denote again from the global variables the variable types:

     

    Screen Shot 2015-11-03 at 6.16.30 AM.png

     

    Clean run when the selected VM's are power on:

     

    Screen Shot 2015-11-03 at 6.18.45 AM.png

     

    The log:

     

    Service Request ID: 5710

    Workflow Inputs:

    - VM_Selector_Many

    - VM_ID_From_Loop

    - Cloud

     

     

     

     

    Nov 03, 2015 11:25:20 UTC Request submitted

    Nov 03, 2015 11:25:25 UTC Executing workflow item number 1

    Nov 03, 2015 11:25:25 UTC Completed workflow item number 1, with status Completed

    Nov 03, 2015 11:25:31 UTC Executing workflow item number 2

    Nov 03, 2015 11:25:32 UTC Trigger context executeWorkFlowStep called

    Nov 03, 2015 11:25:32 UTC Executing custom action Multi_VM_Power_OFF (Start Loop)

    Nov 03, 2015 11:25:32 UTC Executing custom action Multi_VM_Power_OFF (Start Loop)

    Nov 03, 2015 11:25:35 UTC Start While task execution iteration no - 1

    Nov 03, 2015 11:25:41 UTC Task #1 (Multi_VM_Power_OFF (Start Loop)) completed successfully in 9 seconds

    Nov 03, 2015 11:25:41 UTC Input/Output values for Task #1 (Multi_VM_Power_OFF (Start Loop)):

    Nov 03, 2015 11:25:41 UTC [Local Input: List based iteration = true]

    Nov 03, 2015 11:25:41 UTC [Mapped Input: Input for list based iteration = 1145,1146]

    Nov 03, 2015 11:25:41 UTC [Local Input: User Input to assign iterated values = input_1_VM_ID_From_Loop29]

    Nov 03, 2015 11:25:41 UTC [Local Input: Count based iteration = false]

    Nov 03, 2015 11:25:41 UTC [Local Input: Number of times to loop = ]

    Nov 03, 2015 11:25:41 UTC [Output: START_LOOP_OUTPUT = 1145]

    Nov 03, 2015 11:25:41 UTC Completed workflow item number 2, with status Completed

    Nov 03, 2015 11:25:47 UTC Executing workflow item number 3

    Nov 03, 2015 11:25:47 UTC Trigger context executeWorkFlowStep called

    Nov 03, 2015 11:25:47 UTC Executing custom action Multi_VM_Power_OFF (VM Power Action)

    Nov 03, 2015 11:25:47 UTC Executing custom action Multi_VM_Power_OFF (VM Power Action)

    Nov 03, 2015 11:25:51 UTC Executing action powerOff on VM 1145 as part of custom action Multi_VM_Power_OFF

    Nov 03, 2015 11:25:51 UTC Waiting for action to complete

    Nov 03, 2015 11:25:52 UTC Initiated task, waiting for completion...

    Nov 03, 2015 11:25:56 UTC Task completed with status success

    Nov 03, 2015 11:26:21 UTC Action Complete

    Nov 03, 2015 11:26:21 UTC Task #2 (Multi_VM_Power_OFF (VM Power Action)) completed successfully in 34 seconds

    Nov 03, 2015 11:26:21 UTC Input/Output values for Task #2 (Multi_VM_Power_OFF (VM Power Action)):

    Nov 03, 2015 11:26:21 UTC [Mapped Input: Select VM = 1145]

    Nov 03, 2015 11:26:21 UTC [Local Input: VM Action = powerOff]

    Nov 03, 2015 11:26:21 UTC Completed workflow item number 3, with status Completed

    Nov 03, 2015 11:26:24 UTC Executing workflow item number 4

    Nov 03, 2015 11:26:24 UTC Trigger context executeWorkFlowStep called

    Nov 03, 2015 11:26:24 UTC Executing custom action Multi_VM_Power_OFF (End Loop)

    Nov 03, 2015 11:26:24 UTC Executing custom action Multi_VM_Power_OFF (End Loop)

    Nov 03, 2015 11:26:28 UTC End While task execution iteration no - 1

    Nov 03, 2015 11:26:28 UTC Task #3 (Multi_VM_Power_OFF (End Loop)) completed successfully in 3 seconds

    Nov 03, 2015 11:26:28 UTC Input/Output values for Task #3 (Multi_VM_Power_OFF (End Loop)):

    Nov 03, 2015 11:26:28 UTC Completed workflow item number 4, with status

    Nov 03, 2015 11:26:30 UTC Executing workflow item number 2

    Nov 03, 2015 11:26:30 UTC Trigger context executeWorkFlowStep called

    Nov 03, 2015 11:26:31 UTC Executing custom action Multi_VM_Power_OFF (Start Loop)

    Nov 03, 2015 11:26:31 UTC Executing custom action Multi_VM_Power_OFF (Start Loop)

    Nov 03, 2015 11:26:35 UTC Start While task execution iteration no - 2

    Nov 03, 2015 11:26:42 UTC Task #1 (Multi_VM_Power_OFF (Start Loop)) completed successfully in 11 seconds

    Nov 03, 2015 11:26:42 UTC Input/Output values for Task #1 (Multi_VM_Power_OFF (Start Loop)):

    Nov 03, 2015 11:26:42 UTC [Local Input: List based iteration = true]

    Nov 03, 2015 11:26:42 UTC [Mapped Input: Input for list based iteration = 1145,1146]

    Nov 03, 2015 11:26:42 UTC [Local Input: User Input to assign iterated values = input_1_VM_ID_From_Loop29]

    Nov 03, 2015 11:26:42 UTC [Local Input: Count based iteration = false]

    Nov 03, 2015 11:26:42 UTC [Local Input: Number of times to loop = ]

    Nov 03, 2015 11:26:42 UTC [Output: START_LOOP_OUTPUT = 1146]

    Nov 03, 2015 11:26:42 UTC Completed workflow item number 2, with status Completed

    Nov 03, 2015 11:26:46 UTC Executing workflow item number 3

    Nov 03, 2015 11:26:46 UTC Trigger context executeWorkFlowStep called

    Nov 03, 2015 11:26:46 UTC Executing custom action Multi_VM_Power_OFF (VM Power Action)

    Nov 03, 2015 11:26:46 UTC Executing custom action Multi_VM_Power_OFF (VM Power Action)

    Nov 03, 2015 11:26:51 UTC Executing action powerOff on VM 1146 as part of custom action Multi_VM_Power_OFF

    Nov 03, 2015 11:26:51 UTC Waiting for action to complete

    Nov 03, 2015 11:26:51 UTC Initiated task, waiting for completion...

    Nov 03, 2015 11:26:54 UTC Task completed with status success

    Nov 03, 2015 11:27:21 UTC Action Complete

    Nov 03, 2015 11:27:21 UTC Task #2 (Multi_VM_Power_OFF (VM Power Action)) completed successfully in 34 seconds

    Nov 03, 2015 11:27:21 UTC Input/Output values for Task #2 (Multi_VM_Power_OFF (VM Power Action)):

    Nov 03, 2015 11:27:21 UTC [Mapped Input: Select VM = 1146]

    Nov 03, 2015 11:27:21 UTC [Local Input: VM Action = powerOff]

    Nov 03, 2015 11:27:21 UTC Completed workflow item number 3, with status Completed

    Nov 03, 2015 11:27:23 UTC Executing workflow item number 4

    Nov 03, 2015 11:27:23 UTC Trigger context executeWorkFlowStep called

    Nov 03, 2015 11:27:23 UTC Executing custom action Multi_VM_Power_OFF (End Loop)

    Nov 03, 2015 11:27:23 UTC Executing custom action Multi_VM_Power_OFF (End Loop)

    Nov 03, 2015 11:27:27 UTC End While task execution iteration no - 2

    Nov 03, 2015 11:27:27 UTC Task #3 (Multi_VM_Power_OFF (End Loop)) completed successfully in 3 seconds

    Nov 03, 2015 11:27:27 UTC Input/Output values for Task #3 (Multi_VM_Power_OFF (End Loop)):

    Nov 03, 2015 11:27:27 UTC Completed workflow item number 4, with status Completed

    Nov 03, 2015 11:27:29 UTC Executing workflow item number 5

    Nov 03, 2015 11:27:29 UTC Completed workflow item number 5, with status Completed

     

     

    Schedule the workflow:

     

    Right click:

     

    Screen Shot 2015-11-03 at 6.20.43 AM.png

     

    And set the Schedule:

     

    Screen Shot 2015-11-03 at 6.21.11 AM.png

     

    The schedule is in place:

     

    Screen Shot 2015-11-03 at 6.22.24 AM.png