From a573ecfe972be24f513ceaa05f8790e4f3be68c4 Mon Sep 17 00:00:00 2001 From: Esdras Vidal Date: Wed, 3 Oct 2018 11:00:26 -0300 Subject: [PATCH] Add PhysicalDisks into Canisters --- app/models/canister.rb | 1 + app/models/ems_refresh/save_inventory_physical_infra.rb | 8 ++++---- app/models/physical_disk.rb | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/canister.rb b/app/models/canister.rb index a7f3efcaa0bf..edb91c5caa95 100644 --- a/app/models/canister.rb +++ b/app/models/canister.rb @@ -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 diff --git a/app/models/ems_refresh/save_inventory_physical_infra.rb b/app/models/ems_refresh/save_inventory_physical_infra.rb index 228cafeb9117..efcac84d58b0 100644 --- a/app/models/ems_refresh/save_inventory_physical_infra.rb +++ b/app/models/ems_refresh/save_inventory_physical_infra.rb @@ -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 # diff --git a/app/models/physical_disk.rb b/app/models/physical_disk.rb index 282261eb3fe8..66407aec67b0 100644 --- a/app/models/physical_disk.rb +++ b/app/models/physical_disk.rb @@ -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