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 host_guest_devices association and inv_collection #17505

Merged
merged 2 commits into from
Jul 20, 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/manageiq/providers/infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class InfraManager < BaseManager
has_many :host_storages, :through => :hosts
has_many :host_switches, :through => :hosts
has_many :host_networks, :through => :hosts, :source => :networks
has_many :host_guest_devices, :through => :host_hardwares, :source => :guest_devices
has_many :snapshots, :through => :vms_and_templates
has_many :switches, -> { distinct }, :through => :hosts
has_many :lans, -> { distinct }, :through => :hosts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ def guest_devices
)
end

def host_guest_devices
Copy link
Contributor

Choose a reason for hiding this comment

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

add_properties(
:model_class => ::GuestDevice,
:manager_ref => %i(hardware uid_ems),
:parent_inventory_collections => %i(hosts),
)
end

def host_hardwares
add_properties(
:model_class => ::Hardware,
Expand All @@ -32,6 +40,14 @@ def host_hardwares
)
end

def host_system_services
Copy link
Contributor

Choose a reason for hiding this comment

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

@agrare 👍 - I'll wait with my PR

add_properties(
:model_class => ::SystemService,
:manager_ref => %i(host name),
:parent_inventory_collections => %i(hosts)
)
end

def snapshots
add_properties(
:manager_ref => %i(uid),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ def host_networks(extra_attributes = {})
attributes.merge!(extra_attributes)
end

def host_guest_devices(extra_attributes = {})
attributes = {
:model_class => ::GuestDevice,
:manager_ref => %i(hardware uid_ems),
:association => :host_guest_devices,
:parent_inventory_collections => [:hosts],
:inventory_object_attributes => %i(
address
controller_type
device_name
device_type
lan
location
network
present
switch
uid_ems
),
}

attributes.merge!(extra_attributes)
end

def guest_devices(extra_attributes = {})
attributes = {
:model_class => ::GuestDevice,
Expand Down Expand Up @@ -102,6 +125,16 @@ def snapshots(extra_attributes = {})
attributes.merge!(extra_attributes)
end

def host_system_services(extra_attributes = {})
attributes = {
:model_class => ::SystemService,
:manager_ref => %i(host name),
:parent_inventory_collections => %i(hosts),
}

attributes.merge!(extra_attributes)
end

def operating_systems(extra_attributes = {})
attributes = {
:model_class => ::OperatingSystem,
Expand Down