Skip to content

Commit

Permalink
Merge pull request #16605 from Ladas/allowing_operating_system_for_cl…
Browse files Browse the repository at this point in the history
…oud_manager_graph_refresh

Allowing OperatingSystem for CloudManager graph refresh
(cherry picked from commit 35f1636)

https://bugzilla.redhat.com/show_bug.cgi?id=1524572
  • Loading branch information
agrare authored and simaishi committed Dec 11, 2017
1 parent 5716c13 commit 7a01394
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def self.supported_types_and_descriptions_hash
:class_name => "VmOrTemplate", :inverse_of => :ext_management_system
has_many :miq_templates, :foreign_key => :ems_id, :inverse_of => :ext_management_system
has_many :vms, :foreign_key => :ems_id, :inverse_of => :ext_management_system
has_many :operating_systems, :through => :vms_and_templates
has_many :hardwares, :through => :vms_and_templates
has_many :networks, :through => :hardwares
has_many :disks, :through => :hardwares
Expand Down
1 change: 0 additions & 1 deletion app/models/manageiq/providers/infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class InfraManager < BaseManager
has_many :host_switches, :through => :hosts
has_many :host_networks, :through => :hosts, :source => :networks
has_many :snapshots, :through => :vms_and_templates
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
Expand Down
18 changes: 18 additions & 0 deletions app/models/manager_refresh/inventory_collection_default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ def hardwares(extra_attributes = {})
attributes.merge!(extra_attributes)
end

def operating_systems(extra_attributes = {})
attributes = {
:model_class => ::OperatingSystem,
:manager_ref => [:vm_or_template],
:association => :operating_systems,
:parent_inventory_collections => [:vms, :miq_templates],
}

attributes[:targeted_arel] = lambda do |inventory_collection|
manager_uuids = inventory_collection.parent_inventory_collections.flat_map { |c| c.manager_uuids.to_a }
inventory_collection.parent.operating_systems.joins(:vm_or_template).where(
'vms' => {:ems_ref => manager_uuids}
)
end

attributes.merge!(extra_attributes)
end

def disks(extra_attributes = {})
attributes = {
:model_class => ::Disk,
Expand Down

0 comments on commit 7a01394

Please sign in to comment.