Class: Katello::RhsmFactParser
- Inherits:
-
FactParser
- Object
- FactParser
- Katello::RhsmFactParser
- Defined in:
- app/models/katello/rhsm_fact_parser.rb
Instance Method Summary collapse
- #architecture ⇒ Object
-
#domain ⇒ Object
required to be defined, even if they return nil.
- #environment ⇒ Object
- #get_facts_for_interface(interface) ⇒ Object
-
#get_interfaces ⇒ Object
rubocop:disable Style/AccessorMethodName:.
- #invalid_centos_os?(name, minor_version) ⇒ Boolean
- #ipmi_interface ⇒ Object
- #model ⇒ Object
- #operatingsystem ⇒ Object
- #support_interfaces_parsing? ⇒ Boolean
Instance Method Details
#architecture ⇒ Object
3 4 5 6 7 |
# File 'app/models/katello/rhsm_fact_parser.rb', line 3 def architecture name = facts['lscpu.architecture'] name = "x86_64" if name == "amd64" Architecture.where(:name => name).first_or_create unless name.blank? end |
#domain ⇒ Object
required to be defined, even if they return nil
57 58 |
# File 'app/models/katello/rhsm_fact_parser.rb', line 57 def domain end |
#environment ⇒ Object
60 61 |
# File 'app/models/katello/rhsm_fact_parser.rb', line 60 def environment end |
#get_facts_for_interface(interface) ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/models/katello/rhsm_fact_parser.rb', line 22 def get_facts_for_interface(interface) { 'link' => true, 'macaddress' => facts["net.interface.#{interface}.mac_address"], 'ipaddress' => facts["net.interface.#{interface}.ipv4_address"] } end |
#get_interfaces ⇒ Object
rubocop:disable Style/AccessorMethodName:
31 32 33 34 35 36 37 |
# File 'app/models/katello/rhsm_fact_parser.rb', line 31 def get_interfaces mac_keys = facts.keys.select { |f| f =~ /net\.interface\..*\.mac_address/ } names = mac_keys.map do |key| key.sub('net.interface.', '').sub('.mac_address', '') if facts[key] != 'none' end names.compact end |
#invalid_centos_os?(name, minor_version) ⇒ Boolean
52 53 54 |
# File 'app/models/katello/rhsm_fact_parser.rb', line 52 def invalid_centos_os?(name, minor_version) name == 'CentOS' && minor_version.blank? end |
#ipmi_interface ⇒ Object
63 64 |
# File 'app/models/katello/rhsm_fact_parser.rb', line 63 def ipmi_interface end |
#model ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'app/models/katello/rhsm_fact_parser.rb', line 9 def model if facts['virt::is_guest'] == "true" name = facts['lscpu.hypervisor_vendor'] else name = facts['dmi.system.product_name'] end ::Model.where(:name => name.strip).first_or_create unless name.blank? end |
#operatingsystem ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/katello/rhsm_fact_parser.rb', line 39 def name = facts['distribution.name'] version = facts['distribution.version'] return nil if name.nil? || version.nil? os_name = ::Katello::Candlepin::Consumer.distribution_to_puppet_os(name) major, minor = version.split('.') if os_name && !invalid_centos_os?(os_name, minor) os_attributes = {:major => major, :minor => minor || '', :name => os_name} ::.find_by(os_attributes) || ::.create!(os_attributes) end end |
#support_interfaces_parsing? ⇒ Boolean
18 19 20 |
# File 'app/models/katello/rhsm_fact_parser.rb', line 18 def support_interfaces_parsing? true end |