Class: DiscoveryRule

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Includes:
Authorizable, Parameterizable::ByIdName, Taxonomix
Defined in:
app/models/discovery_rule.rb

Instance Method Summary collapse

Instance Method Details

#default_int_attributesObject



35
36
37
38
# File 'app/models/discovery_rule.rb', line 35

def default_int_attributes
 self.max_count ||= 0
 self.priority  ||= 0
end

#enforce_taxonomyObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/discovery_rule.rb', line 40

def enforce_taxonomy
  return if hostgroup.nil?
  if SETTINGS[:organizations_enabled]
    unless (ms = hostgroup.organizations - organizations).empty?
      names = ms.collect(&:name).to_sentence
      errors.add(:organizations, n_("Host group organization %s must also be associated to the discovery rule", "Host group organizations %s must also be associated to the discovery rule", ms.size) % names)
    end
  end
  if SETTINGS[:locations_enabled]
    unless (ms = hostgroup.locations - locations).empty?
      names = ms.collect(&:name).to_sentence
      errors.add(:locations, n_("Host group location %s must also be associated to the discovery rule", "Host group locations %s must also be associated to the discovery rule", ms.size) % names)
    end
  end
end