Hi guys.
I can't create Routed Org Network by PowerCLI.
PowerCLI version is 6.5.0.234 and vCD for SP version is 8.20.0.2.
I'm connected to vCD server and all objects are exists: Org "Test", OrgVDC "Test-VDC" and EdgeGW "Test-EdgeGW".
But last one (EdgeGW) isn't using in script and it's strange because in process of creation routed org network in GUI we are choosing existing Edge Gateway... (see pic).
I suppose that script is out of date...
PowerCLI C:\> $OrgName = "Test"
PowerCLI C:\> $Org = Get-Org -Name $OrgName
PowerCLI C:\> $OrgVDCName = "$OrgName-VDC"
PowerCLI C:\> $OrgVDC = Get-OrgVdc -Name $OrgVDCName
PowerCLI C:\> $edgeGateway = Search-Cloud -QueryType EdgeGateway -Name $orgName | Get-CIView | where {$_.name -like "$orgName*"}
PowerCLI C:\> $ExNetnetwork = New-Object VMware.VimAutomation.Cloud.Views.OrgVdcNetwork
PowerCLI C:\> $ExNetnetwork.EdgeGateway = $edgeGateway.Id
PowerCLI C:\> $ExNetnetwork.isShared = $false
PowerCLI C:\> $ExNetnetwork.Configuration = New-Object VMware.VimAutomation.Cloud.Views.NetworkConfiguration
PowerCLI C:\> $ExNetnetwork.Name = "$OrgName-Org-Net01"
PowerCLI C:\> $ExNetnetwork.Configuration.IpScopes = New-Object VMware.VimAutomation.Cloud.Views.IpScopes
PowerCLI C:\> $ExNetnetwork.Configuration.FenceMode = "natRouted"
PowerCLI C:\> $IpScope = New-Object VMware.VimAutomation.Cloud.Views.IpScope
PowerCLI C:\> $IpScope.Gateway = "192.168.100.1"
PowerCLI C:\> $IpScope.Netmask = "255.255.255.0"
PowerCLI C:\> $IpScope.Dns1 = "8.8.8.8"
PowerCLI C:\> $IpScope.IpRanges = New-Object VMware.VimAutomation.Cloud.Views.IpRanges
PowerCLI C:\> $IpScope.IpRanges.IpRange = New-Object VMware.VimAutomation.Cloud.Views.IpRange
PowerCLI C:\> $IpScope.IpRanges.IpRange[0].StartAddress = "192.168.100.2"
PowerCLI C:\> $IpScope.IpRanges.IpRange[0].EndAddress = "192.168.100.50"
PowerCLI C:\> $ExNetnetwork.Configuration.IpScopes.IpScope += $IpScope
PowerCLI C:\> $orgVdc.ExtensionData.CreateNetwork($ExNetnetwork)
Exception calling "CreateNetwork" with "1" argument(s): "The server returned 'Server Error' with the status code 500 - InternalServerError."
At line:1 char:1
+ $orgVdc.ExtensionData.CreateNetwork($ExNetnetwork)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : CloudException
What's wrong? Can anybody give me working example of creating Routed Org Network by PowerCLI?
Hello,
I have written a new Function to create NatRouted Org Networks:
VMware-vCD-Module/New-MyOrgNetwork.psm1 at NewOrgNet · mycloudrevolution/VMware-vCD-Module · GitHub
This Function Creates a New Org Network and attaches this Network to an existing Edge Gateway. Maybe this helps you...
The other Option is to create a new Isolated OrgNet and the add it to the EdgeGateway. You can Check this Blog post for the basic approach (get the existing Config and then use updateServerData()😞 GeekAfterFive - Infrastructure as Code
Best regards,
Markus
Sorry, missed your message regarding this thread. Is this topic still relevant?
Yes. I automated everything in creation of Org except this one...
I have not modified a existing ESG via PowerCLI. I have created the Edges with the whole configuration in one step:
$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)
This is a snippet from my own function to create a new Edge Gateway:
https://github.com/mycloudrevolution/VMware-vCD-Module/blob/master/functions/New-MyEdgeGateway.psm1
Maybe you can use this function in your script.
Best regards,
Markus
Hello Markus!
Thanks for your function (i'm using it in my script) and answers to my questions.
Maybe i'm doing something wrong or don't understand something because of my lack of competence in this matter but i didn't find in this function creation of routed network.
Also in your function there is no any parameters of routed network.
For example, could you show me where in your function set name of routed network?
Btw,
"$EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[0].ApplyRateLimit = $false"
don't work from vCD 9.0 (i'm using "true" value of this parameter).
Hello,
I only create a edge with an external Network and no internal network.
The additional network can be added to the Interface Array:
$EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[1].name = ...
Best Regards,
Markus
I will check that, thanks!
Markus,
After setting this parameters Rate Limits back
$EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[0].InRateLimit = $InRateLimit | |
$EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[0].OutRateLimit = $OutRateLimit |
I added this parameters for your function.
Markus, I'm sorry for my small experience in powershell coding.
I can't create another interface at Edge. When i configured first interface of Edge (0) for External network:
PowerCLI C:\> $EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[0]
Name : ClientsExternalNetwork
DisplayName : ClientsExternalNetwork
Network : VMware.VimAutomation.Cloud.Views.Reference
InterfaceType : uplink
SubnetParticipation : {VMware.VimAutomation.Cloud.Views.SubnetParticipation}
ApplyRateLimit : True
InRateLimit : 100
OutRateLimit : 100
UseForDefaultRoute : True
AnyAttr :
VCloudExtension :
I try to create another interface for Edge (1) for Organization Network:
PowerCLI C:\> $EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface = New-Object VMware.VimAutomation.Cloud.Views.GatewayInterface
But instead of it my configuration of interface 0 is clearing:
PowerCLI C:\> $EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[0]
Name :
DisplayName :
Network :
InterfaceType :
SubnetParticipation :
ApplyRateLimit :
InRateLimit :
OutRateLimit :
UseForDefaultRoute :
AnyAttr :
VCloudExtension :
And there is no another interface initialized:
PowerCLI C:\> $EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[1]
PowerCLI C:\> $EdgeGateway.Configuration.GatewayInterfaces.GatewayInterface[2]
PowerCLI C:\>
Could you help me to write code of initialization Organization Network at interface 1 of Gateway?
For example, gateway - "192.168.0.1", mask - "255.255.255.0", dns - "8.8.8.8", static ip pool - "192.168.0.2-192.168.0.50".
I would recommend you to create the Edge GW manually and then analyze the properties via Show-Object Function (PS-Helper/Show-Object.ps1 at master · mycloudrevolution/PS-Helper · GitHub )
$Edge = Search-Cloud -QueryType EdgeGateway -Name $Name
$EdgeView = $Edge | Get-CIView
Show-Object $EdgeView
Markus, thanks for useful script, i modified it into a function.
I think that at first it's necessary to create isolated network in OrgVDC and after connect this network to second Edge Gateway Interface. But my question is still actual - How to initialize (create) second interface of Edge Gateway
Hello,
I have written a new Function to create NatRouted Org Networks:
VMware-vCD-Module/New-MyOrgNetwork.psm1 at NewOrgNet · mycloudrevolution/VMware-vCD-Module · GitHub
This Function Creates a New Org Network and attaches this Network to an existing Edge Gateway. Maybe this helps you...
The other Option is to create a new Isolated OrgNet and the add it to the EdgeGateway. You can Check this Blog post for the basic approach (get the existing Config and then use updateServerData()😞 GeekAfterFive - Infrastructure as Code
Best regards,
Markus
Markus, thanks a lot!
It's amazing!
Markus, did you try to create network with your function?
I tried to create Routed Org Net but got the error:
PowerCLI C:\> New-MyOrgNetwork -Name "Test-Net" -OrgVdcName "Test-VDC" -OrgName "Test" -EdgeName "Test-Edge"
-SubnetMask 255.255.255.0 -Gateway 192.168.66.1 -IPRangeStart 192.168.66.2 -IPRangeEnd 192.168.66.50
Exception on call "CreateNetwork" with "1" arguments: "[ 8edd6315-4498-42f7-a17b-cd3ab8ed0928 ] class java.lang.NullPointerException"
C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\New-MyOrgNetwork\New-MyOrgNetwork.psm1:101 sign:9
+ $CreateOrgNetwork = $orgVdcView.CreateNetwork($OrgNetwork)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : CloudException
Get-OrgVdcNetwork : Can not check argument for parameter "Id". Argument empty or has value NULL. Specify a non-null argument that does not have a NULL value, then repeat the command.
C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\New-MyOrgNetwork\New-MyOrgNetwork.psm1:105 sign:39
+ while(!(Get-OrgVdcNetwork -Id $CreateOrgNetwork.Id -ErrorActi ...
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-OrgVdcNetwork], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.Cloud.Commands.Cmdlets.GetOrgVdcNetwork
Get-OrgVdcNetwork : Can not check the argument for the "Id" parameter. The argument is empty or NULL. Specify a non-null argument that does not have a NULL value, then repeat the command.
C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\New-MyOrgNetwork\New-MyOrgNetwork.psm1:114 sign:31
+ Get-OrgVdcNetwork -Id $CreateOrgNetwork.Id | Select-Object Na ...
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-OrgVdcNetwork], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.Cloud.Commands.Cmdlets.GetOrgVdcNetwork
Hello,
as I see have you used my example Command. I thin you should modify these Parameters: -OrgVdcName "Test-VDC" -OrgName "Test" -EdgeName "Test-Edge"
Markus,
I have really Organization "Test" with VDC "Test-VDC" and Edge Gateway "Test-Edge" in it at my vCD.
Ah, ok.
I verified the function again, nand it works in my environment.
My Environment:
- Script from master Branch: VMware-vCD-Module/New-MyOrgNetwork.psm1 at master · mycloudrevolution/VMware-vCD-Module · GitHub
- Connected as System Administrator
- PowerShell 5.1
- VMware PowerCLI 6.5.1
Markus,
I have the same environment.
What is the version of your vCloud Director?
I have 9.0.0.2 (when topic was created it was 8.20).
OK, probably the vCD Version is the Problem I verified the Script with 8.20. I can Test tomorrow with a 9.1 instance.
Do you use Advanced Edges (I do)?
Might you please do the same Check we have done with the manual Edge Gatway properties with the Org Network?