<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:clearspace="http://www.jivesoftware.com/xmlns/clearspace/rss" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>VMware Communities: Message List - Trouble retrieving VM objects</title>
    <link>http://communities.vmware.com/community/developer/forums/vsphere_sdk_perl?view=discussions</link>
    <description>Most recent forum messages</description>
    <language>en</language>
    <pubDate>Fri, 26 Jun 2009 21:41:52 GMT</pubDate>
    <generator>Clearspace 1.10.12 (http://jivesoftware.com/products/clearspace/)</generator>
    <dc:date>2009-06-26T21:41:52Z</dc:date>
    <dc:language>en</dc:language>
    <item>
      <title>Re: Trouble retrieving VM objects</title>
      <link>http://communities.vmware.com/message/1296375?tstart=0#1296375</link>
      <description>At least it was something simple. Sorry I misread your post not once, but twice. &lt;img class="jive-emoticon" border="0" src="http://communities.vmware.com/images/emoticons/wink.gif" alt=";)" /&gt;</description>
      <pubDate>Fri, 26 Jun 2009 21:41:52 GMT</pubDate>
      <author>stumpr</author>
      <guid>http://communities.vmware.com/message/1296375?tstart=0#1296375</guid>
      <dc:date>2009-06-26T21:41:52Z</dc:date>
      <clearspace:dateToText>5 months, 21 hours ago</clearspace:dateToText>
    </item>
    <item>
      <title>Re: Trouble retrieving VM objects</title>
      <link>http://communities.vmware.com/message/1296374?tstart=0#1296374</link>
      <description>&lt;br /&gt;
Gee, I finaliy figured out what's going on. The account I'm using didn't have enough permissions in the cluster I was querying. I ran the code against another cluster and voila! &lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
Hahaha, I feel stupid. Thanks a lot for your help, though.&lt;br /&gt;
&lt;p /&gt;
&lt;br /&gt;</description>
      <pubDate>Fri, 26 Jun 2009 21:40:26 GMT</pubDate>
      <author>rsantos@qualcomm.com</author>
      <guid>http://communities.vmware.com/message/1296374?tstart=0#1296374</guid>
      <dc:date>2009-06-26T21:40:26Z</dc:date>
      <clearspace:dateToText>5 months, 21 hours ago</clearspace:dateToText>
      <clearspace:replyCount>1</clearspace:replyCount>
    </item>
    <item>
      <title>Re: Trouble retrieving VM objects</title>
      <link>http://communities.vmware.com/message/1296325?tstart=0#1296325</link>
      <description>So I wrote some code almost matching what you got (only difference was variable names).  It's working for me.&lt;br /&gt;
&lt;br /&gt;
Is your hash declaration in a loop so it's getting reset?</description>
      <pubDate>Fri, 26 Jun 2009 21:14:08 GMT</pubDate>
      <author>stumpr</author>
      <guid>http://communities.vmware.com/message/1296325?tstart=0#1296325</guid>
      <dc:date>2009-06-26T21:14:08Z</dc:date>
      <clearspace:dateToText>5 months, 22 hours ago</clearspace:dateToText>
      <clearspace:replyCount>2</clearspace:replyCount>
    </item>
    <item>
      <title>Re: Trouble retrieving VM objects</title>
      <link>http://communities.vmware.com/message/1296320?tstart=0#1296320</link>
      <description>&lt;br /&gt;
That's what I thought this section of the code was doing:&lt;br /&gt;
&lt;p /&gt;
my $datastores = Vim::get_views (mo_ref_array =&amp;gt; $cluster-&amp;gt;datastore);&lt;br /&gt;
foreach my $datastore (sort @$datastores){&lt;br /&gt;
my $vms = Vim::get_views (mo_ref_array =&amp;gt; $datastore-&amp;gt;vm);&lt;br /&gt;
&lt;p /&gt;
But the @$vms array appears to be empty and I'm not sure why. I know that the @$datastores array is being populated, though, so it appears to be a valid array reference.&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;br /&gt;</description>
      <pubDate>Fri, 26 Jun 2009 20:52:00 GMT</pubDate>
      <author>rsantos@qualcomm.com</author>
      <guid>http://communities.vmware.com/message/1296320?tstart=0#1296320</guid>
      <dc:date>2009-06-26T20:52:00Z</dc:date>
      <clearspace:dateToText>5 months, 22 hours ago</clearspace:dateToText>
      <clearspace:replyCount>3</clearspace:replyCount>
    </item>
    <item>
      <title>Re: Trouble retrieving VM objects</title>
      <link>http://communities.vmware.com/message/1296319?tstart=0#1296319</link>
      <description>Sorry, didn't read that detail the first time.  That's also easy.&lt;br /&gt;
&lt;br /&gt;
Look at the &lt;a class="jive-link-external" href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.Datastore.html"&gt;Datastore&lt;/a&gt; object, particular the &lt;b&gt;vm&lt;/b&gt; property.  It'll give you an array of morefs of VMs using it.  Obviously, this won't include VMs that are not in the VC inventory, for that you'd have to search the datastore for files and make some assumptions about their validity by name.</description>
      <pubDate>Fri, 26 Jun 2009 20:46:22 GMT</pubDate>
      <author>stumpr</author>
      <guid>http://communities.vmware.com/message/1296319?tstart=0#1296319</guid>
      <dc:date>2009-06-26T20:46:22Z</dc:date>
      <clearspace:dateToText>5 months, 22 hours ago</clearspace:dateToText>
      <clearspace:replyCount>4</clearspace:replyCount>
    </item>
    <item>
      <title>Re: Trouble retrieving VM objects</title>
      <link>http://communities.vmware.com/message/1296280?tstart=0#1296280</link>
      <description>&lt;br /&gt;
But wouldn't this give me all VMs in a datacenter? I'm only interested in VMs on a given datastore.&lt;br /&gt;
&lt;p /&gt;
&lt;br /&gt;</description>
      <pubDate>Fri, 26 Jun 2009 20:17:50 GMT</pubDate>
      <author>rsantos@qualcomm.com</author>
      <guid>http://communities.vmware.com/message/1296280?tstart=0#1296280</guid>
      <dc:date>2009-06-26T20:17:50Z</dc:date>
      <clearspace:dateToText>5 months, 22 hours ago</clearspace:dateToText>
      <clearspace:replyCount>5</clearspace:replyCount>
    </item>
    <item>
      <title>Re: Trouble retrieving VM objects</title>
      <link>http://communities.vmware.com/message/1296051?tstart=0#1296051</link>
      <description>Have you looked at the named parameter "begin_entity" ?&lt;br /&gt;
&lt;br /&gt;
You could probably save some logic by getting a ManagedObject Reference to your datacenter of choice, then make your &lt;b&gt;find_entity_views&lt;/b&gt; call:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;my $virtual_machine_views = Vim::find_entity_view(
     view_type =&amp;gt; &amp;quot;VirtualMachine&amp;quot;,
     begin_entity =&amp;gt; $datacenter_moref,
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
That would probably be a little easier.</description>
      <pubDate>Fri, 26 Jun 2009 16:21:39 GMT</pubDate>
      <author>stumpr</author>
      <guid>http://communities.vmware.com/message/1296051?tstart=0#1296051</guid>
      <dc:date>2009-06-26T16:21:39Z</dc:date>
      <clearspace:dateToText>5 months, 1 day ago</clearspace:dateToText>
      <clearspace:replyCount>6</clearspace:replyCount>
    </item>
    <item>
      <title>Trouble retrieving VM objects</title>
      <link>http://communities.vmware.com/message/1295509?tstart=0#1295509</link>
      <description>I'm trying to collect all VMs in a datastore from a given datacenter, passed as a command line argument. Here's a snippet:&lt;br /&gt;
&lt;br /&gt;
my %allvms = (); &lt;br /&gt;
&lt;br /&gt;
my $clusters = Vim::find_entity_views(&lt;br /&gt;
view_type =&amp;gt; 'ClusterComputeResource',&lt;br /&gt;
filter =&amp;gt; { 'name' =&amp;gt; "$cluster_name" },&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
foreach my $cluster ( @$clusters ){&lt;br /&gt;
print "Cluster: " . $cluster-&amp;gt;name . "\n";&lt;br /&gt;
my $datastores = Vim::get_views (mo_ref_array =&amp;gt; $cluster-&amp;gt;datastore);&lt;br /&gt;
foreach my $datastore (sort @$datastores){&lt;br /&gt;
my $vms = Vim::get_views (mo_ref_array =&amp;gt; $datastore-&amp;gt;vm);&lt;br /&gt;
foreach my $vm ( @$vms ){&lt;br /&gt;
$allvms{$vm-&amp;gt;name}{path} = $vm-&amp;gt;summary-&amp;gt;config-&amp;gt;vmPathName;&lt;br /&gt;
$allvms{$vm-&amp;gt;name}{name} = $vm-&amp;gt;name;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;p /&gt;
&lt;br /&gt;
foreach ( sort keys %allvms ){ print "$_: $allvms{$_}{path}\n"; }&lt;br /&gt;
&lt;br /&gt;
But the %allvms hash is empy.  What am I doing wrong?&lt;br /&gt;
&lt;br /&gt;
Thanks much!&lt;br /&gt;
Rob</description>
      <pubDate>Fri, 26 Jun 2009 02:05:06 GMT</pubDate>
      <author>rsantos@qualcomm.com</author>
      <guid>http://communities.vmware.com/message/1295509?tstart=0#1295509</guid>
      <dc:date>2009-06-26T02:05:06Z</dc:date>
      <clearspace:dateToText>5 months, 1 day ago</clearspace:dateToText>
      <clearspace:replyCount>7</clearspace:replyCount>
    </item>
  </channel>
</rss>

