Skip to content

Commit

Permalink
Fixed call that build list of Storages to build Host file drop down
Browse files Browse the repository at this point in the history
Issue was introduced in #3956, in commit 6df12d1 code that builds Host file drop down was changed `vm.try(:available_iso_names)` was removed and new method `get_iso_options` was added to build the list. Changed to get all storages that the vm's host is attached to instead of all of the vm's storages

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1689369
  • Loading branch information
h-kataria committed Aug 6, 2019
1 parent c371d84 commit 6616c36
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/mixins/actions/vm_actions/reconfigure.rb
Expand Up @@ -233,8 +233,8 @@ def get_vlan_options(host_id)
def get_iso_options(vm)
iso_options = []

datastore_ids = vm.storages.pluck(:id)
# determine available iso files for the datastaores
datastore_ids = vm.host.storages.pluck(:id)
# determine available iso files for the datastores
Rbac.filtered(StorageFile.where("storage_id IN (?) and ext_name = 'iso'", datastore_ids)).each do |sf|
iso_options << [sf.name, sf.name + ',' + sf.storage_id.to_s]
end
Expand Down
28 changes: 28 additions & 0 deletions spec/controllers/mixins/actions/vm_actions/reconfigure_spec.rb
@@ -0,0 +1,28 @@
describe Mixins::Actions::VmActions::Reconfigure do
describe '#get_iso_options' do
before do
@vm = FactoryBot.create(:vm_vmware)
@host = FactoryBot.create(:host, :name =>'hostname1')
@datastore = FactoryBot.create(:storage, :name => 'storage_name')
@vm.host = @host
FactoryBot.create(:storage_file, :storage_id => @datastore.id, :ext_name => 'iso', :base_name => "good-stuff.iso")
FactoryBot.create(:storage_file, :storage_id => 1, :ext_name => 'iso', :base_name => "some_other_storage.iso")
end

context 'populate list of Host files' do
let(:controller) { VmInfraController.new }

it "gets list of VM's host storages that have iso files" do
@host.storages << @datastore
storage_list = controller.send(:get_iso_options, @vm)
expect(storage_list.count).to be(1)
end

it "gets empty list for VM's storage" do
@vm.storages << @datastore
storage_list = controller.send(:get_iso_options, @vm)
expect(storage_list.count).to be(0)
end
end
end
end

0 comments on commit 6616c36

Please sign in to comment.