Morning,
I´m trying to work on a specific workflow and, in the middle of it, I need to get a vCNS/NSX Edge appliance to do some stuff with it.
The appliance will be different each time, so I need some sort of method to acquire it.
I already noticed that the vCNS/NSX plugin does not have an action, workflow or even an object function like a "Get all Edges" sort of thing.
I went through the API trying to find a REST call that would accomplish that, but got no luck there either.
Lastly, I tried using the Server.findAllForType method, and found something weird:
Set "vm" as Array/VC:VirtualMachine
vm = Server.findAllForType("VC:VirtualMachine")
"vm" is populated with a list of all virtual machines
=========================================
Now, if I do:
Set "edge" as Array/NSX:Edge
edge = Server.findAllForType("NSX:Edge")
"edge" is empty
I found it pretty weird since the vCNS/NSX plugin is working just fine as I´m using it with other workflows.
Any idea on how to capture a specific Edge or get a complete list of them?
Thank you very much.
Hi,
Looking at NSX plug-in source code, it seems that Server.findAllForType() would work only for type NSX:Connection. Not sure why, perhaps plug-in author(s) can elaborate on this, and correct me if I am wrong.
There is a scripting class NSXEdgeManager that seems suitable if you want to retrieve a specific edge. The scripting call could be something like
var edge = NSXEdgeManager.getEdge(connection, edgeid);
where connection is the connection object (of type NSXConnection) and edgeid is the ID of the edge you want to retrieve (of type string).
Hi,
Looking at NSX plug-in source code, it seems that Server.findAllForType() would work only for type NSX:Connection. Not sure why, perhaps plug-in author(s) can elaborate on this, and correct me if I am wrong.
There is a scripting class NSXEdgeManager that seems suitable if you want to retrieve a specific edge. The scripting call could be something like
var edge = NSXEdgeManager.getEdge(connection, edgeid);
where connection is the connection object (of type NSXConnection) and edgeid is the ID of the edge you want to retrieve (of type string).
Hum.........
You know. That just might work.
I won´t know the edge-id for this particular workflow, but I could retrieve it from the Edge hostname, since my Edges will have the default hostname.
Gonna try that and brb.
And it works!!
Here´s how it looks like.
Assuming:
- The Edge appliances have a standard name, based on a username (Ex: john-0);
- The Edge appliances use the default hostname (Ex: vShieldEdge-edge-<id>-0);
var vms = VcPlugin.allVirtualMachines;
for (var i in vms)
{
if (vms[i].summary.config.product != null)
{
namesplit = vms[i].name.split("-");
vmname = namesplit[0];
if (vms[i].summary.config.product.name == "vShield Edge" && vmname == username)
{
var edgevm = vms[i];
break; //I´m breaking here since I want just one appliance
}
}
}
var edgename = edgevm.summary.guest.hostName.split("-");
var edgeid = edgename[1] + "-" + edgename[2];
edge = NSXEdgeManager.getEdge(nsxconn,edgeid);
Thanks a lot once again