mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #2037 from maestrodev/vsphere-get_virtual_machine
[vsphere] searchIndex.FindByUuid datacenter parameter must be a RbVmomi::VIM::Datacenter
This commit is contained in:
commit
10fa1c4924
2 changed files with 15 additions and 11 deletions
|
@ -9,14 +9,17 @@ module Fog
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def get_vm_ref(id, dc = nil)
|
def get_vm_ref(id, dc = nil)
|
||||||
|
raw_datacenter = find_raw_datacenter(dc) if dc
|
||||||
vm = case is_uuid?(id)
|
vm = case is_uuid?(id)
|
||||||
# UUID based
|
# UUID based
|
||||||
when true
|
when true
|
||||||
@connection.searchIndex.FindByUuid :uuid => id, :vmSearch => true, :instanceUuid => true, :datacenter => dc
|
params = {:uuid => id, :vmSearch => true, :instanceUuid => true}
|
||||||
|
params[:datacenter] = raw_datacenter if dc
|
||||||
|
@connection.searchIndex.FindByUuid(params)
|
||||||
else
|
else
|
||||||
# try to find based on VM name
|
# try to find based on VM name
|
||||||
if dc
|
if dc
|
||||||
get_raw_datacenter(dc).find_vm(id)
|
raw_datacenter.find_vm(id)
|
||||||
else
|
else
|
||||||
raw_datacenters.map { |d| d.find_vm(id) }.compact.first
|
raw_datacenters.map { |d| d.find_vm(id) }.compact.first
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,7 @@ module Fog
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
# RbVmomi::VIM::Datacenter Array
|
||||||
def raw_datacenters
|
def raw_datacenters
|
||||||
@raw_datacenters ||= @connection.rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter)
|
@raw_datacenters ||= @connection.rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue