Skip to content

Commit

Permalink
Merge pull request #409 from mansam/exclude-attached-instances-from-v…
Browse files Browse the repository at this point in the history
…olume-attachment-form

Exclude already attached VMs from the volume attachment form

(cherry picked from commit 66f9fd1)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1672695
  • Loading branch information
aufi authored and simaishi committed Feb 12, 2019
1 parent 804ab34 commit 26ab2ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -137,7 +137,7 @@ def create_volume_snapshot_queue(userid, options)
end

def available_vms
cloud_tenant.vms
cloud_tenant.vms.where.not(:id => vms.select(&:id))
end

def provider_object(connection)
Expand Down
Expand Up @@ -144,5 +144,11 @@
it "supports attachment to only those instances that are in the same tenant" do
expect(cloud_volume.available_vms).to contain_exactly(first_instance, second_instance)
end

it "should exclude instances that are already attached to the volume" do
attached_instance = FactoryGirl.create(:vm_openstack, :ext_management_system => ems, :ems_ref => "attached_instance", :cloud_tenant => tenant)
allow(cloud_volume).to receive(:vms).and_return([attached_instance])
expect(cloud_volume.available_vms).to contain_exactly(first_instance, second_instance)
end
end
end

0 comments on commit 26ab2ac

Please sign in to comment.