How to list the Distributed switches of a vCenter Cluster? I did not see a property in VC:ClusterComputeResource.
Check the following code (the input variable is cluster😞
for each (var host in cluster.host) {
for each (var net in host.network) {
if (net.config == null) continue;
var dvs = net.config.distributedVirtualSwitch;
System.log(dvs.name + " (id: " + dvs.id + ")");
}
}
The above code will print distributed virtual switches' names and IDs.
Note that it may, and likely will, print a lot of duplicate entries, as one distributed virtual switch can be associated with multiple hosts. So you may need to add some extra code to filter out the duplicate entries from the output of the above code.
Check the following code (the input variable is cluster😞
for each (var host in cluster.host) {
for each (var net in host.network) {
if (net.config == null) continue;
var dvs = net.config.distributedVirtualSwitch;
System.log(dvs.name + " (id: " + dvs.id + ")");
}
}
The above code will print distributed virtual switches' names and IDs.
Note that it may, and likely will, print a lot of duplicate entries, as one distributed virtual switch can be associated with multiple hosts. So you may need to add some extra code to filter out the duplicate entries from the output of the above code.