From 38d754f949b3ec44b38e304e4a09650f78b72af5 Mon Sep 17 00:00:00 2001 From: Libor Pichler Date: Fri, 4 Oct 2019 15:36:16 +0200 Subject: [PATCH] Consolidate virtual_delegate --- app/models/vm_or_template.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/models/vm_or_template.rb b/app/models/vm_or_template.rb index 5747f06ff1a..d2117cf7a17 100644 --- a/app/models/vm_or_template.rb +++ b/app/models/vm_or_template.rb @@ -150,9 +150,6 @@ class VmOrTemplate < ApplicationRecord virtual_column :used_storage, :type => :integer, :uses => [:used_disk_storage, :mem_cpu] virtual_column :used_storage_by_state, :type => :integer, :uses => :used_storage virtual_column :uncommitted_storage, :type => :integer, :uses => [:provisioned_storage, :used_storage_by_state] - virtual_delegate :ram_size_in_bytes, :to => :hardware, :allow_nil => true, :default => 0, :type => :integer - virtual_delegate :mem_cpu, :to => "hardware.memory_mb", :allow_nil => true, :default => 0, :type => :integer - virtual_delegate :ram_size, :to => "hardware.memory_mb", :allow_nil => true, :default => 0, :type => :integer virtual_column :ipaddresses, :type => :string_set, :uses => {:hardware => :ipaddresses} virtual_column :hostnames, :type => :string_set, :uses => {:hardware => :hostnames} virtual_column :mac_addresses, :type => :string_set, :uses => {:hardware => :mac_addresses} @@ -160,8 +157,6 @@ class VmOrTemplate < ApplicationRecord virtual_column :num_hard_disks, :type => :integer, :uses => {:hardware => :hard_disks} virtual_column :num_disks, :type => :integer, :uses => {:hardware => :disks} virtual_column :num_cpu, :type => :integer, :uses => :hardware - virtual_delegate :cpu_total_cores, :cpu_cores_per_socket, :to => :hardware, :allow_nil => true, :default => 0, :type => :integer - virtual_delegate :annotation, :to => :hardware, :prefix => "v", :allow_nil => true, :type => :string virtual_column :has_rdm_disk, :type => :boolean, :uses => {:hardware => :disks} virtual_column :disks_aligned, :type => :string, :uses => {:hardware => {:hard_disks => :partitions_aligned}} @@ -181,6 +176,12 @@ class VmOrTemplate < ApplicationRecord virtual_delegate :name, :to => :ems_cluster, :prefix => true, :allow_nil => true, :type => :string virtual_delegate :vmm_product, :to => :host, :prefix => :v_host, :allow_nil => true, :type => :string virtual_delegate :v_pct_free_disk_space, :v_pct_used_disk_space, :to => :hardware, :allow_nil => true, :type => :float + virtual_delegate :cpu_total_cores, :cpu_cores_per_socket, :to => :hardware, :allow_nil => true, :default => 0, :type => :integer + virtual_delegate :annotation, :to => :hardware, :prefix => "v", :allow_nil => true, :type => :string + virtual_delegate :ram_size_in_bytes, :to => :hardware, :allow_nil => true, :default => 0, :type => :integer + virtual_delegate :mem_cpu, :to => "hardware.memory_mb", :allow_nil => true, :default => 0, :type => :integer + virtual_delegate :ram_size, :to => "hardware.memory_mb", :allow_nil => true, :default => 0, :type => :integer + delegate :connect_lans, :disconnect_lans, :to => :hardware, :allow_nil => true after_save :save_genealogy_information