Module: ForemanMonitoring::HostExtensions
- Defined in:
- app/models/concerns/foreman_monitoring/host_extensions.rb
Class Method Summary collapse
Instance Method Summary collapse
- #downtime_host(options) ⇒ Object
- #downtime_host_build ⇒ Object
- #hostgroup_inherited_attributes ⇒ Object
- #monitored? ⇒ Boolean
- #monitoring_attributes ⇒ Object
- #monitoring_status(options = {}) ⇒ Object
- #monitoring_status_label(options = {}) ⇒ Object
- #refresh_monitoring_status ⇒ Object
- #smart_proxy_ids ⇒ Object
Class Method Details
.prepended(base) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'app/models/concerns/foreman_monitoring/host_extensions.rb', line 3 def self.prepended(base) base.class_eval do include Orchestration::Monitoring after_build :downtime_host_build has_many :monitoring_results, :dependent => :destroy, :foreign_key => 'host_id', :inverse_of => :host end end |
Instance Method Details
#downtime_host(options) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/models/concerns/foreman_monitoring/host_extensions.rb', line 29 def downtime_host() return unless monitored? begin monitoring.set_downtime_host(self, ) rescue ProxyAPI::ProxyException => e errors.add(:base, _("Error setting downtime: '%s'") % e.) end errors.empty? end |
#downtime_host_build ⇒ Object
25 26 27 |
# File 'app/models/concerns/foreman_monitoring/host_extensions.rb', line 25 def downtime_host_build downtime_host(:comment => _('Host rebuilt in Foreman')) end |
#hostgroup_inherited_attributes ⇒ Object
43 44 45 |
# File 'app/models/concerns/foreman_monitoring/host_extensions.rb', line 43 def hostgroup_inherited_attributes super + ['monitoring_proxy_id'] end |
#monitored? ⇒ Boolean
39 40 41 |
# File 'app/models/concerns/foreman_monitoring/host_extensions.rb', line 39 def monitored? monitoring_proxy.present? end |
#monitoring_attributes ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/concerns/foreman_monitoring/host_extensions.rb', line 55 def monitoring_attributes { :ip => ip, :ip6 => ip6, :architecture => architecture.try(:name), :os => .try(:to_label), :osfamily => .try(:family), :virtual => provider != 'BareMetal', :provider => provider, :compute_resource => compute_resource.try(:to_label), :hostgroup => hostgroup.try(:to_label), :organization => organization.try(:name), :location => organization.try(:name), :comment => comment, :environment => environment.try(:to_s), :owner_name => owner.try(:name) } end |
#monitoring_status(options = {}) ⇒ Object
13 14 15 |
# File 'app/models/concerns/foreman_monitoring/host_extensions.rb', line 13 def monitoring_status( = {}) @monitoring_status ||= get_status(HostStatus::MonitoringStatus).to_status() end |
#monitoring_status_label(options = {}) ⇒ Object
17 18 19 |
# File 'app/models/concerns/foreman_monitoring/host_extensions.rb', line 17 def monitoring_status_label( = {}) @monitoring_status_label ||= get_status(HostStatus::MonitoringStatus).to_label() end |
#refresh_monitoring_status ⇒ Object
21 22 23 |
# File 'app/models/concerns/foreman_monitoring/host_extensions.rb', line 21 def refresh_monitoring_status get_status(HostStatus::MonitoringStatus).refresh end |
#smart_proxy_ids ⇒ Object
47 48 49 50 51 52 53 |
# File 'app/models/concerns/foreman_monitoring/host_extensions.rb', line 47 def smart_proxy_ids ids = super [monitoring_proxy, hostgroup.try(:monitoring_proxy)].compact.each do |proxy| ids << proxy.id end ids end |