I am trying to get this script working for creating an OrgNetwork in vCD 5.1. When I run it I get an exception saying that "Gateway address and subnet mask have to be provided when creating routed/isolated org VDC network." Here is what I have, this is a modified version of a vApp network creation script that Jake Robinson wrote:
$orgName = "1001"
$org = Get-OrgVdc $orgName | Get-CIView
$mynetwork = new-object vmware.vimautomation.cloud.views.orgvdcnetwork
$mynetwork.Name = "1001-Test"
$mynetwork.configuration = new-object vmware.vimautomation.cloud.views.networkconfiguration
$mynetwork.configuration.fencemode = "natRouted"
$mynetwork.Configuration.IpScope = new-object vmware.vimautomation.cloud.views.ipscope
$mynetwork.Configuration.IpScope.Gateway = "192.168.2.1"
$mynetwork.Configuration.IpScope.Netmask = "255.255.255.0"
$mynetwork.Configuration.IpScope.Dns1 = "192.168.2.1"
$mynetwork.Configuration.IpScope.IpRanges = new-object vmware.vimautomation.cloud.views.ipranges
$mynetwork.Configuration.IpScope.IpRanges.IpRange = new-object vmware.vimautomation.cloud.views.iprange
$mynetwork.Configuration.IpScope.IpRanges.IpRange[0].startaddress = "192.168.2.100"
$mynetwork.Configuration.IpScope.IpRanges.IpRange[0].endaddress = "192.168.2.200"
$result = $org.CreateNetwork($mynetwork)
Any help would be greatly appreciated. Thanks in advance!
I think the ipscope should actually be in the ipscopes collection…
I don't have time to test this, but it's probably like so:
…
$mynetwork.Configuration.IpScopes = New-Object vmware.vimautomation.cloud.views.IpScopes
$scope = New-Object vmware.vimautomation.cloud.views.IpScope
$scope.Gateway = "192.168.2.1"
$scope.Netmask = "255.255.255.0"
$scope.Dns1 = "192.168.2.1"
$scope.IpRanges = new-object vmware.vimautomation.cloud.views.ipranges
$scope.IpRanges.IpRange = new-object vmware.vimautomation.cloud.views.iprange
$scope.IpRanges.IpRange[0].startaddress = "192.168.2.100"
$scope.IpRanges.IpRange[0].endaddress = "192.168.2.200"
$mynetwork.Configuration.IpScopes += $scope
…
Seems to be closer, getting another exception now, Exception calling "CreateNetwork" with "1" argument(s): "entityRef"
Missed something, forgot to add the EdgeGateway. Added that and it is now working. Thanks for your help Jake!