After several hours and searches in the vSphere API and Onyx I realized that there isn´t any direct method for that :(
So I test the illogical things and enhanced the defaultPortConfig attribute about the vlan attribute... and what should I say: There was an atribute!
After testing if the attribute is part of the VcVmwareDistributedVirtualSwitchVlanIdSpec I was able to check the vlan :)
for(i in dvSwitch.portgroup){
System.debug(dvSwitch.portgroup[i].config.defaultPortConfig.vlan);
if(dvSwitch.portgroup[i].config.defaultPortConfig.vlan instanceof VcVmwareDistributedVirtualSwitchVlanIdSpec){
System.debug(dvSwitch.portgroup[i].config.defaultPortConfig.vlan.vlanId);
}
}
This looks like the following screen in the end:
So I hope this helps! By the way, I never had so many failed runs in a row :)
I got it a bit differently, sheer luck that I found out how:
ReplyDeleteWhen you get the object of DvPortGroupObject type (lets call it obj), do this in a workflow code:
DvPortGroupID = DvPortGroupObject.id;
This gives you the ID!! I was so happy when I found it :)
Happen to know if something similar is available in the java API? I looked at objects with similar names but did not find a vlan id anywhere.
ReplyDeleteI know it should be easy, but I'm new to this and I'm not getting quite what I need.
ReplyDeleteHow would I retrieve the vlan for a specific distributed portgroup?