Hi
Trying to create a script for vCloud Director automation. For a vApp with a number of networks, I want to create static routes on a vApp. I have found some components to use, but I just can't get the components to work. It isn't really a script yet, I was first playing with the snippets. I have already created some StaticRoutes through the GUI as an example to work with.
The vApp on which I have a number of networks configured is named: vApp_Topdesk
The networks are: vAppNet-10.239.12, vAppNet-172.17.1, vAppNet-172.17.12, vAppNet-10.239.1
Snippets:
$vAppTopdesk = Get-CIVApp -Name vApp_Topdesk
$FirstvNet = $vAppTopdesk | Get-CIVAppNetwork -Name vAppNet-10.239.12
If I now run this:
$FirstNet.ExtensionData.Configuration.features.StaticRoute
The result is:
Name : To-10.239.1
Network : 10.239.1.0/24
NextHopIp : 192.168.0.10
Interface : External
GatewayInterface :
AnyAttr :
VCloudExtension :
Name : To-172.17.1
Network : 172.17.1.0/24
NextHopIp : 192.168.0.124
Interface : External
GatewayInterface :
AnyAttr :
VCloudExtension :
Now I would like to add a static route myself. So I build this:
$routeService = New-Object vmware.vimautomation.cloud.views.staticroutingservice
$routeService.IsEnabled = $true <---- Not sure if needed because I already have static routes
$routeService.StaticRoute = New-Object vmware.vimautomation.cloud.views.staticroute
$routeService.StaticRoute[0].name = "To-172.17.12"
$routeService.StaticRoute[0].network = "172.17.12.0/24"
$routeService.StaticRoute[0].nexthopip = "192.168.0.21"
$routeService.StaticRoute[0].interface = "External"
But how can I now put the content from $routeService into the vApp?
What I tried:
$vAppNetworks.NetworkConfig += $routeService
Exception setting "NetworkConfig": "Cannot convert the "VMware.VimAutomation.Cloud.Views.StaticRoutingService" value of type "VMware.VimAutomation.Cloud.Views.StaticRoutingService" to type "VMware.VimAutom
ation.Cloud.Views.VAppNetworkConfiguration"."
At line:1 char:1
+ $vAppNetworks.NetworkConfig += $routeService
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting
And also:
$CurrentStaticRoutes += $routeService[0]
Method invocation failed because [VMware.VimAutomation.Cloud.Views.StaticRoutingService] doesn't contain a method named 'op_Addition'.
At line:1 char:1
+ $CurrentStaticRoutes += $routeService[0]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Any tips on how to get this to work would be great :-)