From d5fe5f05e0fdfd611f89d06aade5f6013c856c42 Mon Sep 17 00:00:00 2001 From: Greg Blomquist Date: Thu, 27 Jul 2017 12:38:45 -0400 Subject: [PATCH] Merge pull request #15600 from AparnaKarve/bz1471162 Add a virtual column for `supports_block_storage?` and `supports_cloud_object_store_container_create?` (cherry picked from commit d7611ab2ed3163ba7a89119d7ea17023aae784ec) https://bugzilla.redhat.com/show_bug.cgi?id=1478571 https://bugzilla.redhat.com/show_bug.cgi?id=1479802 --- app/models/ext_management_system.rb | 10 ++++++++++ spec/models/ext_management_system_spec.rb | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index 9d80595e81ac..fec064a1dbd9 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -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 @@ -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 diff --git a/spec/models/ext_management_system_spec.rb b/spec/models/ext_management_system_spec.rb index b1bcee424d97..9d3fc7ef679c 100644 --- a/spec/models/ext_management_system_spec.rb +++ b/spec/models/ext_management_system_spec.rb @@ -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