Coder Social home page Coder Social logo

Comments (5)

cdickmann avatar cdickmann commented on June 30, 2024

Try connection.propertyCollector.collectMultiple(vms, prop1, prop2) or connection.propertyCollector.collectMultiple(vms, *props)

from rbvmomi.

Altonymous avatar Altonymous commented on June 30, 2024

tyvm, that's what I needed!

from rbvmomi.

Altonymous avatar Altonymous commented on June 30, 2024

@cdickmann While you're around.. am I getting the virtual machines array the most efficient way possible? We have folders nested in folders, so I figured I'd have to traverse them n-levels to find all the machines. Not ideal imo.

from rbvmomi.

cdickmann avatar cdickmann commented on June 30, 2024

Check out this example on how to use the property collector to traverse the tree in a single API call and get all objects of a certain type. In the example we walk the tree of resource pools to get all VMs:
https://github.com/vmware/rbvmomi/blob/master/lib/rbvmomi/utils/admission_control.rb#L167

There is also this example that traverses all kinds of stuff and gets all kinds of stuff:
https://github.com/vmware/rbvmomi/blob/master/lib/rbvmomi/utils/perfdump.rb#L79

from rbvmomi.

pmitoraj avatar pmitoraj commented on June 30, 2024

Just recently I found a convenient way of getting all the nested objects. It was somewhere in https://github.com/vmware/pyvmomi code base.
You can use view manager to collect all the nested objects of types that are interesting to you.
Here is a code sample:

params = {:host => '1.1.1.1',
  :insecure => true,
  :user => 'root',
  :password => 'pass'}
client = RbVmomi::VIM.connect(params)

si_content = client.serviceInstance.content
view_manager = si_content.viewManager
virtual_machines = view_manager.CreateContainerView(container: si_content.rootFolder,
                                        type: ['VirtualMachine'],
                                        recursive: true).view

value for type is an array with possible String values: VirtualMachine, Folder, Network, Datastore, ClusterComputeResource, ResourcePool, HostSystem

from rbvmomi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.