Skip to content

Commit

Permalink
Merge pull request ManageIQ#17728 from skovic/physical-server-alert
Browse files Browse the repository at this point in the history
Add support for new physical server alert
  • Loading branch information
agrare authored Jul 31, 2018
2 parents f2aadc3 + fefa6f1 commit f8e671b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def self.api_allowed_attributes
has_many :hardwares, :through => :vms_and_templates
has_many :networks, :through => :hardwares
has_many :disks, :through => :hardwares
has_many :physical_servers, :foreign_key => :ems_id, :inverse_of => :ext_management_system, :dependent => :destroy

has_many :storages, -> { distinct }, :through => :hosts
has_many :ems_events, -> { order("timestamp") }, :class_name => "EmsEvent", :foreign_key => "ems_id",
Expand Down
3 changes: 2 additions & 1 deletion app/models/miq_alert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class MiqAlert < ApplicationRecord
MiqServer
ContainerNode
ContainerProject
PhysicalServer
)

def self.base_tables
Expand All @@ -35,7 +36,7 @@ def self.base_tables

acts_as_miq_set_member

ASSIGNMENT_PARENT_ASSOCIATIONS = [:host, :ems_cluster, :ext_management_system, :my_enterprise]
ASSIGNMENT_PARENT_ASSOCIATIONS = %i(host ems_cluster ext_management_system my_enterprise physical_server).freeze

HOURLY_TIMER_EVENT = "_hourly_timer_"

Expand Down
2 changes: 1 addition & 1 deletion app/models/mixins/assignment_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def all_assignments(tag = nil)
included do #:nodoc:
acts_as_miq_taggable

const_set("ASSIGNMENT_PARENT_ASSOCIATIONS", [:parent_blue_folders, :parent_resource_pool, :host, :ems_cluster, :ext_management_system, :my_enterprise]) unless const_defined?("ASSIGNMENT_PARENT_ASSOCIATIONS")
const_set("ASSIGNMENT_PARENT_ASSOCIATIONS", %i(parent_blue_folders parent_resource_pool host ems_cluster ext_management_system my_enterprise physical_server)) unless const_defined?("ASSIGNMENT_PARENT_ASSOCIATIONS")

cache_with_timeout(:assignments_cached, 1.minute) { assignments }
end
Expand Down
1 change: 1 addition & 0 deletions app/models/physical_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PhysicalServer < ApplicationRecord
has_one :host, :inverse_of => :physical_server
has_one :asset_detail, :as => :resource, :dependent => :destroy
has_many :guest_devices, :through => :hardware
has_many :miq_alert_statuses, :as => :resource, :dependent => :destroy, :inverse_of => :physical_server

scope :with_hosts, -> { where("physical_servers.id in (select hosts.physical_server_id from hosts)") }

Expand Down
1 change: 1 addition & 0 deletions app/models/zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Zone < ApplicationRecord
has_many :vms, :through => :ext_management_systems
has_many :miq_templates, :through => :ext_management_systems
has_many :ems_clusters, :through => :ext_management_systems
has_many :physical_servers, :through => :ext_management_systems
has_many :container_nodes, :through => :container_managers
has_many :container_groups, :through => :container_managers
has_many :container_replicators, :through => :container_managers
Expand Down
15 changes: 15 additions & 0 deletions db/fixtures/miq_alerts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,18 @@
value: prod
:db: Vm
:guid: 89db0be8-c240-11de-a3be-000c290de4f9
- :description: Physical server has critical health state
:options:
:notifications:
:delay_next_evaluation: 3600
:email:
:from: ''
:to: []
:miq_expression: !ruby/object:MiqExpression
exp:
=:
field: PhysicalServer-health_state
value: "Critical"
:db: PhysicalServer
:guid: 15feb65a-1f36-44db-84ee-0e71d9f497c8
:responds_to_events: _hourly_timer_

0 comments on commit f8e671b

Please sign in to comment.