Skip to content

Commit

Permalink
Merge pull request #15600 from AparnaKarve/bz1471162
Browse files Browse the repository at this point in the history
Add a virtual column for `supports_block_storage?` and `supports_cloud_object_store_container_create?`
(cherry picked from commit d7611ab)

https://bugzilla.redhat.com/show_bug.cgi?id=1478571
https://bugzilla.redhat.com/show_bug.cgi?id=1479802
  • Loading branch information
blomquisg authored and simaishi committed Aug 9, 2017
1 parent 1a0907b commit ccbbe81
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ def hostname_uniqueness_valid?
virtual_column :total_vms_never, :type => :integer
virtual_column :total_vms_suspended, :type => :integer
virtual_total :total_subnets, :cloud_subnets
virtual_column :supports_block_storage, :type => :boolean
virtual_column :supports_cloud_object_store_container_create, :type => :boolean

virtual_aggregate :total_vcpus, :hosts, :sum, :total_vcpus
virtual_aggregate :total_memory, :hosts, :sum, :ram_size
Expand Down Expand Up @@ -490,6 +492,14 @@ def total_vms_never; vm_count_by_state("never"); end

def total_vms_suspended; vm_count_by_state("suspended"); end

def supports_block_storage
supports_block_storage?
end

def supports_cloud_object_store_container_create
supports_cloud_object_store_container_create?
end

def get_reserve(field)
(hosts + ems_clusters).inject(0) { |v, obj| v + (obj.send(field) || 0) }
end
Expand Down
16 changes: 16 additions & 0 deletions spec/models/ext_management_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,4 +392,20 @@
expect(tenant.ext_management_systems).to include(ems)
end
end

context "virtual column :supports_block_storage" do
it "returns true if block storage is supported" do
ems = FactoryGirl.create(:ext_management_system)
allow(ems).to receive(:supports_block_storage).and_return(true)
expect(ems.supports_block_storage).to eq(true)
end
end

context "virtual column :supports_cloud_object_store_container_create" do
it "returns true if cloud_object_store_container_create is supported" do
ems = FactoryGirl.create(:ext_management_system)
allow(ems).to receive(:supports_cloud_object_store_container_create).and_return(true)
expect(ems.supports_cloud_object_store_container_create).to eq(true)
end
end
end

0 comments on commit ccbbe81

Please sign in to comment.