<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help with a script that tries to gather info in vSphere SDK for Perl Discussions</title>
    <link>https://communities.vmware.com/t5/vSphere-SDK-for-Perl-Discussions/Help-with-a-script-that-tries-to-gather-info/m-p/366853#M268</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Oct 2012 13:13:37 GMT</pubDate>
    <dc:creator>cmartinvalle</dc:creator>
    <dc:date>2012-10-02T13:13:37Z</dc:date>
    <item>
      <title>Help with a script that tries to gather info</title>
      <link>https://communities.vmware.com/t5/vSphere-SDK-for-Perl-Discussions/Help-with-a-script-that-tries-to-gather-info/m-p/366849#M264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have this piece of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV id="_mcePaste"&gt;my $vm_view = Vim::find_entity_views(view_type =&amp;gt; 'VirtualMachine');&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;my $vnic_name;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;my $vnic_device;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt; &lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;foreach(@$vm_view) {&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; my $vm_name = $_-&amp;gt;summary-&amp;gt;config-&amp;gt;name;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; my $devices =$_-&amp;gt;config-&amp;gt;hardware-&amp;gt;device;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; my $mac_string;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; my $network = "";&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach(@$devices) {&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if($_-&amp;gt;isa("VirtualEthernetCard")) {&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $mac_string .= "\t\t[" . $_-&amp;gt;deviceInfo-&amp;gt;label . "] : " . $_-&amp;gt;macAddress . "\n";&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($_-&amp;gt;deviceInfo-&amp;gt;label eq $vnic_name){&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $vnic_device=$_;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "\t$vnic_device\n";&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; my $currMac = $vnic_device-&amp;gt;macAddress;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "\t$currMac\n";&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; my $network = Vim::get_view(mo_ref =&amp;gt; $_-&amp;gt;backing-&amp;gt;network, properties =&amp;gt; ['name']);&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "\t" . $network-&amp;gt;{'name'} . "\n";&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And when executing it, the output is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Undefined subroutine &amp;amp;VirtualEthernetCardDistributedVirtualPortBackingInfo::network called at getAllVMMacs.pl line 38&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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 =&amp;gt; $_-&amp;gt;backing-&amp;gt;network, properties =&amp;gt; ['name']);" but I don't know how to invoke to the right object, does anyone know how to do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;H1&gt;&lt;/H1&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 16:39:12 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-SDK-for-Perl-Discussions/Help-with-a-script-that-tries-to-gather-info/m-p/366849#M264</guid>
      <dc:creator>cmartinvalle</dc:creator>
      <dc:date>2012-09-27T16:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script that tries to gather info</title>
      <link>https://communities.vmware.com/t5/vSphere-SDK-for-Perl-Discussions/Help-with-a-script-that-tries-to-gather-info/m-p/366850#M265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to check your backing type since there are differences between a DistributeVirtualPortgroup and a standard Portgroup.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 02:38:25 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-SDK-for-Perl-Discussions/Help-with-a-script-that-tries-to-gather-info/m-p/366850#M265</guid>
      <dc:creator>stumpr</dc:creator>
      <dc:date>2012-09-28T02:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script that tries to gather info</title>
      <link>https://communities.vmware.com/t5/vSphere-SDK-for-Perl-Discussions/Help-with-a-script-that-tries-to-gather-info/m-p/366851#M266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, that's it! Many thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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 &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.vmware.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 10:38:10 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-SDK-for-Perl-Discussions/Help-with-a-script-that-tries-to-gather-info/m-p/366851#M266</guid>
      <dc:creator>cmartinvalle</dc:creator>
      <dc:date>2012-09-28T10:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script that tries to gather info</title>
      <link>https://communities.vmware.com/t5/vSphere-SDK-for-Perl-Discussions/Help-with-a-script-that-tries-to-gather-info/m-p/366852#M267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Working from memory here...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your backing type in the case of a Distributed Virtual Switch Portgroup will be a 'VirtualEthernetCardDistributedVirtualPortBackingInfo'.&amp;nbsp; From that, you can get the 'portgroupKey'.&amp;nbsp; That key should be a UUID type value, which you can use to find the DistributedVirtualPortgroup by comparing it with the DistributedVirtualPortgroup.key values.&amp;nbsp; That will have a 'name' property that is probably the value you want (portgroup name).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can probably do something like the following once you get your portgroupKey -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$pgKey = &amp;lt;key value from VirtualEthernetCardDistributedVirtualPortBackingInfo&amp;gt;;&lt;/P&gt;&lt;P&gt;$dvpg = find_entity_view( view_type =&amp;gt; 'DistributedVirtualPortgroup', filter =&amp;gt; { 'key' =&amp;gt; $pgKey }, properties =&amp;gt; [ 'name' ] );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print $dvpg-&amp;gt;{'name'} . "\n";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H1&gt;&lt;/H1&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 14:20:57 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-SDK-for-Perl-Discussions/Help-with-a-script-that-tries-to-gather-info/m-p/366852#M267</guid>
      <dc:creator>stumpr</dc:creator>
      <dc:date>2012-09-28T14:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script that tries to gather info</title>
      <link>https://communities.vmware.com/t5/vSphere-SDK-for-Perl-Discussions/Help-with-a-script-that-tries-to-gather-info/m-p/366853#M268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2012 13:13:37 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-SDK-for-Perl-Discussions/Help-with-a-script-that-tries-to-gather-info/m-p/366853#M268</guid>
      <dc:creator>cmartinvalle</dc:creator>
      <dc:date>2012-10-02T13:13:37Z</dc:date>
    </item>
  </channel>
</rss>

