From cfc1833902d7a596cb9b05b5187d78c08044d114 Mon Sep 17 00:00:00 2001 From: d-m-u Date: Sat, 19 Sep 2020 14:27:15 -0400 Subject: [PATCH] replace virtual_aggregate calls with virtual_sum 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 --- app/models/ext_management_system.rb | 8 ++++---- app/models/hardware.rb | 4 ++-- app/models/mixins/aggregation_mixin.rb | 14 +++++++------- spec/models/zone_spec.rb | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index 66e53232042..c7f26832aa8 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -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 diff --git a/app/models/hardware.rb b/app/models/hardware.rb index daf5ceb4df2..24255e47945 100644 --- a/app/models/hardware.rb +++ b/app/models/hardware.rb @@ -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 diff --git a/app/models/mixins/aggregation_mixin.rb b/app/models/mixins/aggregation_mixin.rb index 77e0d4ec5e7..1ba5601e816 100644 --- a/app/models/mixins/aggregation_mixin.rb +++ b/app/models/mixins/aggregation_mixin.rb @@ -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 diff --git a/spec/models/zone_spec.rb b/spec/models/zone_spec.rb index c273245f3c6..ba3091a85da 100644 --- a/spec/models/zone_spec.rb +++ b/spec/models/zone_spec.rb @@ -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