0% found this document useful (0 votes)
365 views

Lab Guide - Automating Zerto

This document provides instructions for completing a hands-on lab to automate Zerto Virtual Replication functionality using PowerShell scripts and Zerto's REST APIs. The lab guide outlines scripts to deploy Virtual Replication Appliances, create replication groups (VPGs), troubleshoot scripts, and perform a failover test. The lab uses a "jumpbox" VM to access the scripts and documentation needed to complete the exercises interacting with Zerto APIs.

Uploaded by

Flatni Rosario
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
365 views

Lab Guide - Automating Zerto

This document provides instructions for completing a hands-on lab to automate Zerto Virtual Replication functionality using PowerShell scripts and Zerto's REST APIs. The lab guide outlines scripts to deploy Virtual Replication Appliances, create replication groups (VPGs), troubleshoot scripts, and perform a failover test. The lab uses a "jumpbox" VM to access the scripts and documentation needed to complete the exercises interacting with Zerto APIs.

Uploaded by

Flatni Rosario
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Lab Guide: 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

Zerto Automation with REST APIs Lab Guide 1 of 3


Chapter 1: Introduction
This technical lab will get you up and running with automating ZVR functionality by using PowerShell
scripting with Zerto’s REST APIs. Although you don't need to be an expert, some prior experience with
both scripting and Zerto will be helpful.

After completing this lab, you should be able to:


• Use variables in a PowerShell script
• Use CSV files with PowerShell scripts
• Use Zerto’s REST APIs with PowerShell scripts
• Troubleshoot PowerShell scripts
• Create a PowerShell script

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!

Zerto Automation with REST APIs Lab Guide 2 of 4


Chapter 2: VRA Deployment Script

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

2. Login to the production ZVM (https://192.168.111.20:9669) using these credentials:

o Username: [email protected]

o Password: ZertoLabs18!

3. From the top navigation menu, click on Setup

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

5. Double-click the Windows PowerShell ISE icon

6. Click File -> Open... to start with an existing script

7. Browse to the Zerto Automation folder located on the desktop

8. Select the file named VRA_Deployment.ps1

Zerto Automation with REST APIs Lab Guide 3 of 5


9. Once the script is opened, read through the script comments to understand what the script is
doing; for example, what method is the script using to load data about our VRAs? Also take note
of these sections in particular:

o Defining script variables up top

o Setting up the logging engine

o Setting the certificate policy for the Zerto API

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

Zerto Automation with REST APIs Lab Guide 4 of 6


13. Populate the columns of the CSV file with the following data (case sensitive):

o Column 1: ESXiHostName: 192.168.111.1

o Column 2: DatastoreName: FreeNAS-DS

o Column 3: PortGroupName: VM Network

o Column 4: VRAGroupName: default_group

o Column 5: MemoryInGB: 3

o Column 6: DefaultGateway: 192.168.111.254

o Column 7: SubnetMask: 255.255.255.0

o Column 8: VRAIPAddress: 192.168.111.35

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.

Zerto Automation with REST APIs Lab Guide 5 of 7


More Information
PowerShell ISE (Integrated Scripting Environment) is a GUI complement to PowerShell itself that allows
you to write, execute, and debug from a single application. Its helpful features include IntelliSense,
which is a predictive auto-complete tool to display matching, valid commands you can use to help
minimize typos or avoid constantly checking reference documentation.

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.

Zerto Automation with REST APIs Lab Guide 6 of 8


Chapter 3: VPG Creation Script

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

2. Open the existing script, click File -> Open...

3. Browse to the Zerto Automation folder located on the desktop

4. Select the file named VPG_Creation.ps1

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.

8. Save the CSV files (optionally, exit CSVed as well)


(Note: without saving, the scripts will not execute as expected.)

9. Open PowerShell ISE back up to edit the PS1 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.

Zerto Automation with REST APIs Lab Guide 7 of 9


14. Execute the script by pressing F5 in PowerShell ISE

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!

16. Navigate to the VPGs tab

17. Monitor the ZVM UI to see the VPGs being created

From the top "Chapter Selection" dropdown, click on the "Troubleshoot" option to proceed to the next
part of the guide.

Zerto Automation with REST APIs Lab Guide 8 of 10


Chapter 4: Troubleshoot Script

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

2. Click File -> Open...

3. Browse to the Scripts folder located on the Desktop

4. Select the file named Pause_Resume_VPG.ps1

5. Once the script is opened, read through the script comments to understand what the script is
doing

6. Execute the script by pressing F5 in PowerShell ISE

7. Review the errors within the PowerShell ISE Console

o Some mistakes may be related to variables, but others may simply be typos

o PowerShell ISE's syntax highlighting can make troubleshooting easier by quickly


identifying problem areas within the script

o Careful sleuthing should uncover a total of four problem areas

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.

Zerto Automation with REST APIs Lab Guide 9 of 11


Chapter 5: Failover Test Script

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

2. Create a new script, click File -> New

3. Populate the script with the following code sections:

o Define the script variables

o Setup the logging engine and start logging

o Set the cert policy for the Zerto API

o Build the Zerto API string and invoke to get the session header

o Get the VPG identifier to be used in the FOT

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.

5. Login to the ZVM by navigating a web browser to https://192.168.111.20:9669

o Username: [email protected]

o Password: ZertoLabs18!

6. Execute the script by pressing F5 in PowerShell ISE

Zerto Automation with REST APIs Lab Guide 10 of 12


7. Back in Chrome within the ZVM GUI, navigate to the VPGs tab

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

Zerto Automation with REST APIs Lab Guide 11 of 13


Chapter 6: Wrapping Up

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.

Key Takeaways from Zerto Automation with REST APIs


• Don't re-invent the wheel: copy from starter scripts and code samples, e.g. from Zerto's
Github or our documentation (see links below)

• Create (or borrow) re-usable code—then document it well with comments

• 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)

• Zerto Analytics API Documentation with Swagger

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.

Zerto Automation with REST APIs Lab Guide 12 of 13

You might also like