Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lib/vmpooler/providers/vsphere.rb
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def find_vmdks(vmname, datastore, connection)

vmdk_datastore = find_datastore(datastore, connection)

vm_files = vmdk_datastore._connection.serviceContent.propertyCollector.collectMultiple vmdk_datastore.vm, 'layoutEx.file'
vm_files = connection.serviceContent.propertyCollector.collectMultiple vmdk_datastore.vm, 'layoutEx.file'
vm_files.keys.each do |f|
vm_files[f]['layoutEx.file'].each do |l|
if l.name =~ /^\[#{vmdk_datastore.name}\] #{vmname}\/#{vmname}_([0-9]+).vmdk/
Expand Down
21 changes: 0 additions & 21 deletions spec/unit/providers/vsphere_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1236,11 +1236,6 @@
let(:reconfig_vm_task) { mock_RbVmomi_VIM_Task() }

before(:each) do
# NOTE - This method should not be using `_connection`, instead it should be using `@conection`
# This should not be required once https://github.com/puppetlabs/vmpooler/issues/213 is resolved
mock_ds = subject.find_datastore(datastorename,connection)
allow(mock_ds).to receive(:_connection).and_return(connection) unless mock_ds.nil?

# Mocking for find_vmdks
allow(connection.serviceContent.propertyCollector).to receive(:collectMultiple).and_return(collectMultiple_response)

Expand Down Expand Up @@ -2701,25 +2696,9 @@
let(:collectMultiple_response) { {} }

before(:each) do
# NOTE - This method should not be using `_connection`, instead it should be using `@conection`
mock_ds = subject.find_datastore(datastorename,connection)
allow(mock_ds).to receive(:_connection).and_return(connection)
allow(connection.serviceContent.propertyCollector).to receive(:collectMultiple).and_return(collectMultiple_response)
end

it 'should not use _connction to get the underlying connection object' do
pending('https://github.com/puppetlabs/vmpooler/issues/213')

mock_ds = subject.find_datastore(datastorename)
expect(mock_ds).to receive(:_connection).exactly(0).times

begin
# ignore all errors. What's important is that it doesn't call _connection
subject.find_vmdks(vmname,datastorename,connection)
rescue
end
end

context 'Searching all files for all VMs on a Datastore' do
# This is fairly fragile mocking
let(:collectMultiple_response) { {
Expand Down