Quantcast
Channel: VMware Communities : Discussion List - vSphere SDK for Perl
Viewing all articles
Browse latest Browse all 1577

Filtering Virtual Machine view with the name of the Host

$
0
0

Hi,

 

I'm trying to get a specific Virtual Machine view from an hypervisor.

 

Basically I tried to reuse an idea found on the cdromdisconnect.pl script, an addressed in http://communities.vmware.com/message/1192878#1192878

 

The code would be

 

 

my $host_view = Vim::find_entity_view (
    view_type   =>  'HostSystem',
    filter      => { 'name' => $vm_hypervisor_name},
  ); 

 

my $host_moref = $host_view->{mo_ref}{value};

 


$vm_view = Vim::find_entity_views (
    view_type   =>  'VirtualMachine',
    filter      =>  {
                        'runtime.host' => $host_moref,

                        'name'           => $vm_name,

    },
);

 

 

But the API says that "Filtering is only supported for Simple Type"

 

 

So actually i'm just getting the host_view, and then call the "->vm" property to retrieve all the vm of the Host, and then I loop inside the array to fetch the name and have the VM I'm looking for

 

 

 

But, Isn't there a smoother way to get directly the entity view of a specific host's VM?

 

 

Thanks


Viewing all articles
Browse latest Browse all 1577

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>