Skip to content

Commit

Permalink
Consolidate virtual_delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Oct 4, 2019
1 parent 6244124 commit 38d754f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,13 @@ 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}
virtual_column :memory_exceeds_current_host_headroom, :type => :string, :uses => [:mem_cpu, {:host => [:hardware, :ext_management_system]}]
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}}

Expand All @@ -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
Expand Down

0 comments on commit 38d754f

Please sign in to comment.