From 5a3f2d8eecf96d5a7c422dd9575938d32cd34951 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 24 Aug 2020 17:19:55 -0400 Subject: [PATCH] Azure VPG Helper Functions Creation --- .../Public/Get-ZertoAzureNetwork.ps1 | 45 +++++++++++++++++++ .../Public/Get-ZertoAzureSecurityGroup.ps1 | 45 +++++++++++++++++++ .../Public/Get-ZertoAzureSubnet.ps1 | 45 +++++++++++++++++++ .../Public/Get-ZertoAzureVmInstanceType.ps1 | 45 +++++++++++++++++++ 4 files changed, 180 insertions(+) create mode 100644 ZertoApiWrapper/Public/Get-ZertoAzureNetwork.ps1 create mode 100644 ZertoApiWrapper/Public/Get-ZertoAzureSecurityGroup.ps1 create mode 100644 ZertoApiWrapper/Public/Get-ZertoAzureSubnet.ps1 create mode 100644 ZertoApiWrapper/Public/Get-ZertoAzureVmInstanceType.ps1 diff --git a/ZertoApiWrapper/Public/Get-ZertoAzureNetwork.ps1 b/ZertoApiWrapper/Public/Get-ZertoAzureNetwork.ps1 new file mode 100644 index 0000000..edf65cd --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZertoAzureNetwork.ps1 @@ -0,0 +1,45 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZertoAzureNetwork { + [CmdletBinding(DefaultParameterSetName = "SiteName")] + param ( + [Parameter( + Mandatory, + HelpMessage = "Name the Azure Site you wish to get the Networks.", + ParameterSetName = "SiteName" + )] + [ValidateNotNullOrEmpty()] + [String]$SiteName, + [Parameter( + Mandatory, + HelpMessage = "Site Identifier of the Azure Site you wish to get the Networks.", + ParameterSetName = "SiteIdentifier" + )] + [ValidateNotNullOrEmpty()] + [String]$SiteIdentifier + ) + + begin { + + } + + process { + if ($PSCmdlet.ParameterSetName -match "SiteName") { + $SiteInfo = Get-ZertoPeerSite | Where-Object { $_.PeerSiteName -match $SiteName } + if ($null -eq $SiteInfo) { + Write-Error "Unable to find a peer site with the name $SiteName. Please check your parameters and try again." -ErrorAction Stop + } + $SiteIdentifier = $SiteInfo | Select-Object -ExpandProperty SiteIdentifier + } else { + $SiteInfo = Get-ZertoPeerSite -siteIdentifier $SiteIdentifier + } + if ($SiteInfo.SiteType -notmatch "Azure") { + Write-Error "Specified site is not an Azure site. Please specify an Azure site and try again." -ErrorAction Stop + } + $uri = "virtualizationsites/{0}/publicCloud/virtualNetworks" -f $SiteIdentifier + Invoke-ZertoRestRequest -uri $uri + } + + end { + + } +} diff --git a/ZertoApiWrapper/Public/Get-ZertoAzureSecurityGroup.ps1 b/ZertoApiWrapper/Public/Get-ZertoAzureSecurityGroup.ps1 new file mode 100644 index 0000000..2b8c4c7 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZertoAzureSecurityGroup.ps1 @@ -0,0 +1,45 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZertoAzureSecurityGroup { + [CmdletBinding(DefaultParameterSetName = "SiteName")] + param ( + [Parameter( + Mandatory, + HelpMessage = "Name the Azure Site you wish to get the Security Groups.", + ParameterSetName = "SiteName" + )] + [ValidateNotNullOrEmpty()] + [String]$SiteName, + [Parameter( + Mandatory, + HelpMessage = "Site Identifier of the Azure Site you wish to get the Security Groups.", + ParameterSetName = "SiteIdentifier" + )] + [ValidateNotNullOrEmpty()] + [String]$SiteIdentifier + ) + + begin { + + } + + process { + if ($PSCmdlet.ParameterSetName -match "SiteName") { + $SiteInfo = Get-ZertoPeerSite | Where-Object { $_.PeerSiteName -match $SiteName } + if ($null -eq $SiteInfo) { + Write-Error "Unable to find a peer site with the name $SiteName. Please check your parameters and try again." -ErrorAction Stop + } + $SiteIdentifier = $SiteInfo | Select-Object -ExpandProperty SiteIdentifier + } else { + $SiteInfo = Get-ZertoPeerSite -siteIdentifier $SiteIdentifier + } + if ($SiteInfo.SiteType -notmatch "Azure") { + Write-Error "Specified site is not an Azure site. Please specify an Azure site and try again." -ErrorAction Stop + } + $uri = "virtualizationsites/{0}/publicCloud/securityGroups" -f $SiteIdentifier + Invoke-ZertoRestRequest -uri $uri + } + + end { + + } +} diff --git a/ZertoApiWrapper/Public/Get-ZertoAzureSubnet.ps1 b/ZertoApiWrapper/Public/Get-ZertoAzureSubnet.ps1 new file mode 100644 index 0000000..dcb677f --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZertoAzureSubnet.ps1 @@ -0,0 +1,45 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZertoAzureSubnet { + [CmdletBinding(DefaultParameterSetName = "SiteName")] + param ( + [Parameter( + Mandatory, + HelpMessage = "Name the Azure Site you wish to get the Subnets.", + ParameterSetName = "SiteName" + )] + [ValidateNotNullOrEmpty()] + [String]$SiteName, + [Parameter( + Mandatory, + HelpMessage = "Site Identifier of the Azure Site you wish to get the Subnets.", + ParameterSetName = "SiteIdentifier" + )] + [ValidateNotNullOrEmpty()] + [String]$SiteIdentifier + ) + + begin { + + } + + process { + if ($PSCmdlet.ParameterSetName -match "SiteName") { + $SiteInfo = Get-ZertoPeerSite | Where-Object { $_.PeerSiteName -match $SiteName } + if ($null -eq $SiteInfo) { + Write-Error "Unable to find a peer site with the name $SiteName. Please check your parameters and try again." -ErrorAction Stop + } + $SiteIdentifier = $SiteInfo | Select-Object -ExpandProperty SiteIdentifier + } else { + $SiteInfo = Get-ZertoPeerSite -siteIdentifier $SiteIdentifier + } + if ($SiteInfo.SiteType -notmatch "Azure") { + Write-Error "Specified site is not an Azure site. Please specify an Azure site and try again." -ErrorAction Stop + } + $uri = "virtualizationsites/{0}/publicCloud/subnets" -f $SiteIdentifier + Invoke-ZertoRestRequest -uri $uri + } + + end { + + } +} diff --git a/ZertoApiWrapper/Public/Get-ZertoAzureVmInstanceType.ps1 b/ZertoApiWrapper/Public/Get-ZertoAzureVmInstanceType.ps1 new file mode 100644 index 0000000..75c6c2d --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZertoAzureVmInstanceType.ps1 @@ -0,0 +1,45 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZertoAzureVmInstanceType { + [CmdletBinding(DefaultParameterSetName = "SiteName")] + param ( + [Parameter( + Mandatory, + HelpMessage = "Name the Azure Site you wish to get the Vm Instance Types.", + ParameterSetName = "SiteName" + )] + [ValidateNotNullOrEmpty()] + [String]$SiteName, + [Parameter( + Mandatory, + HelpMessage = "Site Identifier of the Azure Site you wish to get the Vm Instance Types.", + ParameterSetName = "SiteIdentifier" + )] + [ValidateNotNullOrEmpty()] + [String]$SiteIdentifier + ) + + begin { + + } + + process { + if ($PSCmdlet.ParameterSetName -match "SiteName") { + $SiteInfo = Get-ZertoPeerSite | Where-Object { $_.PeerSiteName -match $SiteName } + if ($null -eq $SiteInfo) { + Write-Error "Unable to find a peer site with the name $SiteName. Please check your parameters and try again." -ErrorAction Stop + } + $SiteIdentifier = $SiteInfo | Select-Object -ExpandProperty SiteIdentifier + } else { + $SiteInfo = Get-ZertoPeerSite -siteIdentifier $SiteIdentifier + } + if ($SiteInfo.SiteType -notmatch "Azure") { + Write-Error "Specified site is not an Azure site. Please specify an Azure site and try again." -ErrorAction Stop + } + $uri = "virtualizationsites/{0}/publicCloud/vmInstanceTypes" -f $SiteIdentifier + Invoke-ZertoRestRequest -uri $uri + } + + end { + + } +}