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?`
  • Loading branch information
blomquisg authored Jul 27, 2017
2 parents 78fb6b4 + 35a5f2c commit d7611ab
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 @@ -145,6 +145,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 @@ -548,6 +550,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 @@ -409,4 +409,20 @@
expect(ExtManagementSystem.count).to eq(1)
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 d7611ab

Please sign in to comment.