server/lib/deltacloud/drivers/vsphere/vsphere_client.rb
# Find a VirtualMachine traversing through all Datastores and Datacenters
#
# This helper will return a Hash: { :datastore => NAME_OF_DS, :instance => VM }
# Returning datastore is necesarry for constructing a correct realm for an
# instance
#
Find a VirtualMachine traversing through all Datastores and Datacenters
This helper will return a Hash: { :datastore => NAME_OF_DS, :instance => VM }
Returning datastore is necesarry for constructing a correct realm for an
instance
Find a VirtualMachine traversing through all Datastores and Datacenters This helper will return a Hash : { : datastore = > NAME_OF_DS : instance = > VM } Returning datastore is necesarry for constructing a correct realm for an instance
def find_vm(credentials, name)
      vsphere = new_client(credentials)
      safely do
        rootFolder = vsphere.serviceInstance.content.rootFolder
        vm = {}
        rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).each do |dc|
          dslist = list_datastores(dc.datastoreFolder)
          dslist.each do |datastore|
            vm[:instance] = datastore.vm.find { |x| x.name == name }
            if vm[:instance]
              vm[:datastore] = datastore.name
              break
            end
            stored_tasks(datastore, vsphere) do |task|
              if task.info.entity.class == RbVmomi::VIM::VirtualMachine and ['queued', 'running'].member? task.info.state
                vm = { :stored_instance => load_serialized_instance(datastore,task.info.key), :datastore => datastore.name }
              end
            end
          end
          break if vm[:datastore]
        end
        vm
      end
    end
def find_vm ( credentials , name ) vsphere = new_client ( credentials ) safely do rootFolder = vsphere . serviceInstance . content . rootFolder vm = { } rootFolder . childEntity . grep ( RbVmomi :: VIM :: Datacenter ) . each do | dc | dslist = list_datastores ( dc . datastoreFolder ) dslist . each do | datastore | vm [ :instance ] = datastore . vm . find { | x | x . name == name } if vm [ :instance ] vm [ :datastore ] = datastore . name break end stored_tasks ( datastore , vsphere ) do | task | if task . info . entity . class == RbVmomi :: VIM :: VirtualMachine and [ 'queued' , 'running' ] . member? task . info . state vm = { :stored_instance => load_serialized_instance ( datastore , task . info . key ) , :datastore => datastore . name } end end end break if vm [ :datastore ] end vm end end
Find a VirtualMachine traversing through all Datastores and Datacenters
This helper will return a Hash: { :datastore => NAME_OF_DS, :instance => VM }
Returning datastore is necesarry for constructing a correct realm for an
instance
Find a VirtualMachine traversing through all Datastores and Datacenters This helper will return a Hash : { : datastore = > NAME_OF_DS : instance = > VM } Returning datastore is necesarry for constructing a correct realm for an instance
credentials
<not_specific>
name
<not_specific>