How to create VM checkpoints using Orchestrator Runbook

Well, if anyone googled “How to create VM checkpoints using Orchestrator Runbook” that gives feeling person who searched this term is new with Orchestrator Runbook concept however he/she is aware about Virtualization, Checkpoints, and PowerShell and now he/she wanted to move a step forward to do the same with System Center.

Alright, before going into the details that how we can do the same with System Center Orchestrator, let me brief about System Center, Orchestrator, Runbooks, and VM Checkpoint. Certainly, after this we will walk through step-by-step to understand Runbooks automation.

System Center:  Microsoft System Center is a bundled suite of systems management products that offers tools to monitor and automate virtualized environments, including private clouds based on Microsoft Hyper-V.

Orchestrator: Orchestrator is a workflow management solution for the data center

Runbooks: Runbooks contain the instructions for an automated task or process.

Checkpoints: Checkpoint saves the state of each virtual hard disk that is attached to a virtual machine and all of the hard disk’s contents, including application data files.

There are other ways also to create VM checkpoints like-

Creating Checkpoint Using Hyper-V Manager

CP1.png

Creating Checkpoint Using PowerShell script

Get-SCVirtualMachine | where {$_.Status -eq "PowerOff" -and $_.Name -eq "VM_Name"} | New-SCVMCheckpoint -Name Checkpoint_Name

Creating Checkpoint Using Orchestartor Runbook

To create checkpoint System Center should be installed in your server and Runbook Designer should be open as Administrator.

Step 1:

Create a runbook.

  1. Right click on Runbook > New > Runbook.
  2. Rename it.
  3. Click on Check In icon link.

CP7

CP4

CP5

CP6

Step 2:

Drag and Drop activities in Runbook Designer design workplace from Activities pane.

Scenario: To create checkpoint for any VM following points are required-

  • Script required user inputs for VM name and checkpoint name.
  • Script should get the status of VM, if VM is in Running status then it should be shutdown before taking the checkpoint.
  • Script should take the screenshot.
  • After taking the screenshot script should leave VM in original state.

Alright so our scenario is ready, now its time to add different activities in design workspace.

  1. Select Runbook Control activities.
  2. Drag and drop Initialize Data activity in design workspace.
  3. Double click on Initialize Data activity.
  4. Add two parameters by clicking on Add button.
  5. Change the parameters name as per your wish by clicking on parameters name. CP8
  6. Click on Finish button.
  7. Select SC 2016 Virtual Machine Manager activity.
  8. Drag and drop Get VM activity in Design Workspace.
  9. To create a link from the Initialize Data activity to the Get VM activity, click and drag the right arrow of the Initialize Data activity to the Get VM activity.
  10. Double click on Get VM activity.
  11. Click the ellipse () button to the right of the Name box, and then select specified server name.
  12. Click on Add button.
  13. Make sure Name field is displaying VM Name value.
  14. Right click on Value field > Subscribe > Published Data.
  15. Select VM Name (a parameter which we have set in Initialize Data activity)
  16. Click on OK button.
  17. Click on OK button.
  18. Click on Finish button.
  19. Drag and Drop Shut Down VM activity from SC 2016 Virtual Machine Manager.
  20. To create a link from the Get VM activity to the Shut Down VM activity, click and drag the right arrow of the Get VM activity to the Shut Down VM activity.
  21. Double click on connecting arrow of Get VM to Shut Down VM.
  22. Click on Add button to add new condition.
  23. Click on newly added Get VM link.
  24. Select Status and click on OK button.
  25. Click on value link and changed to ‘Running’.
  26. Click on OK button.
  27. Now condition should look like this “Status from Get VM equals Running”
  28. Click on Finish button.
  29. Double click on Shut Down VM activity.
  30. Click the ellipse () button to the right of the Name box, and then select specified server name.
  31. Right click on next to VM ID > > Subscribe > Published Data.
  32. Select VM ID and click on OK button.
  33. Click on Finish button.
  34. Select Monitoring from activities.
  35. Drag and drop Get Computer/IP Status activity.
  36. To create a link from the Get VM activity to the Get Computer/IP Status activity, click and drag the right arrow of the Get VM activity to the Get Computer/IP Status activity.
  37. To create a link from the Shut Down VM activity to the Get Computer/IP Status activity, click and drag the right arrow of the Shut Down VM activity to the Get Computer/IP Status activity.
  38. Double click on Get Computer/IP Status activity.
  39. Right click Computer text field > > Subscribe > Published Data.
  40. Select VM ID and click on OK button.
  41. Click on Finish button.
  42. Right click on Get Computer/IP Status activity and select looping…
  43. Select Enable checkbox.
  44. Enter 30 Delay between attempts.
  45. Click on Finish button.
  46. Select SC 2016 Virtual Machine Manager activity.
  47. Drag and drop Create Checkpoint activity in Design Workspace.
  48. To create a link from the Get Computer/IP Status activity to the Create Checkpoint activity, click and drag the right arrow of the Get Computer/IP Status activity to the Create Checkpoint activity.
  49. Double click on arrow between Get Computer/IP Status and Create Checkpoint activity.
  50. Click on Success link and select failed checkbox.
  51. Click on Finish button.
  52. Double click on Create Checkpoint activity.
  53. Click the ellipse () button to the right of the Name box, and then select specified server name.
  54. Right click on next to VM ID > > Subscribe > Published Data.
  55. Select Get VM activity from Activity select field.
  56. Select VM ID and click OK button.
  57. Click on Optional Properties button.
  58. Select Name and click on >> button.
  59. Click on OK button.
  60. Right click on next to Name > > Subscribe > Published Data.
  61. Select Initialize Data activity from Activity select field.
  62. Select second parameter for checkpoint which we have set during Initialize Data activity. In my case, I have given CP Name.
  63. Click on OK button.
  64. Click on Finish button.
  65. Drag and drop Start VM activity from SC 2016 Virtual Machine Manager.
  66. To create a link from the Create Checkpoint activity to the Start VM activity, click and drag the right arrow of the Create Checkpoint activity to the Start VM activity.
  67. Double click on Start VM activity and Click the ellipse () button to the right of the Name box, and then select specified server name.
  68. Right click on next to VM ID > > Subscribe > Published Data.
  69. Select Get VM activity from Activity select field.
  70. Select VM ID and click OK button.
  71. Click on Finish button.
  72. Click on Check In icon link to save the runbook.

OK, after all these steps your runbook should look like this-

CP9

  • Now click on Runbook Tester link.
  • Click on Step Through link.

CP10

Once you pass VMName and CPName, it will start creating checkpoint by given name.

It may look lengthy process but once you get the flow of activities then it is very easy to automate complex task in few minutes. Remember, in the background engine is PowerShell script only.

Hope all the details are making sense. In the next blog I would discuss how to inject PowerShell script in the runbook and how to integrate Runbook to System Center Service Manager.