Skip to content

Commit

Permalink
replace virtual_aggregate calls with virtual_sum
Browse files Browse the repository at this point in the history
virtual_attributes is about to have a new major version cut
that includes a deprecation of virtual_aggregate

we'll presumably want this sometime in the future when we update the version
  • Loading branch information
d-m-u committed Nov 5, 2020
1 parent 41f40f8 commit cfc1833
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ def validate_zone_not_maintenance_when_ems_enabled?
virtual_column :supports_create_security_group, :type => :boolean
virtual_column :supports_storage_services, :type => :boolean

virtual_aggregate :total_vcpus, :hosts, :sum, :total_vcpus
virtual_aggregate :total_memory, :hosts, :sum, :ram_size
virtual_aggregate :total_cloud_vcpus, :vms, :sum, :cpu_total_cores
virtual_aggregate :total_cloud_memory, :vms, :sum, :ram_size
virtual_sum :total_vcpus, :hosts, :total_vcpus
virtual_sum :total_memory, :hosts, :ram_size
virtual_sum :total_cloud_vcpus, :vms, :cpu_total_cores
virtual_sum :total_cloud_memory, :vms, :ram_size

alias_method :clusters, :ems_clusters # Used by web-services to return clusters as the property name
alias_attribute :to_s, :name
Expand Down
4 changes: 2 additions & 2 deletions app/models/hardware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class Hardware < ApplicationRecord
virtual_column :hostnames, :type => :string_set, :uses => :networks
virtual_column :mac_addresses, :type => :string_set, :uses => :nics

virtual_aggregate :used_disk_storage, :disks, :sum, :used_disk_storage
virtual_aggregate :allocated_disk_storage, :disks, :sum, :size
virtual_sum :used_disk_storage, :disks, :used_disk_storage
virtual_sum :allocated_disk_storage, :disks, :size
virtual_total :num_disks, :disks
virtual_total :num_hard_disks, :hard_disks

Expand Down
14 changes: 7 additions & 7 deletions app/models/mixins/aggregation_mixin.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module AggregationMixin
extend ActiveSupport::Concern
included do
virtual_aggregate :aggregate_cpu_speed, :host_hardwares, :sum, :aggregate_cpu_speed
virtual_aggregate :aggregate_cpu_total_cores, :host_hardwares, :sum, :cpu_total_cores
virtual_aggregate :aggregate_disk_capacity, :host_hardwares, :sum, :disk_capacity
virtual_aggregate :aggregate_memory, :host_hardwares, :sum, :memory_mb
virtual_aggregate :aggregate_physical_cpus, :host_hardwares, :sum, :cpu_sockets
virtual_aggregate :aggregate_vm_cpus, :vm_hardwares, :sum, :cpu_sockets
virtual_aggregate :aggregate_vm_memory, :vm_hardwares, :sum, :memory_mb
virtual_sum :aggregate_cpu_speed, :host_hardwares, :aggregate_cpu_speed
virtual_sum :aggregate_cpu_total_cores, :host_hardwares, :cpu_total_cores
virtual_sum :aggregate_disk_capacity, :host_hardwares, :disk_capacity
virtual_sum :aggregate_memory, :host_hardwares, :memory_mb
virtual_sum :aggregate_physical_cpus, :host_hardwares, :cpu_sockets
virtual_sum :aggregate_vm_cpus, :vm_hardwares, :cpu_sockets
virtual_sum :aggregate_vm_memory, :vm_hardwares, :memory_mb
end
end
4 changes: 2 additions & 2 deletions spec/models/zone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
end

it "hosts in virtual reflections" do
expect(described_class.includes(:aggregate_cpu_speed)).not_to be_nil
expect(described_class.includes(:total_cpu_speed)).not_to be_nil
end

it "vms_and_templates in virtual reflections" do
expect(described_class.includes(:aggregate_vm_cpus)).not_to be_nil
expect(described_class.includes(:total_vm_cpus)).not_to be_nil
end
end

Expand Down

0 comments on commit cfc1833

Please sign in to comment.