Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cloud volume to provide a list of volumes for attach #14058

Merged
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
3 changes: 3 additions & 0 deletions app/models/cloud_volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,7 @@ def raw_delete_volume
raise NotImplementedError, _("raw_delete_volume must be implemented in a subclass")
end

def available_vms
raise NotImplementedError, _("available_vms must be implemented in a subclass")
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ def create_volume_snapshot_queue(userid, options)
.create_snapshot_queue(userid, self, options)
end

def available_vms
cloud_tenant.vms
end

def provider_object(connection)
connection.volumes.get(ems_ref)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,15 @@
end
end
end

describe "instance linsting for attaching volumes" do
let(:first_instance) { FactoryGirl.create(:vm_openstack, :ext_management_system => ems, :ems_ref => "instance_0", :cloud_tenant => tenant) }
let(:second_instance) { FactoryGirl.create(:vm_openstack, :ext_management_system => ems, :ems_ref => "instance_1", :cloud_tenant => tenant) }
let(:other_tenant) { FactoryGirl.create(:cloud_tenant_openstack, :ext_management_system => ems) }
let(:other_instance) { FactoryGirl.create(:vm_openstack, :ext_management_system => ems, :ems_ref => "instance_2", :cloud_tenant => other_tenant) }

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
end
end