Permalink
Browse files

Fixes #14718 - on rhsm registration, ignore centos os without minor v…

…ersion (#5988)
  • Loading branch information...
jlsherrill committed Apr 21, 2016
1 parent 2ffb103 commit 27c15a1f7ad43ba528e9824337991965dee57d50
Showing with 22 additions and 2 deletions.
  1. +6 −2 app/models/katello/rhsm_fact_parser.rb
  2. +16 −0 test/models/rhsm_fact_parser_test.rb
@@ -42,13 +42,17 @@ def operatingsystem
return nil if name.nil? || version.nil?
os_name = ::Katello::Candlepin::Consumer.distribution_to_puppet_os(name)
if os_name
major, minor = version.split('.')
major, minor = version.split('.')
if os_name && !invalid_centos_os?(os_name, minor)
os_attributes = {:major => major, :minor => minor || '', :name => os_name}
::Operatingsystem.find_by(os_attributes) || ::Operatingsystem.create!(os_attributes)
end
end
def invalid_centos_os?(name, minor_version)
name == 'CentOS' && minor_version.blank?
end
#required to be defined, even if they return nil
def domain
end
@@ -36,5 +36,21 @@ def test_get_facts_for_interface_without_ip
}
assert_equal expected_eth1, @parser.get_facts_for_interface('eth1')
end
def test_valid_centos_os
@facts['distribution.name'] = 'CentOS'
@facts['distribution.version'] = '7.2'
@parser = RhsmFactParser.new(@facts)
assert @parser.operatingsystem.is_a?(::Operatingsystem)
end
def test_invalid_centos_os
@facts['distribution.name'] = 'CentOS'
@facts['distribution.version'] = '7'
@parser = RhsmFactParser.new(@facts)
refute @parser.operatingsystem
end
end
end

2 comments on commit 27c15a1

@pressplay21

This comment has been minimized.

Show comment
Hide comment
@pressplay21

pressplay21 Jun 1, 2016

I'm running Katello RC5. The client is running Centos 7.2 but the subscription-manager facts will always report "distribution.version: 7" and does not include the minor version. So in the Katello Content Hosts UI, the OS field is blank. If I revert the code, the OS field is populated with CentOS 7 but missing the minor version number. Maybe the issue is with subscription-manager facts?

pressplay21 replied Jun 1, 2016

I'm running Katello RC5. The client is running Centos 7.2 but the subscription-manager facts will always report "distribution.version: 7" and does not include the minor version. So in the Katello Content Hosts UI, the OS field is blank. If I revert the code, the OS field is populated with CentOS 7 but missing the minor version number. Maybe the issue is with subscription-manager facts?

@jlsherrill

This comment has been minimized.

Show comment
Hide comment
@jlsherrill

jlsherrill Jun 3, 2016

Member

@pressplay21 its actually an issue with centos:

https://bugs.centos.org/view.php?id=8359

Sadly this is the best we can do unless centos starts reporting their minor versions. Feel free to help push the issue!

Member

jlsherrill replied Jun 3, 2016

@pressplay21 its actually an issue with centos:

https://bugs.centos.org/view.php?id=8359

Sadly this is the best we can do unless centos starts reporting their minor versions. Feel free to help push the issue!

Please sign in to comment.