Class: Setting::Discovered

Inherits:
Setting
  • Object
show all
Defined in:
app/models/setting/discovered.rb

Class Method Summary collapse

Class Method Details

.load_defaultsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/models/setting/discovered.rb', line 6

def self.load_defaults
  # Check the table exists
  return unless super

  Setting.transaction do
    [
      self.set('discovery_fact', _("The default fact name to use for the MAC of the system"), "discovery_bootif"),
      self.set('discovery_auto', _("Automatically provision newly discovered hosts, according to the provisioning rules"), false),
    ].compact.each { |s| self.create s.update(:category => "Setting::Discovered")}
  end

  Setting.transaction do
    [
      self.set('discovery_prefix', _("The default prefix to use for the host name, must start with a letter"), "mac"),
    ].compact.each { |s| self.create s.update(:category => "Setting::Discovered")}
  end

  Setting.transaction do
    [
      self.set('discovery_fact_column', _("Show fact as an extra column in the discovered hosts list"), ""),
    ].compact.each { |s| self.create s.update(:category => "Setting::Discovered")}
  end

  if SETTINGS[:locations_enabled]
    Setting.transaction do
      [
        self.set('discovery_location', _("The default location to place discovered hosts in"), ""),
      ].compact.each { |s| self.create s.update(:category => "Setting::Discovered")}
    end
  end
  if SETTINGS[:organizations_enabled]
    Setting.transaction do
      [
        self.set('discovery_organization', _("The default organization to place discovered hosts in"), "" ),
      ].compact.each { |s| self.create s.update(:category => "Setting::Discovered")}
    end
  end

  true

end