Menu

List VM's and Templates Separately

Help
Chris
2007-06-05
2013-04-24
  • Chris

    Chris - 2007-06-05

    Hello All!

    I am having an issue with a script I have written using the VIPerlToolKit.  When I list the VM's in my inventory using the code below I am getting all VM's and Templates returned as well.  Is there a filter or a different way to query to gain a list of only actual Virtual Machines and not the templates on the system.

        my $vm = Vim::find_entity_views(view_type => "VirtualMachine");
         foreach (@$vm) {
            eval {
                my $vmname = $_->name;
                # Do Some Work Here

            }
        }

    Thanks Chris

     
    • Subtil

      Subtil - 2007-06-06

      Sure, you can filter VM (same for every entity type) when you retrieve it.
      Here is what you can make to list templates, just switch the "1" to "0" to get all machines.

      Note : this forum is almost dead, you should go on VMware VMTN at :
      http://www.vmware.com/community/category.jspa?categoryID=113
      (damn, you already post there...)

      my $vm = Vim::find_entity_views(
         view_type => "VirtualMachine",
         filter => {'config.template' => '1'}
      );

      foreach (@$vm) {
         eval {
            my $vmname = $_->name;
         }
      }
         

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.