Class: ForemanChef::FactParser
- Inherits:
-
FactParser
- Object
- FactParser
- ForemanChef::FactParser
- Defined in:
- app/models/foreman_chef/fact_parser.rb
Constant Summary collapse
- VIRTUAL =
/\A([a-z0-9]+)[:.](\d+)\Z/- VIRTUAL_NAMES =
/#{VIRTUAL}|#{BRIDGES}|#{BONDS}/
Instance Method Summary collapse
- #architecture ⇒ Object
- #certname ⇒ Object
- #domain ⇒ Object
- #environment ⇒ Object
- #ipmi_interface ⇒ Object
- #model ⇒ Object
- #operatingsystem ⇒ Object
- #parse_interfaces? ⇒ Boolean
- #support_interfaces_parsing? ⇒ Boolean
Instance Method Details
#architecture ⇒ Object
40 41 42 43 44 |
# File 'app/models/foreman_chef/fact_parser.rb', line 40 def architecture name = facts['kernel::machine'] name = "x86_64" if name == "amd64" Architecture.where(:name => name).first_or_create unless name.blank? end |
#certname ⇒ Object
66 67 68 |
# File 'app/models/foreman_chef/fact_parser.rb', line 66 def certname facts['chef_node_name'] end |
#domain ⇒ Object
55 56 57 58 |
# File 'app/models/foreman_chef/fact_parser.rb', line 55 def domain name = facts['domain'] Domain.where(:name => name).first_or_create unless name.blank? end |
#environment ⇒ Object
35 36 37 38 |
# File 'app/models/foreman_chef/fact_parser.rb', line 35 def environment name = facts['environment'] || Setting[:default_puppet_environment] Environment.where(:name => name).first_or_create end |
#ipmi_interface ⇒ Object
60 61 62 63 64 |
# File 'app/models/foreman_chef/fact_parser.rb', line 60 def ipmi_interface if facts['ipmi::mac_address'].present? { 'ipaddress' => facts['ipmi::address'], 'macaddress' => facts['ipmi::mac_address'] }.with_indifferent_access end end |
#model ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/models/foreman_chef/fact_parser.rb', line 46 def model if facts['virtualization'].present? name = facts['virtualization']['system'] else name = facts['dmi::system::product_name'] end Model.where(:name => name.strip).first_or_create unless name.blank? end |
#operatingsystem ⇒ Object
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 |
# File 'app/models/foreman_chef/fact_parser.rb', line 6 def os_name = facts['lsb::id'] || facts['platform'] release = facts['lsb::release'] || facts['platform_version'] # if we have no release information we can't assign OS properly (e.g. missing redhat-lsb) if release.nil? major, minor = 1, nil else major, minor = release.split('.') end if facts['platform'] == 'windows' release_name = facts['kernel::name'] os_name = os_name.capitalize else description = facts['lsb::description'] release_name = facts['lsb::codename'] end begin klass = os_name.constantize rescue NameError => e logger.debug "unknown operating system #{os_name}, fallback to generic type" klass = end args = { :name => os_name, :major => major.to_s, :minor => minor.to_s } klass.where(args).first || klass.new(args.merge(:description => description, :release_name => release_name)).tap(&:save!) end |
#parse_interfaces? ⇒ Boolean
74 75 76 |
# File 'app/models/foreman_chef/fact_parser.rb', line 74 def parse_interfaces? support_interfaces_parsing? && !Setting['ignore_puppet_facts_for_provisioning'] end |
#support_interfaces_parsing? ⇒ Boolean
70 71 72 |
# File 'app/models/foreman_chef/fact_parser.rb', line 70 def support_interfaces_parsing? true end |