Lab Guide - Automating Zerto
Lab Guide - Automating Zerto
Automation with
REST APIs
Hands-on lab using VMware vSphere and
Zerto Virtual Replication.
Version 1.1
2018
Zerto Training
[email protected]
Table of Contents
CHAPTER 1: INTRODUCTION................................................................................................. 2
CHAPTER 2: VRA DEPLOYMENT SCRIPT ................................................................................ 3
CHAPTER 3: VPG CREATION SCRIPT ...................................................................................... 7
CHAPTER 4: TROUBLESHOOT SCRIPT ................................................................................... 9
CHAPTER 5: FAILOVER TEST SCRIPT .................................................................................... 10
CHAPTER 6: WRAPPING UP ................................................................................................ 12
Key Objectives:
1. Populate and Execute VRA Deployment Script
2. Modify and Execute VPG Creation Script
3. Troubleshoot Script
4. Create and Execute FOT Script
This lab uses a "jumpbox" (with red Zerto wallpaper) as the main VM in which we work. The jumpbox (or
"control server") is a central access point in these labs that's connected across different sites and
subnets. The jumpbox's desktop includes shortcuts to key pieces you may need, including an RDP
shortcut for the ZVM, vSphere client shortcuts, and a Chrome shortcut that opens the ZVM GUIs for
both production and DR sites.
When you're ready to get started, log into this VM with these credentials:
Username: Administrator
Password: ZertoLabs18!
TIP: on some monitors the text in the jumpbox can occasionally look fuzzy or degraded. Here's
how to easily remedy this if it happens: after logging into the jumpbox, use the Windows search
bar to locate the "Adjust ClearType text" option in the Control Panel. Enable ClearType by selecting the
checkbox, then click Next and follow the on-screen prompts; ensure you click Finish at the end to apply
the settings.
Need assistance or have questions about the labs? Please contact [email protected] and we'd be
happy to help!
In this section you will populate the variables of a script, populate the CSV file the script relies on, and
then execute the script to deploy a Virtual Replication Appliance (VRA).
Instructions
1. Start by opening the Zerto GUI. From the desktop, double-click on the Chrome shortcut
called Zerto
o Username: [email protected]
o Password: ZertoLabs18!
Since this Setup tab indicates that only one VRA is installed, we can use a script to install the
other one. The GUI is helpful for a few VRA installations, but scripts really start to help when you
have to deploy many VRAs in both production and secondary/peer sites. Zerto recommends
installing VRAs on all hosts on which protected VMs also reside. This makes protecting VMs a
breeze, even if they're vMotioned between hosts.
4. Minimize Chrome and from the desktop open the “Zerto Automation” folder
o Building the Zerto API string and invoking it to get the session header
As you read through the script, notice which parts are related to getting set up for VRA deployment
versus the lines that actually execute the deployment, which doesn't start until line 121.
10. If you noticed on line 5 we referred to a CSV file that's then invoked in line 72. Let's edit that CSV
file now by navigating to the Zerto Automation folder on the jumpbox desktop and opening the
file named VRA_Deployment.csv in CSVed
11. Right-click in the middle pane (e.g. under Column 1 or 2) and select Add Record
o Column 5: MemoryInGB: 3
14. Click Apply Changes at the bottom, then click or X to close this window
15. Save the changes to the CSV file (optionally, exit CSVed as well)
(Note: if you don't save the file, the script will not run as expected.)
16. In PowerShell ISE, update the variables section at the top of the script with the following
information:
o $ZertoServer = "192.168.111.20"
o $ZertoPort = "9669"
o $ZertoUser = "[email protected]"
o $ZertoPassword = "ZertoLabs18!"
o $SecondsBetweenVRADeployments = "30"
17. Save the changes to this VRA_Deployment.ps1 file (ctrl-S or Save icon)
18. Execute the script by pressing F5 in PowerShell ISE or clicking the Run icon
19. Back in Chrome, within the ZVR GUI, navigate to the Setup tab
20. Monitor the Setup tab in the GUI to see the VRAs being deployed; optionally, minimize Chrome
and open the "Prod vCenter" shortcut to verify the vSphere inventory shows two VRAs total (one
for each host).
From the top "Chapter Selection" dropdown, click on the "VPG Creation Script" option to proceed to the
next part of the guide.
Also, note that we're using CSVed for this lab, but of course any CSV editor would work fine here
(including Microsoft Excel).
This VRA script is typical for PowerShell scripts in that it requires a good deal of information just to get
off the ground. However, once the script imports the data from the CSV, it pushes that JSON data to the
Zerto API in order to execute; in this case, execute a VRA deployment. In the Zerto API Documentation
you can read more about what kind of JSON data our APIs require.
Instructions
In this section, you will finish modifying a script and execute the script to create a VPG.
1. From the desktop, open the Zerto Automation folder and double-click the PowerShell ISE icon
5. Once the script is opened, read through the script comments to understand what the script is
doing
6. Navigate to the Zerto Automation folder on the desktop and open the files named VPG_Creation-
VPGs.csv and VPG_Creation-VMs.csv in CSVed
7. Populate the missing column headers of the CSV files with the correct names. The column
header names can be found in the script.
10. Line 50 of the script is incomplete. Complete the line to build the base URL for API calls
11. Line 102 of the script is incomplete. Complete the line to get the localsite information from the
Zerto API
12. Populate the missing variables in the JSON body starting on line 154. The missing fields are:
o JournalHistoryInHours
o Priority
o RpoInSeconds
o HardLimitInMB
13. Line 270 of the script is incomplete. Complete the line to invoke the commit of the VPG settings,
using line 248 to assist you. If needed, refer back to line 121 in the VRA_Deployment.ps1 script
from the last chapter to see a comparable example.
15. If not already logged in, open the ZVM GUI by using Chrome to
open https://192.168.111.20:9669
o Username: [email protected]
o Password: ZertoLabs18!
From the top "Chapter Selection" dropdown, click on the "Troubleshoot" option to proceed to the next
part of the guide.
In this section you will execute a script and resolve any issues within the script to allow it to execute
successfully.
Review each error individually. In the error message, look for the line number where the error occurred.
Go back to the script to review the line which caused the error to determine the problem. Keep in mind
that some errors can be misleading as to the exact cause, but they can still be helpful for narrowing
down possible causes.
Instructions
1. Double click the PowerShell ISE icon on the desktop
5. Once the script is opened, read through the script comments to understand what the script is
doing
o Some mistakes may be related to variables, but others may simply be typos
8. Correct the errors and rerun the script until the script executes successfully
When successful, the script should pause protection on "ERP" VPG, and then resume protection after 60
seconds.
From the top "Chapter Selection" dropdown, click on the "Failover Test Script" option to proceed to the
next part of the guide.
In this section you will create a script that initiates a FOT (Failover Test) for a single VPG. It will require
using what you've learned and using your prior scripts to put together a longer, more complex script.
Review scripts from previous sections to understand the workflows and see if sections can be reused,
and you may want to consult our API documentation while writing your script.
Instructions
1. From the Zerto Automation folder on the desktop, double-click the PowerShell ISE icon
o Build the Zerto API string and invoke to get the session header
o Start the FOT (check out the More Information section below for tips!)
o Stop logging
4. Review your previously edited/saved scripts from earlier in this lab and re-use as much as you
can.
o Username: [email protected]
o Password: ZertoLabs18!
8. Monitor the ZVM GUI to see the failover test being executed—optionally, you can also us the
"Prod vCenter" icon the desktop to open the vSphere client and see the test VMs being spun up
with "testing recovery" appended to their names.
9. At this point you can either stop the tests from within the ZVM GUI or continue on the end and
the environment will be cleaned up when the lab is terminated
Congrats! Use the Chapter Selection dropdown to proceed to the final Wrapping Up section.
More Information
Although you can copy, paste, and adapt old code from the scripts in this lab, you'll need to keep a few
things in mind for executing the actual failover test:
• Remember your HTTP methods—GET, POST, and DELETE—and ensure you're using the right one
with Invoke-RestMethod
• We'd recommending building the URL string with variables as demonstrated earlier, but you'll
need to grab the exact end of the URL, for the test specifically, from our documentation on
myZerto (zerto.com/myzerto)
• As in the last chapter, pay attention to the console errors and anything in your log file—these are
invaluable when stuck with a buggy script
Congrats—you've successfully completed this lab! When you're finished entirely, please use the End
Lab button back in myZerto to shut down the lab environment; the lab will auto-shutdown after 3 hours
if not ended manually.
Please take 1-2 minutes to share feedback with us on your lab experience. Your input will help shape the
future of Zerto labs and improve the experience for others.
• Use CSVs to store key data, then have your scripts read from there rather than hard coding into
the script directly
• You can use PowerShell, as done in this lab, or leverage our APIs with the language of your
choice (e.g. Python, PHP, etc)
Key Resources
• Official REST APIs Documentation
• Automating ZVR with PowerShell and REST APIs White Paper (PDF)
You can also keep the momentum going with the other resources in myZerto, including forums,
documentation, and training in myZerto University. You can check out the API sessions that were run at
ZertoCON 2018; both videos and presentation slidedecks are available.