- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's possible the NIC doesn't have an assigned network portgroup. So you can just check for an ignore it in cases where it's not set. You may actually need to do this for a lot of properties in the API. When building report tools in the past, I usually create an accessor method like 'get_property()' that does all the eval, undefined and other value checks and returns something for print sanity (empty string, 'null', etc). There's actually a get_property() method that's on every object in the Perl SDK as well, but I don't use it myself. Not sure how it handles undefined values.
$pg = Vim::get_view(mo_ref => $pg_mo, properties => ['name']) if defined $pg_mo;
$network = (defined $pg->{'name'}) ? $pg->{'name'} : 'unset';
Reuben Stump | http://www.virtuin.com | @ReubenStump