VMware Cloud Community
jamesbowling
VMware Employee
VMware Employee

Gateway address and subnet mask have to be provided...

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!

James B. | Blog: http://www.vSential.com | Twitter: @vSential --- If you found this helpful then please awards helpful or correct points accordingly. Thanks!
0 Kudos
3 Replies
jake_robinson_b
Hot Shot
Hot Shot

I think the ipscope should actually be in the ipscopes collection…

http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/types/NetworkConfigur...

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

Jake Robinson VCP, vExpert - geekafterfive.com - Twitter: @jakerobinson
jamesbowling
VMware Employee
VMware Employee

Seems to be closer, getting another exception now, Exception calling "CreateNetwork" with "1" argument(s): "entityRef"

James B. | Blog: http://www.vSential.com | Twitter: @vSential --- If you found this helpful then please awards helpful or correct points accordingly. Thanks!
0 Kudos
jamesbowling
VMware Employee
VMware Employee

Missed something, forgot to add the EdgeGateway.  Added that and it is now working.  Thanks for your help Jake!

James B. | Blog: http://www.vSential.com | Twitter: @vSential --- If you found this helpful then please awards helpful or correct points accordingly. Thanks!
0 Kudos