Add New Edge Gateway

Abbility to add a Edge Gateway
This commit is contained in:
mycloudrevolution
2017-08-31 14:58:04 +02:00
parent 5772d994f0
commit e63f4178ab
7 changed files with 389 additions and 185 deletions

View File

@@ -9,15 +9,32 @@ VMware-vCD-Module PowerShell Module
Markus Kraus [@vMarkus_K](https://twitter.com/vMarkus_K) Markus Kraus [@vMarkus_K](https://twitter.com/vMarkus_K)
MY CLOUD-(R)EVOLUTION [mycloudrevolution.com](http://mycloudrevolution.com/)
## Project WebSite: ## Project WebSite:
[mycloudrevolution.com](http://mycloudrevolution.com/) [PowerCLI vCloud Director Customer Provisioning](https://mycloudrevolution.com/2017/06/13/powercli-vcloud-director-customer-provisioning/)
[PowerCLI Create vCloud Director Edge Gateway](https://mycloudrevolution.com/2017/06/27/powercli-create-vcloud-director-edge-gateway/)
## Project Documentation: ## Project Documentation:
[Read the Docs](http://vmware-vcd-module.readthedocs.io/) [Read the Docs - VMware-vCD-Module](http://vmware-vcd-module.readthedocs.io/)
## Project Description: ## Project Description:
The 'VMware-vCD-Module' PowerShell Module is focused on the initial craation of VMware vCloud Director Objects like Org, Org User, Org VDC. The 'VMware-vCD-Module' PowerShell Module is focused on the initial creation of VMware vCloud Director Objects like Org, Org User, Org VDC with External Networks or Edge Gateway.
All Functions in this Module can be used as standalone Cmdlet but also the ``Invoke-My OnBoarding`` Functions to process a JSON File and create all Objects at once.
### Fully tested Versions:
Powershell: v4, v5
PowerCLI: 6.5.1
VMware vCloud Director: 8.10.1

View File

@@ -12,7 +12,7 @@
# RootModule = '' # RootModule = ''
# Die Versionsnummer dieses Moduls # Die Versionsnummer dieses Moduls
ModuleVersion = '0.2.0' ModuleVersion = '1.0.0'
# ID zur eindeutigen Kennzeichnung dieses Moduls # ID zur eindeutigen Kennzeichnung dieses Moduls
GUID = '1ef8a2de-ca22-4c88-8cdb-e00f35007d2a' GUID = '1ef8a2de-ca22-4c88-8cdb-e00f35007d2a'
@@ -21,7 +21,7 @@ GUID = '1ef8a2de-ca22-4c88-8cdb-e00f35007d2a'
Author = 'Markus' Author = 'Markus'
# Unternehmen oder Hersteller dieses Moduls # Unternehmen oder Hersteller dieses Moduls
CompanyName = 'Unbekannt' CompanyName = 'mycloudrevolution.com'
# Urheberrechtserklärung für dieses Modul # Urheberrechtserklärung für dieses Modul
Copyright = '(c) 2017 Markus. Alle Rechte vorbehalten.' Copyright = '(c) 2017 Markus. Alle Rechte vorbehalten.'
@@ -64,12 +64,13 @@ Copyright = '(c) 2017 Markus. Alle Rechte vorbehalten.'
# Die Module, die als geschachtelte Module des in "RootModule/ModuleToProcess" angegebenen Moduls importiert werden sollen. # Die Module, die als geschachtelte Module des in "RootModule/ModuleToProcess" angegebenen Moduls importiert werden sollen.
NestedModules = @('functions\Invoke-MyOnBoarding.psm1', NestedModules = @('functions\Invoke-MyOnBoarding.psm1',
'functions\New-MyEdgeGateway.psm1',
'functions\New-MyOrg.psm1', 'functions\New-MyOrg.psm1',
'functions\New-MyOrgAdmin.psm1', 'functions\New-MyOrgAdmin.psm1',
'functions\New-MyOrgVdc.psm1') 'functions\New-MyOrgVdc.psm1')
# Aus diesem Modul zu exportierende Funktionen # Aus diesem Modul zu exportierende Funktionen
FunctionsToExport = 'Invoke-MyOnBoarding', 'New-MyOrg', 'New-MyOrgAdmin', 'New-MyOrgVdc' FunctionsToExport = 'Invoke-MyOnBoarding', 'New-MyEdgeGateway', 'New-MyOrg', 'New-MyOrgAdmin', 'New-MyOrgVdc'
# Aus diesem Modul zu exportierende Cmdlets # Aus diesem Modul zu exportierende Cmdlets
CmdletsToExport = '*' CmdletsToExport = '*'

View File

@@ -19,6 +19,12 @@
"StorageProfile":"Standard-DC01", "StorageProfile":"Standard-DC01",
"ProviderVDC":"Provider-VDC-DC01", "ProviderVDC":"Provider-VDC-DC01",
"NetworkPool":"Provider-VDC-DC01-NetPool", "NetworkPool":"Provider-VDC-DC01-NetPool",
"ExternalNetwork": "External-OrgVdcNet" "ExternalNetwork": "External-OrgVdcNet",
"EdgeGateway": "Yes",
"IPAddress":"192.168.100.1",
"SubnetMask":"255.255.255.0",
"Gateway":"192.168.100.254",
"IPRangeStart":"192.168.100.2",
"IPRangeEnd":"192.168.100.3"
} }
} }

View File

@@ -1,172 +1,191 @@
#Requires -Version 4 #Requires -Version 4
#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"} #Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"}
Function Invoke-MyOnBoarding { Function Invoke-MyOnBoarding {
<# <#
.SYNOPSIS .SYNOPSIS
Creates all vCD Objecst for a new IAAS Customer Creates all vCD Objecst for a new IAAS Customer
.DESCRIPTION .DESCRIPTION
Creates all vCD Objects for a new IAAS Customer Creates all vCD Objects for a new IAAS Customer
All Objects are: All Objects are:
* Org * Org
* Default Org Admin * Default Org Admin
* Org VDC * Org VDC
** Private Catalog ** Private Catalog
** Optional Bridged Network ** Optional Bridged Network
JSON Config Example: JSON Config Example:
{ {
"Org": { "Org": {
"Name":"TestOrg", "Name":"TestOrg",
"FullName": "Test Org", "FullName": "Test Org",
"Description":"Automation Test Org" "Description":"Automation Test Org"
}, },
"OrgAdmin": { "OrgAdmin": {
"Name":"TestOrgAdmin", "Name":"TestOrgAdmin",
"Pasword": "myPassword1!", "Pasword": "myPassword1!",
"FullName":"Test OrgAdmin", "FullName":"Test OrgAdmin",
"EmailAddress":"test@admin.org" "EmailAddress":"test@admin.org"
}, },
"OrgVdc": { "OrgVdc": {
"Name":"TestOrgVdc", "Name":"TestOrgVdc",
"FixedSize": "M", "FixedSize": "M",
"CPULimit": "1000", "CPULimit": "1000",
"MEMLimit":"1000", "MEMLimit":"1000",
"StorageLimit":"1000", "StorageLimit":"1000",
"StorageProfile":"Standard-DC01", "StorageProfile":"Standard-DC01",
"ProviderVDC":"Provider-VDC-DC01", "ProviderVDC":"Provider-VDC-DC01",
"NetworkPool":"Provider-VDC-DC01-NetPool", "NetworkPool":"Provider-VDC-DC01-NetPool",
"ExternalNetwork": "External_OrgVdcNet" "ExternalNetwork": "External_OrgVdcNet",
} "EdgeGateway": "Yes",
} "IPAddress":"192.168.100.1",
"SubnetMask":"255.255.255.0",
.NOTES "Gateway":"192.168.100.254",
File Name : Invoke-MyOnBoarding.ps1 "IPRangeStart":"192.168.100.2",
Author : Markus Kraus "IPRangeEnd":"192.168.100.3"
Version : 1.2 }
State : Ready }
.LINK .NOTES
https://mycloudrevolution.com/ File Name : Invoke-MyOnBoarding.ps1
Author : Markus Kraus
.EXAMPLE Version : 1.3
Invoke-MyOnBoarding -ConfigFile ".\OnBoarding.json" -Enabled:$true State : Ready
.EXAMPLE .LINK
Invoke-MyOnBoarding -ConfigFile ".\OnBoarding.json" -Enabled:$false https://mycloudrevolution.com/
.PARAMETER ConfigFile .EXAMPLE
Full Path to the JSON Config File Invoke-MyOnBoarding -ConfigFile ".\OnBoarding.json" -Enabled:$true
.PARAMETER Enabled .EXAMPLE
Should the Customer be enabled after creation Invoke-MyOnBoarding -ConfigFile ".\OnBoarding.json" -Enabled:$false
Default: $False .PARAMETER ConfigFile
Full Path to the JSON Config File
#>
Param ( .PARAMETER Enabled
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Full Path to the JSON Config File")] Should the Customer be enabled after creation
[ValidateNotNullorEmpty()]
[String] $ConfigFile, Default: $False
[Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Should the Customer be enabled after creation")]
[ValidateNotNullorEmpty()] #>
[Switch]$Enabled Param (
) [Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Full Path to the JSON Config File")]
Process { [ValidateNotNullorEmpty()]
[String] $ConfigFile,
$Valid = $true [Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Should the Customer be enabled after creation")]
[ValidateNotNullorEmpty()]
Write-Verbose "## Import JSON Config" [Switch]$Enabled
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config...`n" )
$Configs = Get-Content -Raw -Path $ConfigFile -ErrorAction Continue | ConvertFrom-Json -ErrorAction Continue Process {
if (!($Configs)) { $Valid = $true
$Valid = $false
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config Failed" -ForegroundColor Red Write-Verbose "## Import JSON Config"
} Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config...`n"
else { $Configs = Get-Content -Raw -Path $ConfigFile -ErrorAction Continue | ConvertFrom-Json -ErrorAction Continue
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config OK" -ForegroundColor Green
} if (!($Configs)) {
$Valid = $false
if ($Valid) { Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config Failed" -ForegroundColor Red
try{ }
Write-Verbose "## Create Org" else {
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org...`n" -ForegroundColor Yellow Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config OK" -ForegroundColor Green
$Trash = New-MyOrg -Name $Configs.Org.Name -FullName $Configs.Org.Fullname -Description $Configs.Org.Description -Enabled:$Enabled }
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org OK" -ForegroundColor Green
Get-Org -Name $Configs.Org.Name | Select-Object Name, FullName, Enabled | Format-Table -AutoSize if ($Valid) {
} try{
catch { Write-Verbose "## Create Org"
$Valid = $false Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org...`n" -ForegroundColor Yellow
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org Failed" -ForegroundColor Red $Trash = New-MyOrg -Name $Configs.Org.Name -FullName $Configs.Org.Fullname -Description $Configs.Org.Description -Enabled:$Enabled
} Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org OK" -ForegroundColor Green
} Get-Org -Name $Configs.Org.Name | Select-Object Name, FullName, Enabled | Format-Table -AutoSize
}
if ($Valid) { catch {
try{ $Valid = $false
Write-Verbose "## Create OrgAdmin" Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org Failed" -ForegroundColor Red
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgAdmin...`n" -ForegroundColor Yellow }
$Trash = New-MyOrgAdmin -Name $Configs.OrgAdmin.Name -Pasword $Configs.OrgAdmin.Pasword -FullName $Configs.OrgAdmin.FullName -EmailAddress $Configs.OrgAdmin.EmailAddress -Org $Configs.Org.Name -Enabled:$Enabled }
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgAdmin OK" -ForegroundColor Green
Get-CIUser -Org $Configs.Org.Name -Name $Configs.OrgAdmin.Name | Select-Object Name, FullName, Email | Format-Table -AutoSize if ($Valid) {
} try{
catch { Write-Verbose "## Create OrgAdmin"
$Valid = $false Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgAdmin...`n" -ForegroundColor Yellow
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgAdmin Failed" -ForegroundColor Red $Trash = New-MyOrgAdmin -Name $Configs.OrgAdmin.Name -Pasword $Configs.OrgAdmin.Pasword -FullName $Configs.OrgAdmin.FullName -EmailAddress $Configs.OrgAdmin.EmailAddress -Org $Configs.Org.Name -Enabled:$Enabled
} Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgAdmin OK" -ForegroundColor Green
} Get-CIUser -Org $Configs.Org.Name -Name $Configs.OrgAdmin.Name | Select-Object Name, FullName, Email | Format-Table -AutoSize
if ($Valid) { }
try{ catch {
Write-Verbose "## Create OrgVdc" $Valid = $false
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc...`n" -ForegroundColor Yellow Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgAdmin Failed" -ForegroundColor Red
}
if ($Configs.OrgVdc.FixedSize){ }
if ($Valid) {
Write-Host "Fixed Size (T-Shirt Size) '$($Configs.OrgVdc.FixedSize)' Org VDC Requested!" try{
Write-Verbose "## Create OrgVdc"
switch ($Configs.OrgVdc.FixedSize) { Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc...`n" -ForegroundColor Yellow
M {
[String]$CPULimit = 36000 if ($Configs.OrgVdc.FixedSize){
[String]$MEMLimit = 122880
[String]$StorageLimit = 1048576 Write-Host "Fixed Size (T-Shirt Size) '$($Configs.OrgVdc.FixedSize)' Org VDC Requested!"
}
L { switch ($Configs.OrgVdc.FixedSize) {
[String]$CPULimit = 36000 M {
[String]$MEMLimit = 245760 [String]$CPULimit = 36000
[String]$StorageLimit = 1048576 [String]$MEMLimit = 122880
} [String]$StorageLimit = 1048576
default {throw "Invalid T-Shirt Size!"} }
} L {
[String]$CPULimit = 36000
} [String]$MEMLimit = 245760
else{ [String]$StorageLimit = 1048576
Write-Host "Custom Org VDC Size Requested!" }
default {throw "Invalid T-Shirt Size!"}
$CPULimit = $Configs.OrgVdc.CPULimit }
$MEMLimit = $Configs.OrgVdc.MEMLimit
$StorageLimit = $Configs.OrgVdc.StorageLimit }
else{
} Write-Host "Custom Org VDC Size Requested!"
if ($Configs.OrgVdc.ExternalNetwork){ $CPULimit = $Configs.OrgVdc.CPULimit
$Trash = New-MyOrgVdc -Name $Configs.OrgVdc.Name -CPULimit $CPULimit -MEMLimit $MEMLimit -StorageLimit $StorageLimit -Networkpool $Configs.OrgVdc.NetworkPool -StorageProfile $Configs.OrgVdc.StorageProfile -ProviderVDC $Configs.OrgVdc.ProviderVDC -ExternalNetwork $Configs.OrgVdc.ExternalNetwork -Org $Configs.Org.Name -Enabled:$Enabled $MEMLimit = $Configs.OrgVdc.MEMLimit
} $StorageLimit = $Configs.OrgVdc.StorageLimit
else {
$Trash = New-MyOrgVdc -Name $Configs.OrgVdc.Name -CPULimit $CPULimit -MEMLimit $MEMLimit -StorageLimit $StorageLimit -Networkpool $Configs.OrgVdc.NetworkPool -StorageProfile $Configs.OrgVdc.StorageProfile -ProviderVDC $Configs.OrgVdc.ProviderVDC -Org $Configs.Org.Name -Enabled:$Enabled }
}
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc OK" -ForegroundColor Green if ($Configs.OrgVdc.ExternalNetwork -and $Configs.OrgVdc.EdgeGateway -like "Yes"){
Get-OrgVdc -Org $Configs.Org.Name -Name $Configs.OrgVdc.Name | Select-Object Name, Enabled, CpuAllocationGhz, MemoryLimitGB, StorageLimitGB, AllocationModel, ThinProvisioned, UseFastProvisioning, ` Write-Host "Edge Gateway for Org VDC '$($Configs.OrgVdc.Name)' Requested!"
@{N="StorageProfile";E={$_.ExtensionData.VdcStorageProfiles.VdcStorageProfile.Name}}, ` $Trash = New-MyOrgVdc -Name $Configs.OrgVdc.Name -CPULimit $CPULimit -MEMLimit $MEMLimit -StorageLimit $StorageLimit -Networkpool $Configs.OrgVdc.NetworkPool `
@{N='VCpuInMhz';E={$_.ExtensionData.VCpuInMhz}} | Format-Table -AutoSize -StorageProfile $Configs.OrgVdc.StorageProfile -ProviderVDC $Configs.OrgVdc.ProviderVDC -Org $Configs.Org.Name -Enabled:$Enabled
}
catch { $EdgeName = $Configs.Org.Name + "-ESG01"
$Valid = $false $Trash = New-MyEdgeGateway -Name $EdgeName -OrgVDCName $Configs.OrgVdc.Name -Orgname $Configs.Org.Name -ExternalNetwork $Configs.OrgVdc.ExternalNetwork `
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc Failed" -ForegroundColor Red -IPAddress $Configs.OrgVdc.IPAddress -SubnetMask $Configs.OrgVdc.SubnetMask -Gateway $Configs.OrgVdc.Gateway -IPRangeStart $Configs.OrgVdc.IPRangeStart -IPRangeEnd $Configs.OrgVdc.IPRangeEnd
} }
} elseif ($Configs.OrgVdc.ExternalNetwork -and $Configs.OrgVdc.EdgeGateway -like "No"){
Write-Host "External Network for Org VDC '$($Configs.OrgVdc.Name)' Requested!"
Write-Output "Overall Execution was Valid: $Valid" $Trash = New-MyOrgVdc -Name $Configs.OrgVdc.Name -CPULimit $CPULimit -MEMLimit $MEMLimit -StorageLimit $StorageLimit -Networkpool $Configs.OrgVdc.NetworkPool `
} -StorageProfile $Configs.OrgVdc.StorageProfile -ProviderVDC $Configs.OrgVdc.ProviderVDC -ExternalNetwork $Configs.OrgVdc.ExternalNetwork -Org $Configs.Org.Name -Enabled:$Enabled
} }
else {
Write-Host "No external Connection for Org VDC '$($Configs.OrgVdc.Name)' Requested!"
$Trash = New-PecOrgVdc -Name $Configs.OrgVdc.Name -CPULimit $CPULimit -MEMLimit $MEMLimit -StorageLimit $StorageLimit -Networkpool $ProVdcNetworkPool.Name `
-StorageProfile $Configs.OrgVdc.StorageProfile -ProviderVDC $Configs.OrgVdc.ProviderVDC -Org $Configs.Org.Name -Enabled:$Enabled
}
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc OK" -ForegroundColor Green
Get-OrgVdc -Org $Configs.Org.Name -Name $Configs.OrgVdc.Name | Select-Object Name, Enabled, CpuAllocationGhz, MemoryLimitGB, StorageLimitGB, AllocationModel, ThinProvisioned, UseFastProvisioning, `
@{N="StorageProfile";E={$_.ExtensionData.VdcStorageProfiles.VdcStorageProfile.Name}}, `
@{N='VCpuInMhz';E={$_.ExtensionData.VCpuInMhz}} | Format-Table -AutoSize
if ($Configs.OrgVdc.EdgeGateway -like "Yes"){
Search-Cloud -QueryType EdgeGateway -Name $EdgeName | Select Name, IsBusy, GatewayStatus, HaStatus | ft -AutoSize
}
}
catch {
$Valid = $false
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc Failed" -ForegroundColor Red
}
}

View File

@@ -0,0 +1,161 @@
#Requires -Version 4
#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"}
Function New-MyEdgeGateway {
<#
.SYNOPSIS
Creates a new Edge Gateway with Default Parameters
.DESCRIPTION
Creates a new Edge Gateway with Default Parameters
Default Parameters are:
* Size
* HA State
* DNS Relay
.NOTES
File Name : New-MyEdgeGateway.ps1
Author : Markus Kraus
Version : 1.0
State : Ready
.LINK
https://mycloudrevolution.com/
.EXAMPLE
New-MyEdgeGateway -Name "TestEdge" -OrgVDCName "TestVDC" -OrgName "TestOrg" -ExternalNetwork "ExternalNetwork" -IPAddress "192.168.100.1" -SubnetMask "255.255.255.0" -Gateway "192.168.100.254" -IPRangeStart ""192.168.100.2" -IPRangeEnd ""192.168.100.3" -Verbose
.PARAMETER Name
Name of the New Edge Gateway as String
.PARAMETER OrgVDCName
OrgVDC where the new Edge Gateway should be created as string
.PARAMETER OrgName
Org where the new Edge Gateway should be created as string
.PARAMETER ExternalNetwork
External Network of the new Edge Gateway as String
.PARAMETER IPAddress
IP Address of the New Edge Gateway as IP Address
.PARAMETER SubnetMask
Subnet Mask of the New Edge Gateway as IP Address
.PARAMETER Gateway
Gateway of the New Edge Gateway as IP Address
.PARAMETER IPRangeStart
Sub Allocation IP Range Start of the New Edge Gateway as IP Address
.PARAMETER IPRangeEnd
Sub Allocation IP Range End of the New Edge Gateway as IP Address
.PARAMETER Timeout
Timeout for the Edge Gateway to get Ready
Default: 120s
#>
Param (
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Name of the New Edge Gateway as String")]
[ValidateNotNullorEmpty()]
[String] $Name,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="OrgVDC where the new Edge Gateway should be created as string")]
[ValidateNotNullorEmpty()]
[String] $OrgVdcName,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Org where the new Edge Gateway should be created as string")]
[ValidateNotNullorEmpty()]
[String] $OrgName,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="External Network of the New Edge Gateway as String")]
[ValidateNotNullorEmpty()]
[String] $ExternalNetwork,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="IP Address of the New Edge Gateway as IP Address")]
[ValidateNotNullorEmpty()]
[IPAddress] $IPAddress,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Subnet Mask of the New Edge Gateway as IP Address")]
[ValidateNotNullorEmpty()]
[IPAddress] $SubnetMask,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Gateway of the New Edge Gateway as IP Address")]
[ValidateNotNullorEmpty()]
[IPAddress] $Gateway,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Sub Allocation IP Range Start the New Edge Gateway as IP Address")]
[ValidateNotNullorEmpty()]
[IPAddress] $IPRangeStart,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Sub Allocation IP Range End the New Edge Gateway as IP Address")]
[ValidateNotNullorEmpty()]
[IPAddress] $IPRangeEnd,
[Parameter(Mandatory=$False, ValueFromPipeline=$False,HelpMessage="Timeout for the Edge Gateway to get Ready")]
[ValidateNotNullorEmpty()]
[int] $Timeout = 120
)
Process {
## Get Org vDC
Write-Verbose "Get Org vDC"
[Array] $orgVdc = Get-Org -Name $OrgName | Get-OrgVdc -Name $OrgVdcName
if ( $orgVdc.Count -gt 1) {
throw "Multiple OrgVdcs found!"
}
elseif ( $orgVdc.Count -lt 1) {
throw "No OrgVdc found!"
}
## Get External Network
Write-Verbose "Get External Network"
$extNetwork = Get-ExternalNetwork | Get-CIView -Verbose:$False | Where-Object {$_.name -eq $ExternalNetwork}
## Build EdgeGatway Configuration
Write-Verbose "Build EdgeGatway Configuration"
$EdgeGateway = New-Object VMware.VimAutomation.Cloud.Views.Gateway
$EdgeGateway.Name = $Name
$EdgeGateway.Configuration = New-Object VMware.VimAutomation.Cloud.Views.GatewayConfiguration
#$EdgeGateway.Configuration.BackwardCompatibilityMode = $false
$EdgeGateway.Configuration.GatewayBackingConfig = "compact"
$EdgeGateway.Configuration.UseDefaultRouteForDnsRelay = $false
$EdgeGateway.Configuration.HaEnabled = $false
$EdgeGateway.Configuration.EdgeGatewayServiceConfiguration = New-Object VMware.VimAutomation.Cloud.Views.GatewayFeatures
$EdgeGateway.Configuration.GatewayInterfaces = New-Object VMware.VimAutomation.Cloud.Views.GatewayInterfaces
$EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface = New-Object VMware.VimAutomation.Cloud.Views.GatewayInterface
$EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[0].name = $extNetwork.Name
$EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[0].DisplayName = $extNetwork.Name
$EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[0].Network = $extNetwork.Href
$EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[0].InterfaceType = "uplink"
$EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[0].UseForDefaultRoute = $true
$EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[0].ApplyRateLimit = $false
$ExNetexternalSubnet = New-Object VMware.VimAutomation.Cloud.Views.SubnetParticipation
$ExNetexternalSubnet.Gateway = $Gateway.IPAddressToString
$ExNetexternalSubnet.Netmask = $SubnetMask.IPAddressToString
$ExNetexternalSubnet.IpAddress = $IPAddress.IPAddressToString
$ExNetexternalSubnet.IpRanges = New-Object VMware.VimAutomation.Cloud.Views.IpRanges
$ExNetexternalSubnet.IpRanges.IpRange = New-Object VMware.VimAutomation.Cloud.Views.IpRange
$ExNetexternalSubnet.IpRanges.IpRange[0].StartAddress = $IPRangeStart.IPAddressToString
$ExNetexternalSubnet.IpRanges.IpRange[0].EndAddress = $IPRangeEnd.IPAddressToString
$EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[0].SubnetParticipation = $ExNetexternalSubnet
## Create EdgeGatway
Write-Verbose "Create EdgeGatway"
$CreateEdgeGateway = $orgVdc.ExtensionData.CreateEdgeGateway($EdgeGateway)
## Wait for EdgeGatway to become Ready
Write-Verbose "Wait for EdgeGatway to become Ready"
while((Search-Cloud -QueryType EdgeGateway -Name $Name -Verbose:$False).IsBusy -eq $True){
$i++
Start-Sleep 5
if($i -gt $Timeout) { Write-Error "Creating Edge Gateway."; break}
Write-Progress -Activity "Creating Edge Gateway" -Status "Wait for Edge to become Ready..."
}
Write-Progress -Activity "Creating Edge Gateway" -Completed
Start-Sleep 1
Search-Cloud -QueryType EdgeGateway -Name $Name | Select-Object Name, IsBusy, GatewayStatus, HaStatus | Format-Table -AutoSize
}
}

View File

@@ -67,7 +67,7 @@ Function New-MyOrgVdc {
Org where the new Org VDC should be created as string Org where the new Org VDC should be created as string
.PARAMETER Timeout .PARAMETER Timeout
Timeout for teh Org VDC to get Ready Timeout for the Org VDC to get Ready
Default: 120s Default: 120s
@@ -103,7 +103,7 @@ Function New-MyOrgVdc {
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Org where the new Org VDC should be created as string")] [Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Org where the new Org VDC should be created as string")]
[ValidateNotNullorEmpty()] [ValidateNotNullorEmpty()]
[String] $Org, [String] $Org,
[Parameter(Mandatory=$False, ValueFromPipeline=$False,HelpMessage="Timeout for teh Org VDC to get Ready")] [Parameter(Mandatory=$False, ValueFromPipeline=$False,HelpMessage="Timeout for the Org VDC to get Ready")]
[ValidateNotNullorEmpty()] [ValidateNotNullorEmpty()]
[int] $Timeout = 120 [int] $Timeout = 120
) )
@@ -145,7 +145,7 @@ Function New-MyOrgVdc {
## Wait for getting Ready ## Wait for getting Ready
Write-Verbose "Wait for getting Ready" Write-Verbose "Wait for getting Ready"
$i = 0 $i = 0
while(($orgVdc = Get-OrgVdc -Name $Name).Status -eq "NotReady"){ while(($orgVdc = Get-OrgVdc -Name $Name -Verbose:$false).Status -eq "NotReady"){
$i++ $i++
Start-Sleep 2 Start-Sleep 2
if($i -gt $Timeout) { Write-Error "Creating Org Failed."; break} if($i -gt $Timeout) { Write-Error "Creating Org Failed."; break}
@@ -175,7 +175,7 @@ Function New-MyOrgVdc {
## Wait for getting Ready ## Wait for getting Ready
Write-Verbose "Wait for getting Ready" Write-Verbose "Wait for getting Ready"
while(($orgVdc = Get-OrgVdc -Name $name).Status -eq "NotReady"){ while(($orgVdc = Get-OrgVdc -Name $name -Verbose:$false).Status -eq "NotReady"){
$i++ $i++
Start-Sleep 1 Start-Sleep 1
if($i -gt $Timeout) { Write-Error "Update Org Failed."; break} if($i -gt $Timeout) { Write-Error "Update Org Failed."; break}
@@ -201,7 +201,7 @@ Function New-MyOrgVdc {
## Wait for getting Ready ## Wait for getting Ready
Write-Verbose "Wait for getting Ready" Write-Verbose "Wait for getting Ready"
while(($orgVdc = Get-OrgVdc -Name $name).Status -eq "NotReady"){ while(($orgVdc = Get-OrgVdc -Name $name -Verbose:$false).Status -eq "NotReady"){
$i++ $i++
Start-Sleep 1 Start-Sleep 1
if($i -gt $Timeout) { Write-Error "Update Org Failed."; break} if($i -gt $Timeout) { Write-Error "Update Org Failed."; break}
@@ -236,7 +236,7 @@ Function New-MyOrgVdc {
$EnableOrgVdc = Set-OrgVdc -OrgVdc $Name -Enabled:$True $EnableOrgVdc = Set-OrgVdc -OrgVdc $Name -Enabled:$True
$orgVdcView = Get-OrgVdc $Name | Get-CIView $orgVdcView = Get-OrgVdc $Name | Get-CIView
$extNetwork = $_.externalnetwork $extNetwork = $_.externalnetwork
$extNetwork = Get-ExternalNetwork | Get-CIView | Where-Object {$_.name -eq $ExternalNetwork} $extNetwork = Get-ExternalNetwork | Get-CIView -Verbose:$false | Where-Object {$_.name -eq $ExternalNetwork}
$orgNetwork = new-object vmware.vimautomation.cloud.views.orgvdcnetwork $orgNetwork = new-object vmware.vimautomation.cloud.views.orgvdcnetwork
$orgNetwork.name = $ExternalNetwork $orgNetwork.name = $ExternalNetwork
$orgNetwork.Configuration = New-Object VMware.VimAutomation.Cloud.Views.NetworkConfiguration $orgNetwork.Configuration = New-Object VMware.VimAutomation.Cloud.Views.NetworkConfiguration

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 89 KiB