Well this is my very first blog ever. Actually this is a reply to a blog on the mighty virtualization blog from Christian Johannsen on
http://mighty-virtualization.blogspot.com/2011/01/vco-get-all-distributed-virtual.html
Blogspot for some reason did not let me post this code as a reply but I thought I do not want to leave my talent wasted (cough!) and post it as a new blog. Maybe a start for something great. Well here it is, another code for VMware vCenter Orchestrator on how to get all Distributed Virtual Switches. In this case the name of it.
dc by the way is a VcDatacenter object. An input parameter if you will
var dcNetworkFolder = VcPlugin.convertToVimManagedObject( dc, dc.networkFolder.childEntity ); for each (var netItem in dcNetworkFolder) { if (netItem instanceof VcVmwareDistributedVirtualSwitch) { System.log( "DVS Name: " + netItem.name); } }
Today I actually noticed that you could create a network folder put a dvs switch in there and the code above then would not find it as it only runs through the root network folder. So if you are actually using network folders then you need to run through all network folders. But I don’t leave you alone with that. Below you find a code that does that. However you will get all dvs switches and not just the ones that belong to a specific datacenter.
var allNetFolder = sdkConnection.getAllNetworkFolders(); for each (var netFolder in allNetFolder) { var dcNetworkFolder = VcPlugin.convertToVimManagedObject( netFolder, netFolder.childEntity ); for each (var netItem in dcNetworkFolder) { if (netItem instanceof VcVmwareDistributedVirtualSwitch) { System.log( "DVS Name: " + netItem.name); } } }
thx Mike!