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

Add a Subnet model for SCVMM #16153

Merged
merged 2 commits into from
Oct 9, 2017
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
9 changes: 8 additions & 1 deletion app/models/ems_refresh/save_inventory_infra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,14 @@ def remove_obsolete_switches
end

def save_lans_inventory(switch, hashes)
save_inventory_multi(switch.lans, hashes, :use_association, [:uid_ems])
extra_keys = [:parent]
child_keys = [:subnets]

save_inventory_multi(switch.lans, hashes, :use_association, [:uid_ems], child_keys, extra_keys)
end

def save_subnets_inventory(lan, hashes)
save_inventory_multi(lan.subnets, hashes, :use_association, [:ems_ref])
end

def save_storage_files_inventory(storage, hashes)
Expand Down
1 change: 1 addition & 0 deletions app/models/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Host < ApplicationRecord
has_many :host_switches, :dependent => :destroy
has_many :switches, :through => :host_switches
has_many :lans, :through => :switches
has_many :subnets, :through => :lans
has_many :networks, :through => :hardware
has_many :patches, :dependent => :destroy
has_many :system_services, :dependent => :destroy
Expand Down
1 change: 1 addition & 0 deletions app/models/lan.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class Lan < ApplicationRecord
belongs_to :switch

has_many :subnets, :dependent => :destroy
has_many :guest_devices
has_many :vms_and_templates, -> { distinct }, :through => :guest_devices
has_many :vms, -> { distinct }, :through => :guest_devices
Expand Down
1 change: 1 addition & 0 deletions app/models/manageiq/providers/infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class InfraManager < BaseManager
has_many :operating_systems, :through => :vms_and_templates
has_many :switches, -> { distinct }, :through => :hosts
has_many :lans, -> { distinct }, :through => :hosts
has_many :subnets, -> { distinct }, :through => :lans
has_many :networks, :through => :hardwares
has_many :guest_devices, :through => :hardwares

Expand Down
7 changes: 7 additions & 0 deletions app/models/subnet.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Subnet < ApplicationRecord
include NewWithTypeStiMixin

acts_as_miq_taggable

belongs_to :lan
end
1 change: 1 addition & 0 deletions app/models/switch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Switch < ApplicationRecord

has_many :guest_devices
has_many :lans, :dependent => :destroy
has_many :subnets, :through => :lans

acts_as_miq_taggable
end