Sha256: ae6a574406c6b5fed887b2d879360f0a1e5c76ecef01bc643747e90771c712ac

Contents?: true

Size: 1.67 KB

Versions: 6

Compression:

Stored size: 1.67 KB

Contents

class Setting::Discovered < ::Setting
  BLANK_ATTRS << "discovery_location"
  BLANK_ATTRS << "discovery_organization"
  BLANK_ATTRS << "discovery_fact_column"

  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

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman_discovery-2.0.2 app/models/setting/discovered.rb
foreman_discovery-2.0.1 app/models/setting/discovered.rb
foreman_discovery-3.0.0 app/models/setting/discovered.rb
foreman_discovery-2.0.0 app/models/setting/discovered.rb
foreman_discovery-2.0.0.rc2 app/models/setting/discovered.rb
foreman_discovery-2.0.0.rc1 app/models/setting/discovered.rb