Hi,
I have this piece of code:
And when executing it, the output is:
Undefined subroutine &VirtualEthernetCardDistributedVirtualPortBackingInfo::network called at getAllVMMacs.pl line 38
But I want to gather info from the object VirtualEthernetCardNetworkBackingInfo, not from VirtualEthernetCardDistributedVirtualPortBackingInfo, I suppose the problem is in this line: "my $network = Vim::get_view(mo_ref => $_->backing->network, properties => ['name']);" but I don't know how to invoke to the right object, does anyone know how to do it?
Many thanks.
You have to check your backing type since there are differences between a DistributeVirtualPortgroup and a standard Portgroup.
OK, that's it! Many thanks!
It only works with Standard Switches. Do you know who is the right object and proporti for Distributed Switches? I'm trying with some of them (VirtualEthernetCardDistributedVirtualPortBackingInfo, DistributedVirtualSwitch, DistributedVirtualPortGroup, etc.) but still without success
Working from memory here...
Your backing type in the case of a Distributed Virtual Switch Portgroup will be a 'VirtualEthernetCardDistributedVirtualPortBackingInfo'. From that, you can get the 'portgroupKey'. That key should be a UUID type value, which you can use to find the DistributedVirtualPortgroup by comparing it with the DistributedVirtualPortgroup.key values. That will have a 'name' property that is probably the value you want (portgroup name).
You can probably do something like the following once you get your portgroupKey -
$pgKey = <key value from VirtualEthernetCardDistributedVirtualPortBackingInfo>;
$dvpg = find_entity_view( view_type => 'DistributedVirtualPortgroup', filter => { 'key' => $pgKey }, properties => [ 'name' ] );
print $dvpg->{'name'} . "\n";
If you were looking for speed in your script, you could fetch all the Network and DistributedVirtualPortgroup entities and store them in a hash for later lookup to avoid the multiple SDK calls.
Thank you very much! I will give it a try this week and will share the results with you. From my ignorance, it seems to be right!