Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/vSphere/action/clone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def get_location(datastore, dc, machine, template)
location[:datastore] = datastore unless datastore.nil?
end
location[:pool] = get_resource_pool(dc, machine) unless machine.provider_config.clone_from_vm
location[:host] = get_host_system(dc,machine) unless machine.provider_config.host_system.nil?
location
end

Expand Down
1 change: 1 addition & 0 deletions lib/vSphere/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Config < Vagrant.plugin('2', :config)
attr_accessor :password
attr_accessor :data_center_name
attr_accessor :compute_resource_name
attr_accessor :host_system
attr_accessor :resource_pool_name
attr_accessor :clone_from_vm
attr_accessor :template_name
Expand Down
6 changes: 6 additions & 0 deletions lib/vSphere/util/vim_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ def get_compute_resource(datacenter, machine)
cr
end

def get_host_system(datacenter, machine)
cr = find_clustercompute_or_compute_resource(datacenter, machine.provider_config.compute_resource_name)
hs = cr.host.find { |host| host.name == machine.provider_config.host_system }
hs
end

def find_clustercompute_or_compute_resource(datacenter, path)
if path.is_a? String
es = path.split('/').reject(&:empty?)
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def call
password: 'testpassword',
data_center_name: nil,
compute_resource_name: 'testcomputeresource',
host_system: nil,
resource_pool_name: 'testresourcepool',
vm_base_path: nil,
template_name: TEMPLATE,
Expand Down Expand Up @@ -122,6 +123,7 @@ def call
vmFolder: vm_folder,
pretty_path: "data_center/#{vm_folder}",
find_compute_resource: @compute_resource,
find_host_system: @host_system,
hostFolder: @host_folder)

@device = RbVmomi::VIM::VirtualEthernetCard.new
Expand Down