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

Add a virtual column for supports_block_storage? and supports_cloud_object_store_container_create? #15600

Merged
merged 7 commits into from
Jul 27, 2017
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 @@ -542,6 +544,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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@durandom any idea why alias would not work here? With alias supports_block_storage supports_block_storage?:

ems.supports_block_storage? # => true
ems.supports_block_storage # => false

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe because you've added the alias before the block storage mixing got included?
the supports_feature_mixin defaults all features to unsupported. once it's supported it defines another method.

I tried to remove this in #11322 - but unfortunately that PR got stale

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 @@ -408,4 +408,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