As part of some workflow I am building for a customer, I need to automate assigning the default route (default gateway) for an vCNS Edge appliance, using vRealize Orchestrator.
The provided NSXDefaultRoute, which can be used with NSXEdgeManager.setDefaultRoute() per the documentation, has read-only properties and the NSX Orchestrator Plugin 1.0.4 provides no further documentation to my knowledge on how to use this scripting object:
There are two accessors available as part of the NSXDefaultRoute scripting object. To my knowledge, these are not documented.
- NSXDefaultRoute.setvNicIndex(string vnicindex)
- NSXDefaultRoute.setGatewayIpAddress(string ip)
Note, there is no accessor for MTU, although as shown below that is an option in the default gateway config.
This example code works with vRealize Automation 7.1 and the embedded Orchestrator service.
Setup a new workflow with these variables as input, and the below code in a scripting task, and it should work for you too.
- Variable nsx is a NSX:Connection object specifying my vCNS Manager in vRO inventory
- Variable edgeId is a string object specifying the edge objectId, such as edge-28
var route = new NSXDefaultRoute();
route.setvNicIndex("0"); //Generally 0 if your first Edge Interface is where traffic should be routed by default, otherwise 2, 3, 4, etc.
route.setGatewayIpAddress("192.168.18.254"); //Must be in the same subnet defined for vNicIndex
NSXEdgeManager.setDefaultRoute(nsx, edgeId, route);
Here’s the results after running this code