Skip to content

Commit

Permalink
Add PhysicalDisks into Canisters
Browse files Browse the repository at this point in the history
  • Loading branch information
EsdrasVP committed Oct 9, 2018
1 parent 08f42d9 commit a573ecf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/models/canister.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Canister < ApplicationRecord
has_one :computer_system, :as => :managed_entity, :dependent => :destroy, :inverse_of => false
has_one :hardware, :through => :computer_system

has_many :physical_disks, :dependent => :destroy, :inverse_of => :canister
has_many :guest_devices, :through => :hardware
has_many :physical_network_ports, :through => :guest_devices

Expand Down
8 changes: 4 additions & 4 deletions app/models/ems_refresh/save_inventory_physical_infra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,17 @@ def save_asset_detail_inventory(parent, hash)
end

#
# Saves the disks information of a storage
# Saves the disks information of a resource
#
def save_physical_disks_inventory(physical_storage, hashes)
def save_physical_disks_inventory(parent, hashes)
return if hashes.nil?

# Update the associated ids
hashes.each do |h|
h[:physical_storage_id] = h.delete(:physical_storage).try(:[], :id)
h[:canister_id] = h.delete(:canister).try(:[], :id)
end

save_inventory_multi(physical_storage.physical_disks, hashes, :use_association, [:physical_storage_id])
save_inventory_multi(parent.physical_disks, hashes, :use_association, [:ems_ref])
end

#
Expand Down
1 change: 1 addition & 0 deletions app/models/physical_disk.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class PhysicalDisk < ApplicationRecord
belongs_to :physical_storage, :foreign_key => :physical_storage_id, :inverse_of => :physical_disks
belongs_to :canister, :foreign_key => :canister_id, :inverse_of => :physical_disks

acts_as_miq_taggable
end

0 comments on commit a573ecf

Please sign in to comment.