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
we don’t want to parse puppet environment, foreman_chef already has its own environment.
- #ipmi_interface ⇒ Object
- #model ⇒ Object
- #operatingsystem ⇒ Object
- #parse_interfaces? ⇒ Boolean
- #support_interfaces_parsing? ⇒ Boolean
Instance Method Details
#architecture ⇒ Object
50 51 52 53 54 |
# File 'app/models/foreman_chef/fact_parser.rb', line 50 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
76 77 78 |
# File 'app/models/foreman_chef/fact_parser.rb', line 76 def certname facts['chef_node_name'] end |
#domain ⇒ Object
65 66 67 68 |
# File 'app/models/foreman_chef/fact_parser.rb', line 65 def domain name = facts['domain'] Domain.where(:name => name).first_or_create unless name.blank? end |
#environment ⇒ Object
we don’t want to parse puppet environment, foreman_chef already has its own environment
46 47 48 |
# File 'app/models/foreman_chef/fact_parser.rb', line 46 def environment nil end |
#ipmi_interface ⇒ Object
70 71 72 73 74 |
# File 'app/models/foreman_chef/fact_parser.rb', line 70 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
56 57 58 59 60 61 62 63 |
# File 'app/models/foreman_chef/fact_parser.rb', line 56 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 34 35 36 37 38 39 40 41 42 43 |
# 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 # to keep OS names consistent with other cfgmgt agents we skip description importing # description = facts['lsb::description'] release_name = facts['lsb::codename'] end # So far only CentOS needs exception case os_name when 'CentOS' if major.to_i >= 7 # get the minor.build number, e.g. 7.2.1511 -> 2.1511 minor = release[2..-1] end 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(:release_name => release_name)).tap(&:save!) end |
#parse_interfaces? ⇒ Boolean
84 85 86 |
# File 'app/models/foreman_chef/fact_parser.rb', line 84 def parse_interfaces? support_interfaces_parsing? && !Setting['ignore_puppet_facts_for_provisioning'] end |
#support_interfaces_parsing? ⇒ Boolean
80 81 82 |
# File 'app/models/foreman_chef/fact_parser.rb', line 80 def support_interfaces_parsing? true end |