diff --git a/Modules/VMware-vCD-Module/README.md b/Modules/VMware-vCD-Module/README.md index a691421..3d7bc48 100644 --- a/Modules/VMware-vCD-Module/README.md +++ b/Modules/VMware-vCD-Module/README.md @@ -9,15 +9,32 @@ VMware-vCD-Module PowerShell Module Markus Kraus [@vMarkus_K](https://twitter.com/vMarkus_K) +MY CLOUD-(R)EVOLUTION [mycloudrevolution.com](http://mycloudrevolution.com/) + + ## 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: -[Read the Docs](http://vmware-vcd-module.readthedocs.io/) +[Read the Docs - VMware-vCD-Module](http://vmware-vcd-module.readthedocs.io/) ## 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 + diff --git a/Modules/VMware-vCD-Module/VMware-vCD-Module.psd1 b/Modules/VMware-vCD-Module/VMware-vCD-Module.psd1 index 59a02de..27584d1 100644 --- a/Modules/VMware-vCD-Module/VMware-vCD-Module.psd1 +++ b/Modules/VMware-vCD-Module/VMware-vCD-Module.psd1 @@ -12,7 +12,7 @@ # RootModule = '' # Die Versionsnummer dieses Moduls -ModuleVersion = '0.2.0' +ModuleVersion = '1.0.0' # ID zur eindeutigen Kennzeichnung dieses Moduls GUID = '1ef8a2de-ca22-4c88-8cdb-e00f35007d2a' @@ -21,7 +21,7 @@ GUID = '1ef8a2de-ca22-4c88-8cdb-e00f35007d2a' Author = 'Markus' # Unternehmen oder Hersteller dieses Moduls -CompanyName = 'Unbekannt' +CompanyName = 'mycloudrevolution.com' # Urheberrechtserklärung für dieses Modul 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. NestedModules = @('functions\Invoke-MyOnBoarding.psm1', + 'functions\New-MyEdgeGateway.psm1', 'functions\New-MyOrg.psm1', 'functions\New-MyOrgAdmin.psm1', 'functions\New-MyOrgVdc.psm1') # 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 CmdletsToExport = '*' diff --git a/Modules/VMware-vCD-Module/examples/OnBoarding.json b/Modules/VMware-vCD-Module/examples/OnBoarding.json index ecd1f88..9fe4217 100644 --- a/Modules/VMware-vCD-Module/examples/OnBoarding.json +++ b/Modules/VMware-vCD-Module/examples/OnBoarding.json @@ -19,6 +19,12 @@ "StorageProfile":"Standard-DC01", "ProviderVDC":"Provider-VDC-DC01", "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" } } \ No newline at end of file diff --git a/Modules/VMware-vCD-Module/functions/Invoke-MyOnBoarding.psm1 b/Modules/VMware-vCD-Module/functions/Invoke-MyOnBoarding.psm1 index 4b5e209..97e00ed 100644 --- a/Modules/VMware-vCD-Module/functions/Invoke-MyOnBoarding.psm1 +++ b/Modules/VMware-vCD-Module/functions/Invoke-MyOnBoarding.psm1 @@ -1,172 +1,191 @@ -#Requires -Version 4 -#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"} -Function Invoke-MyOnBoarding { -<# -.SYNOPSIS - Creates all vCD Objecst for a new IAAS Customer - -.DESCRIPTION - Creates all vCD Objects for a new IAAS Customer - - All Objects are: - * Org - * Default Org Admin - * Org VDC - ** Private Catalog - ** Optional Bridged Network - - JSON Config Example: - - { - "Org": { - "Name":"TestOrg", - "FullName": "Test Org", - "Description":"Automation Test Org" - }, - "OrgAdmin": { - "Name":"TestOrgAdmin", - "Pasword": "myPassword1!", - "FullName":"Test OrgAdmin", - "EmailAddress":"test@admin.org" - }, - "OrgVdc": { - "Name":"TestOrgVdc", - "FixedSize": "M", - "CPULimit": "1000", - "MEMLimit":"1000", - "StorageLimit":"1000", - "StorageProfile":"Standard-DC01", - "ProviderVDC":"Provider-VDC-DC01", - "NetworkPool":"Provider-VDC-DC01-NetPool", - "ExternalNetwork": "External_OrgVdcNet" - } - } - -.NOTES - File Name : Invoke-MyOnBoarding.ps1 - Author : Markus Kraus - Version : 1.2 - State : Ready - -.LINK - https://mycloudrevolution.com/ - -.EXAMPLE - Invoke-MyOnBoarding -ConfigFile ".\OnBoarding.json" -Enabled:$true - -.EXAMPLE - Invoke-MyOnBoarding -ConfigFile ".\OnBoarding.json" -Enabled:$false - -.PARAMETER ConfigFile - Full Path to the JSON Config File - -.PARAMETER Enabled - Should the Customer be enabled after creation - - Default: $False - -#> - Param ( - [Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Full Path to the JSON Config File")] - [ValidateNotNullorEmpty()] - [String] $ConfigFile, - [Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Should the Customer be enabled after creation")] - [ValidateNotNullorEmpty()] - [Switch]$Enabled - ) - Process { - - $Valid = $true - - Write-Verbose "## Import JSON Config" - 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 - - if (!($Configs)) { - $Valid = $false - Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config Failed" -ForegroundColor Red - } - else { - Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config OK" -ForegroundColor Green - } - - if ($Valid) { - try{ - Write-Verbose "## Create Org" - Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org...`n" -ForegroundColor Yellow - $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 - } - catch { - $Valid = $false - Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org Failed" -ForegroundColor Red - } - } - - if ($Valid) { - try{ - Write-Verbose "## Create OrgAdmin" - 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 - } - catch { - $Valid = $false - Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgAdmin Failed" -ForegroundColor Red - } - } - if ($Valid) { - try{ - Write-Verbose "## Create OrgVdc" - Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc...`n" -ForegroundColor Yellow - - if ($Configs.OrgVdc.FixedSize){ - - Write-Host "Fixed Size (T-Shirt Size) '$($Configs.OrgVdc.FixedSize)' Org VDC Requested!" - - switch ($Configs.OrgVdc.FixedSize) { - M { - [String]$CPULimit = 36000 - [String]$MEMLimit = 122880 - [String]$StorageLimit = 1048576 - } - L { - [String]$CPULimit = 36000 - [String]$MEMLimit = 245760 - [String]$StorageLimit = 1048576 - } - default {throw "Invalid T-Shirt Size!"} - } - - } - else{ - Write-Host "Custom Org VDC Size Requested!" - - $CPULimit = $Configs.OrgVdc.CPULimit - $MEMLimit = $Configs.OrgVdc.MEMLimit - $StorageLimit = $Configs.OrgVdc.StorageLimit - - } - - if ($Configs.OrgVdc.ExternalNetwork){ - $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 { - $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 - 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 - } - catch { - $Valid = $false - Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc Failed" -ForegroundColor Red - } - } - - Write-Output "Overall Execution was Valid: $Valid" - } -} +#Requires -Version 4 +#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"} +Function Invoke-MyOnBoarding { +<# +.SYNOPSIS + Creates all vCD Objecst for a new IAAS Customer + +.DESCRIPTION + Creates all vCD Objects for a new IAAS Customer + + All Objects are: + * Org + * Default Org Admin + * Org VDC + ** Private Catalog + ** Optional Bridged Network + + JSON Config Example: + + { + "Org": { + "Name":"TestOrg", + "FullName": "Test Org", + "Description":"Automation Test Org" + }, + "OrgAdmin": { + "Name":"TestOrgAdmin", + "Pasword": "myPassword1!", + "FullName":"Test OrgAdmin", + "EmailAddress":"test@admin.org" + }, + "OrgVdc": { + "Name":"TestOrgVdc", + "FixedSize": "M", + "CPULimit": "1000", + "MEMLimit":"1000", + "StorageLimit":"1000", + "StorageProfile":"Standard-DC01", + "ProviderVDC":"Provider-VDC-DC01", + "NetworkPool":"Provider-VDC-DC01-NetPool", + "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" + } + } + +.NOTES + File Name : Invoke-MyOnBoarding.ps1 + Author : Markus Kraus + Version : 1.3 + State : Ready + +.LINK + https://mycloudrevolution.com/ + +.EXAMPLE + Invoke-MyOnBoarding -ConfigFile ".\OnBoarding.json" -Enabled:$true + +.EXAMPLE + Invoke-MyOnBoarding -ConfigFile ".\OnBoarding.json" -Enabled:$false + +.PARAMETER ConfigFile + Full Path to the JSON Config File + +.PARAMETER Enabled + Should the Customer be enabled after creation + + Default: $False + +#> + Param ( + [Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Full Path to the JSON Config File")] + [ValidateNotNullorEmpty()] + [String] $ConfigFile, + [Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Should the Customer be enabled after creation")] + [ValidateNotNullorEmpty()] + [Switch]$Enabled + ) + Process { + + $Valid = $true + + Write-Verbose "## Import JSON Config" + 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 + + if (!($Configs)) { + $Valid = $false + Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config Failed" -ForegroundColor Red + } + else { + Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config OK" -ForegroundColor Green + } + + if ($Valid) { + try{ + Write-Verbose "## Create Org" + Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org...`n" -ForegroundColor Yellow + $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 + } + catch { + $Valid = $false + Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org Failed" -ForegroundColor Red + } + } + + if ($Valid) { + try{ + Write-Verbose "## Create OrgAdmin" + 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 + } + catch { + $Valid = $false + Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgAdmin Failed" -ForegroundColor Red + } + } + if ($Valid) { + try{ + Write-Verbose "## Create OrgVdc" + Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc...`n" -ForegroundColor Yellow + + if ($Configs.OrgVdc.FixedSize){ + + Write-Host "Fixed Size (T-Shirt Size) '$($Configs.OrgVdc.FixedSize)' Org VDC Requested!" + + switch ($Configs.OrgVdc.FixedSize) { + M { + [String]$CPULimit = 36000 + [String]$MEMLimit = 122880 + [String]$StorageLimit = 1048576 + } + L { + [String]$CPULimit = 36000 + [String]$MEMLimit = 245760 + [String]$StorageLimit = 1048576 + } + default {throw "Invalid T-Shirt Size!"} + } + + } + else{ + Write-Host "Custom Org VDC Size Requested!" + + $CPULimit = $Configs.OrgVdc.CPULimit + $MEMLimit = $Configs.OrgVdc.MEMLimit + $StorageLimit = $Configs.OrgVdc.StorageLimit + + } + + if ($Configs.OrgVdc.ExternalNetwork -and $Configs.OrgVdc.EdgeGateway -like "Yes"){ + Write-Host "Edge Gateway for Org VDC '$($Configs.OrgVdc.Name)' Requested!" + $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 + + $EdgeName = $Configs.Org.Name + "-ESG01" + $Trash = New-MyEdgeGateway -Name $EdgeName -OrgVDCName $Configs.OrgVdc.Name -Orgname $Configs.Org.Name -ExternalNetwork $Configs.OrgVdc.ExternalNetwork ` -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!" + $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 + } + } + + Write-Output "Overall Execution was Valid: $Valid" + } +} diff --git a/Modules/VMware-vCD-Module/functions/New-MyEdgeGateway.psm1 b/Modules/VMware-vCD-Module/functions/New-MyEdgeGateway.psm1 new file mode 100644 index 0000000..205c635 --- /dev/null +++ b/Modules/VMware-vCD-Module/functions/New-MyEdgeGateway.psm1 @@ -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 + + + } +} diff --git a/Modules/VMware-vCD-Module/functions/New-MyOrgVdc.psm1 b/Modules/VMware-vCD-Module/functions/New-MyOrgVdc.psm1 index 783ad5e..26258e7 100644 --- a/Modules/VMware-vCD-Module/functions/New-MyOrgVdc.psm1 +++ b/Modules/VMware-vCD-Module/functions/New-MyOrgVdc.psm1 @@ -67,7 +67,7 @@ Function New-MyOrgVdc { Org where the new Org VDC should be created as string .PARAMETER Timeout - Timeout for teh Org VDC to get Ready + Timeout for the Org VDC to get Ready 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")] [ValidateNotNullorEmpty()] [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()] [int] $Timeout = 120 ) @@ -145,7 +145,7 @@ Function New-MyOrgVdc { ## Wait for getting Ready Write-Verbose "Wait for getting Ready" $i = 0 - while(($orgVdc = Get-OrgVdc -Name $Name).Status -eq "NotReady"){ + while(($orgVdc = Get-OrgVdc -Name $Name -Verbose:$false).Status -eq "NotReady"){ $i++ Start-Sleep 2 if($i -gt $Timeout) { Write-Error "Creating Org Failed."; break} @@ -175,7 +175,7 @@ Function New-MyOrgVdc { ## 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++ Start-Sleep 1 if($i -gt $Timeout) { Write-Error "Update Org Failed."; break} @@ -201,7 +201,7 @@ Function New-MyOrgVdc { ## 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++ Start-Sleep 1 if($i -gt $Timeout) { Write-Error "Update Org Failed."; break} @@ -236,7 +236,7 @@ Function New-MyOrgVdc { $EnableOrgVdc = Set-OrgVdc -OrgVdc $Name -Enabled:$True $orgVdcView = Get-OrgVdc $Name | Get-CIView $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.name = $ExternalNetwork $orgNetwork.Configuration = New-Object VMware.VimAutomation.Cloud.Views.NetworkConfiguration diff --git a/Modules/VMware-vCD-Module/media/Invoke-MyOnBoarding.png b/Modules/VMware-vCD-Module/media/Invoke-MyOnBoarding.png index 9f60a93..c09f0fe 100644 Binary files a/Modules/VMware-vCD-Module/media/Invoke-MyOnBoarding.png and b/Modules/VMware-vCD-Module/media/Invoke-MyOnBoarding.png differ