From 57c4babef09c4ed6b9ea0eb0c804586d6ed023f6 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 20 Jun 2018 09:03:42 -0300 Subject: [PATCH] Adding PhysicalStorage into PhysicalChassis --- app/models/ems_refresh/save_inventory_physical_infra.rb | 1 + app/models/physical_chassis.rb | 1 + app/models/physical_rack.rb | 2 +- app/models/physical_storage.rb | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/ems_refresh/save_inventory_physical_infra.rb b/app/models/ems_refresh/save_inventory_physical_infra.rb index 4476c4e30266..9ca52b5aec76 100644 --- a/app/models/ems_refresh/save_inventory_physical_infra.rb +++ b/app/models/ems_refresh/save_inventory_physical_infra.rb @@ -98,6 +98,7 @@ def save_physical_storages_inventory(ems, hashes, target = nil) hashes.each do |h| h[:physical_rack_id] = h.delete(:physical_rack).try(:[], :id) + h[:physical_chassis_id] = h.delete(:physical_chassis).try(:[], :id) end child_keys = %i(computer_system asset_detail) diff --git a/app/models/physical_chassis.rb b/app/models/physical_chassis.rb index c71b150c6179..fb20ad04ee6d 100644 --- a/app/models/physical_chassis.rb +++ b/app/models/physical_chassis.rb @@ -6,6 +6,7 @@ class PhysicalChassis < ApplicationRecord belongs_to :physical_rack, :foreign_key => :physical_rack_id, :inverse_of => :physical_chassis has_many :physical_servers, :dependent => :destroy, :inverse_of => :physical_chassis + has_many :physical_storages, :dependent => :destroy, :inverse_of => :physical_chassis has_one :computer_system, :as => :managed_entity, :dependent => :destroy, :inverse_of => false has_one :hardware, :through => :computer_system diff --git a/app/models/physical_rack.rb b/app/models/physical_rack.rb index a37026d113be..fc45f45d757a 100644 --- a/app/models/physical_rack.rb +++ b/app/models/physical_rack.rb @@ -3,9 +3,9 @@ class PhysicalRack < ApplicationRecord belongs_to :ext_management_system, :foreign_key => :ems_id, :inverse_of => :physical_racks, :class_name => "ManageIQ::Providers::PhysicalInfraManager" - has_many :physical_chassis, :dependent => :nullify, :inverse_of => :physical_rack has_many :physical_servers, :dependent => :nullify, :inverse_of => :physical_rack + has_many :physical_storages, :dependent => :nullify, :inverse_of => :physical_rack def my_zone ems = ext_management_system diff --git a/app/models/physical_storage.rb b/app/models/physical_storage.rb index 95f8daadc68b..115ac1ab5a63 100644 --- a/app/models/physical_storage.rb +++ b/app/models/physical_storage.rb @@ -1,8 +1,8 @@ class PhysicalStorage < ApplicationRecord belongs_to :ext_management_system, :foreign_key => :ems_id, :inverse_of => :physical_storages, :class_name => "ManageIQ::Providers::PhysicalInfraManager" - belongs_to :physical_rack, :foreign_key => :physical_rack_id, :inverse_of => :physical_storages + belongs_to :physical_chassis, :foreign_key => :physical_chassis_id, :inverse_of => :physical_storages has_one :computer_system, :as => :managed_entity, :dependent => :destroy, :inverse_of => false has_one :hardware, :through => :computer_system