- This topic has 5 replies, 2 voices, and was last updated September 13, 2018 by Anish K.
One to Many vms not showing virtualizationsites/vm
-
Anish KJune 7, 2018 01:58:10 PM
In the API, I’ve always used “virtualizationsites/{SITEIDENTIFIER}/vms” to find all of the VMs available to replicate. Not sure when this occurred, but I noticed on 6.0u2 that this no longer retrieves VMs that would be considered One to Many. If I pull them up in the web UI I can find the VM in the “Select VMs” One to Many section, but they no longer show up in the API.
Ryan SJune 7, 2018 04:10:59 PMHi Jason,
Could you provide the full script so we could take a look at it?
Thanks!
Anish KJune 7, 2018 06:25:48 PM#Get Unprotected VMs function Get-ZertoVM { <# .SYNOPSIS Returns VMs that Zerto can see that are not currently protected .PARAMETER VMName Return information on specific VMs .EXAMPLE Get-ZertoVM -VMName COMPUTERNAME .PARAMETER SiteIdentifier Specify the SiteID search .EXAMPLE Get-ZertoVM -SiteIdentifier ab1cd123-ab12-1a23-1a2b-0123ab1234a1 .PARAMETER IdOnly Return only the ID of the VM .EXAMPLE Get-ZertoVM -VMName COMPUTERNAME -IdOnly #> param ( [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true, HelpMessage='Zerto VM Name')] [String]$VMName = "null", [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true, HelpMessage='Zerto Site Identifier, gathered from Get-ZertoSite')] [String]$SiteIdentifier = "null", [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true, HelpMessage='Return only the ID of a single VM VMIdentifier, ignored if no VMName given')] [Switch]$IdOnly = $false ) Try { if ($SiteIdentifier -eq "null"){$SiteIdentifier = Get-ZertoSite | select SiteIdentifier -ExpandProperty SiteIdentifier} New-ZertoSession $ResultsURL = $global:connZerto.BaseURL+"virtualizationsites/"+$SiteIdentifier+"/vms" $ResultsCMD = Invoke-RestMethod -Uri $ResultsURL -TimeoutSec 100 -Headers $global:connZerto.SessionHeader -ContentType "application/JSON" Remove-ZertoSession if ($VMName -eq "null"){$ResultsCMD} elseif ($IDOnly) {$ResultsCMD | where {$_.VMName -like "$VMName"} | select VMIdentifier -ExpandProperty VMIdentifier} else {$ResultsCMD | where {$_.VMName -like "$VMName"}} } #Try Catch {} }
Anish KJune 7, 2018 06:28:51 PMBasically the New-ZertoSession function populates the $global:connZerto with the BaseURL and SessionHeader with some predefined credentials and ZVM variables.
The Remove-ZertoSession removes it. This way we don’t get a lot of open sessions waiting to time out, though it does flood the ZVM Events with login spam.
Anish KSeptember 13, 2018 12:53:14 PMOk, I think I just figured this out. It appears that maybe back before Zerto 6, the “virtualizationsites/<SITEIDENTIFIER>/vms” would pull all vms on the vcenter. Now, it only pulls unprotected vms. My “Get-ZertoVM” function uses that method to get the vm id to add it to the VPG. I’ve just got to do a check if I don’t find it with that method and get it from the “vms/<VMIDENTIFIER>” method instead. A little inconvenient, but doable.
Anish KSeptember 13, 2018 01:02:18 PMOk, I think I just figured this out. It appears that back before Zerto 6, the “virtualizationsites/<SITEIDENTIFIER>/vms” would pull all vms on the vcenter as long as they have not been placed in a certain number of VPGs. Now, it only pulls unprotected vms, even though we have the One to Many license. I could work around this by double checking with the “vms/<VMIDENTIFIER>” method. Should we be able to get all available vms according to the REST API documentation for 6.0u3 on page 82? Unless this was fixed in 6.0u3, we are currently on 6.0u2. Thanks for your help!
The forum ‘Scripting and APIs’ is closed to new topics and replies.