Statistics
| Branch: | Tag: | Revision:

root / config / initializers / foreman.rb @ develop

History | View | Annotate | Download (1004 Bytes)

1
require 'foreman'
2
require 'puppet'
3
require 'puppet/rails'
4
# import settings file
5
SETTINGS= YAML.load_file("#{Rails.root}/config/settings.yaml")
6
7
SETTINGS[:version] = "0.5"
8
9
SETTINGS[:unattended] = SETTINGS[:unattended].nil? || SETTINGS[:unattended]
10
Puppet[:config] = SETTINGS[:puppetconfdir] || "/etc/puppet/puppet.conf"
11
Puppet.parse_config
12
$puppet = Puppet.settings.instance_variable_get(:@values) if Rails.env == "test"
13
SETTINGS[:login] ||= SETTINGS[:ldap]
14
15
begin
16
  if SETTINGS[:unattended]
17
    require 'virt'
18
    SETTINGS[:libvirt] = true
19
  else
20
    SETTINGS[:libvirt] = false
21
  end
22
rescue LoadError
23
  Rails.logger.debug "Libvirt binding are missing - hypervisor management is disabled"
24
  SETTINGS[:libvirt] = false
25
end
26
27
# We load the default settings if they are not already present
28
Foreman::DefaultSettings::Loader.load
29
30
# We load the default settings for the roles if they are not already present
31
Foreman::DefaultData::Loader.load(false)
32
33
WillPaginate.per_page = Setting.entries_per_page rescue 20