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 switches support for physical infra #16948

Merged
merged 1 commit into from
Apr 6, 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
11 changes: 10 additions & 1 deletion app/models/ems_refresh/save_inventory_physical_infra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Calling order for EmsPhysicalInfra:
# - ems
# - physical_racks
# - physical_switches
# - physical_servers
#

Expand All @@ -22,7 +23,7 @@ def save_ems_physical_infra_inventory(ems, hashes, target = nil)
_log.debug("#{log_header} hashes:\n#{YAML.dump(hashes)}")
end

child_keys = %i(physical_racks physical_servers customization_scripts)
child_keys = %i(physical_racks physical_switches physical_servers customization_scripts)

# Save and link other subsections
save_child_inventory(ems, hashes, child_keys, target)
Expand All @@ -44,6 +45,14 @@ def save_physical_racks_inventory(ems, hashes, target = nil)
store_ids_for_new_records(ems.physical_racks, hashes, :ems_ref)
end

def save_physical_switches_inventory(ems, hashes, target = nil)
target = ems if target.nil?

deletes = target == ems ? :use_association : []

save_inventory_multi(ems.physical_switches, hashes, deletes, [:uid_ems], %i(asset_detail hardware))
end

def save_physical_servers_inventory(ems, hashes, target = nil)
target = ems if target.nil?

Expand Down
1 change: 1 addition & 0 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def self.api_allowed_attributes
has_many :customization_specs, :foreign_key => "ems_id", :dependent => :destroy, :inverse_of => :ext_management_system
has_many :storage_profiles, :foreign_key => "ems_id", :dependent => :destroy, :inverse_of => :ext_management_system
has_many :physical_racks, :foreign_key => "ems_id", :dependent => :destroy, :inverse_of => :ext_management_system
has_many :physical_switches, :foreign_key => "ems_id", :dependent => :destroy, :inverse_of => :ext_management_system
has_many :physical_servers, :foreign_key => "ems_id", :dependent => :destroy, :inverse_of => :ext_management_system
has_many :customization_scripts, :foreign_key => "manager_id", :dependent => :destroy, :inverse_of => :ext_management_system

Expand Down
1 change: 1 addition & 0 deletions app/models/hardware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Hardware < ApplicationRecord
belongs_to :miq_template, :foreign_key => :vm_or_template_id
belongs_to :host
belongs_to :computer_system
belongs_to :physical_switch, :foreign_key => :switch_id, :inverse_of => :hardware

has_many :networks, :dependent => :destroy
has_many :firmwares, :as => :resource, :dependent => :destroy
Expand Down
1 change: 1 addition & 0 deletions app/models/manageiq/providers/physical_infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class PhysicalInfraManager < BaseManager
include SupportsFeatureMixin

virtual_total :total_physical_racks, :physical_racks
virtual_total :total_physical_switches, :physical_switches
virtual_total :total_physical_servers, :physical_servers
virtual_column :total_hosts, :type => :integer
virtual_column :total_vms, :type => :integer
Expand Down
6 changes: 6 additions & 0 deletions app/models/physical_switch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class PhysicalSwitch < Switch
has_one :asset_detail, :as => :resource, :dependent => :destroy, :inverse_of => :resource
has_one :hardware, :dependent => :destroy, :foreign_key => :switch_id, :inverse_of => :physical_switch

belongs_to :ext_management_system, :foreign_key => :ems_id, :inverse_of => :physical_switches
end
1 change: 1 addition & 0 deletions app/models/switch.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Switch < ApplicationRecord
include NewWithTypeStiMixin
include CustomActionsMixin

has_many :host_switches, :dependent => :destroy
Expand Down