Skip to content

Commit

Permalink
Save Storage Drivers Model
Browse files Browse the repository at this point in the history
  • Loading branch information
EsdrasVP committed Aug 10, 2018
1 parent 6772448 commit 9d8e755
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/models/ems_refresh/save_inventory_physical_infra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def save_physical_storages_inventory(ems, hashes, target = nil)
h[:physical_chassis_id] = h.delete(:physical_chassis).try(:[], :id)
end

child_keys = %i(computer_system asset_detail)
child_keys = %i(computer_system asset_detail physical_disk)
save_inventory_multi(ems.physical_storages, hashes, deletes, [:ems_ref], child_keys)
store_ids_for_new_records(ems.physical_storages, hashes, :ems_ref)
end
Expand All @@ -114,6 +114,14 @@ def save_asset_detail_inventory(parent, hash)
save_inventory_single(:asset_detail, parent, hash)
end

#
# Saves the drive information of a storage
#
def save_physical_disk_inventory(parent, hash)
return if hash.nil?
save_inventory_single(:physical_disk, parent, hash)
end

def save_physical_network_ports_inventory(guest_device, hashes, target = nil)
return if hashes.nil?

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

acts_as_miq_taggable
end
2 changes: 2 additions & 0 deletions app/models/physical_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class PhysicalStorage < ApplicationRecord
has_one :asset_detail, :as => :resource, :dependent => :destroy, :inverse_of => false
has_many :guest_devices, :through => :hardware

has_many :physical_disks, :dependent => :destroy, :inverse_of => :physical_storages

def my_zone
ems = ext_management_system
ems ? ems.my_zone : MiqServer.my_zone
Expand Down

0 comments on commit 9d8e755

Please sign in to comment.