Automating ZVR with PowerShell and REST APIs …

VERSION 4.0 MAY 2018

Automating Zerto Virtual Replication with PowerShell & REST APIs Whitepaper

Table of Contents

1 INTRODUCTION .................................................................................................................................................... 4

1.1 Use Cases .....................................................................................................................................................................4 1.2 REST APIs .....................................................................................................................................................................4 1.3 Legal Disclaimer ...........................................................................................................................................................4

2 BASICS & BEST PRACTICES....................................................................................................................................5

2.1 Requirements ..............................................................................................................................................................5 2.2 Using Variables & Arrays .............................................................................................................................................5 2.3 Encrypting Passwords..................................................................................................................................................6 2.4 Scripting Best Practices................................................................................................................................................6 2.5 Transcripts ...................................................................................................................................................................6 2.6 Loading Modules .........................................................................................................................................................7 2.7 Bypassing Certificate Warnings ...................................................................................................................................7 2.8 Establishing API Sessions .............................................................................................................................................8 2.9 Full Start of Script Example..........................................................................................................................................9

3 QUERYING & REPORTING ...................................................................................................................................11

3.1 Use Cases .................................................................................................................................................................. 11 3.1 Listing Unprotected VMs .......................................................................................................................................... 11 3.2 Using Unprotected VM IDs ....................................................................................................................................... 11 3.3 Listing Protected VMs & VPGs.................................................................................................................................. 12 3.4 Long Term RPO & Storage Reporting to CSV............................................................................................................ 13 3.5 Resource Reports...................................................................................................................................................... 15 3.6 Resource Report Use Cases ...................................................................................................................................... 17 3.7 VPG, VM, VDISK, VNIC & Re-IP Settings Report ....................................................................................................... 18

4 DAILY EMAIL REPORTS........................................................................................................................................27

4.1 Use Cases .................................................................................................................................................................. 27 4.2 Design Methodology ................................................................................................................................................ 27 4.3 Daily Email Report .................................................................................................................................................... 27

5 AUTOMATING DEPLOYMENT .............................................................................................................................67

5.1 Use Cases .................................................................................................................................................................. 67 5.2 Bulk Automated VRA Deployment ........................................................................................................................... 67 5.3 Bulk Automated VPG Creation ? ZVM Only.............................................................................................................. 70 5.4 Bulk Automated VPG Creation ? ZVM & ZCM .......................................................................................................... 76 5.5 Bulk Automated VPG Creation with Boot Groups & Re-IP ? ZVM Only ................................................................... 82

6 AUTOMATING VM PROTECTION ........................................................................................................................89

6.1 Use Cases .................................................................................................................................................................. 89 6.2 Automating VM Protection by vSphere Folder - ZVM Only ..................................................................................... 89 6.3 Automating VM Protection by vSphere Folder - ZVM & ZCM.................................................................................. 97 6.4 Automating VM Protection with vRealize Orchestrator ........................................................................................ 104 6.5 Adding VMs to VPGs ............................................................................................................................................... 105

AUTOMATING ZVR WITH POWERSHELL & REST API WHITEPAPER

2 OF 134

7 BULK EDIT OPERATIONS ...................................................................................................................................107 7.1 Bulk VPG Name Changing ....................................................................................................................................... 107 7.2 Bulk Editing VM NIC Settings Including Re-IP & Port Groups................................................................................. 111

8 SCHEDULING OFFSITE CLONES .........................................................................................................................119 8.1 Use Cases ................................................................................................................................................................ 119 8.2 Design Methodology .............................................................................................................................................. 119 8.3 Scheduled Offsite Clone ......................................................................................................................................... 120

9 TROUBLESHOOTING .........................................................................................................................................134

AUTOMATING ZVR WITH POWERSHELL & REST API WHITEPAPER

3 OF 134

1 INTRODUCTION

1.1 Use Cases

This document gives an overview of how to utilize Zerto Virtual Replication REST APIs with PowerShell to automate your virtual infrastructure. In turn, this enables the reduction of manual processes and the realization of the full benefits of software-defined replication and recovery. Highlights of key use cases covered within this document include:

? Automating VM protection ? Automating VM protection with vRealize Orchestrator ? Bulk VRA deployment ? Bulk VPG configuration ? Scheduling Offsite Clones ? Daily email reports ? Bulk Re-IP addressing

Also included is how to obtain reporting on:

? Long term RPO statistics ? VMs by top journal and recovery storage usage ? Protected and unprotected VMs ? VMs by target Hosts for recovery balancing ? VMs by average bandwidth utilization ? VMs by datastore ? VMs by CPU and RAM allocation

The examples given have been developed to meet the requirements of Zerto cloud and enterprise environments ranging from 100s to thousands of VMs. The font size of the examples given are optimized depending on the maximum line length to enable copying and pasting directly from the PDF into your PowerShell scripts.

1.2 REST APIs

The REST APIs utilized in the examples are all included within the Zerto Virtual Manager documentation set. The document does not intend to give examples for all the available APIs. Its purpose is to give examples of the most commonly requested use cases and give you the information and knowledge to customize and create your own automation scripts.

1.3 Legal Disclaimer

ALL EXAMPLES AND SCRIPTS ARE PROVIDED "AS-IS" WITHOUT WARRANTY OF ANY KIND. THE AUTHOR AND ZERTO FURTHER DISCLAIM ALL IMPLIED WARRANTIES INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR A PARTICULAR PURPOSE.

IN NO EVENT SHALL ZERTO, ITS AUTHORS, OR ANYONE ELSE INVOLVED IN THE CREATION, PRODUCTION, OR DELIVERY OF THE SCRIPTS BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE SAMPLE SCRIPTS OR DOCUMENTATION, EVEN IF THE AUTHOR OR ZERTO HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF THE SAMPLE SCRIPTS AND DOCUMENTATION REMAINS WITH YOU.

AUTOMATING ZVR WITH POWERSHELL & REST API WHITEPAPER

4 OF 134

2 BASICS & BEST PRACTICES

2.1 Requirements

All the example scripts given in this document share a common set of minimum requirements. These are:

? ZVM Server Name, Username and password with permission to access the API of the ZVM ? Network connectivity to the ZVM ? Access permission to write in and create the directory specified for logging, or manually create the directory in advance ? The PowerShell execution policy set to "Set-ExecutionPolicy unrestricted" ? Use Foxit PDF Reader or Adobe PDF reader to open then copy examples from this PDF and maintain the script structure

Some example scripts also directly interact with the vCenter or a Zerto Cloud Manager (ZCM). For these examples, the following requirements must also be met:

? VMware PowerCLI, 5.5+, installed on the host running the script ? vCenter Server Name, Username and password to establish as session using PowerCLI to the vCenter ? Network connectivity to the vCenter ? ZCM with a new service profile configured and applied to both site ZVMs (source and target)

2.2 Using Variables & Arrays

To store data for execution within PowerShell scripts it is important to use variables and arrays for efficiency. Variables allow a value to be used multiple times and it only needs to be changed once, making editing scripts easier. For ease of use the same variables will be used in all examples in this document, these are:

$ZertoServer = "192.168.0.31" $ZertoPort = "9669" $ZertoUser = administrator@lab.local $ZertoPassword = "Password123!" $vCenterServer = "192.168.0.81" $vCenterUser = administrator@lab.local $vCenterPassword = "Password123!"

Arrays are used in many examples in this document. These are used to build tables of data obtained from the APIs and multiple data sources simultaneously, like vSphere PowerCLI queries. The array is then used to export data to CSVs or to perform multiple actions within the script. Arrays are created line by line with the required values which are then added together. Below as an example of how to create a simple array:

$Value1 = "FirstValue" $Value2 = "SecondValue" $Array = @() $ArrayLine = new-object PSObject $ArrayLine | Add-Member -MemberType NoteProperty -Name "Value1" -Value $Value1 $ArrayLine | Add-Member -MemberType NoteProperty -Name "Value2" -Value $Value2 $Array += $ArrayLine $Array

AUTOMATING ZVR WITH POWERSHELL & REST API WHITEPAPER

5 OF 134

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download