Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding PhysicalStorage into PhysicalChassis #17616

Merged
merged 1 commit into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/ems_refresh/save_inventory_physical_infra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions app/models/physical_chassis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/physical_rack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just adding an association that already existing on the physical_storage model right? Nothing was changed in schema for this to work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it doesn't change nothing in schema. This was done because PhysicalRack requires an association with PhysicalStorage in order to get them when needed. If this is not added, then we can get a PhysicalRack from a PhysicalStorage, but the inverse does not work.


def my_zone
ems = ext_management_system
Expand Down
2 changes: 1 addition & 1 deletion app/models/physical_storage.rb
Original file line number Diff line number Diff line change
@@ -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, :inverse_of => :physical_storages

has_one :computer_system, :as => :managed_entity, :dependent => :destroy, :inverse_of => false
has_one :hardware, :through => :computer_system
Expand Down