From 2da45d4cabe1f2ccd7cda3472a6611a2b609ba2c Mon Sep 17 00:00:00 2001 From: Trey Dockendorf Date: Wed, 22 Apr 2020 10:19:59 -0400 Subject: [PATCH 1/2] Subscription manager on RHEL 7.8 now uses Entitlement Type for subscriptions --- lib/puppet/provider/rhsm_pool/subscription_manager.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/rhsm_pool/subscription_manager.rb b/lib/puppet/provider/rhsm_pool/subscription_manager.rb index 6337a87..dac52e2 100755 --- a/lib/puppet/provider/rhsm_pool/subscription_manager.rb +++ b/lib/puppet/provider/rhsm_pool/subscription_manager.rb @@ -90,9 +90,9 @@ def self.consumed_pools subscription.store(:active, value) next end - m = %r{^\s*System Type:\s*([^:]+)$}.match(line) + m = %r{^\s*(System|Entitlement) Type:\s*([^:]+)$}.match(line) unless m.nil? - value = m[1].strip.to_sym + value = m[2].strip.to_sym subscription.store(:system_type, value) # this is the last item output subscription.store(:provider, :subscription_manager) From 5b8a6af730c4878a6cc6edb1e75dc6f1bfde70e3 Mon Sep 17 00:00:00 2001 From: "Jeremiah D. Powell" Date: Tue, 28 Apr 2020 20:55:10 -0600 Subject: [PATCH 2/2] Test the updated parsing of Entitlements as System types --- .../rhsm_pool/subscription_manager_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/unit/provider/rhsm_pool/subscription_manager_spec.rb b/spec/unit/provider/rhsm_pool/subscription_manager_spec.rb index ab53639..cb8684f 100755 --- a/spec/unit/provider/rhsm_pool/subscription_manager_spec.rb +++ b/spec/unit/provider/rhsm_pool/subscription_manager_spec.rb @@ -36,6 +36,8 @@ System Type: Physical EOD +entitlement_data = raw_data.sub('System Type','Entitlement Type') + title1 = '1a2b3c4d5e6f1234567890abcdef12345' title2 = '1234abc' @@ -60,6 +62,7 @@ provider: :subscription_manager, } + provider_class = Puppet::Type.type(:rhsm_pool).provider(:subscrption_manager) describe provider_class, '#rhsm_pool.provider' do @@ -173,6 +176,18 @@ end end + describe 'system_type on RHEL 7.8 as entitlement_type' do + it 'prefetches the data' do + expect(provider.class).to respond_to(:prefetch) + end + it 'but returns system_type instead for consistency with legacy' do + expect(provider.class).to receive(:subscription_manager).with( + 'list', '--consumed' + ).and_return(entitlement_data) + provider.class.prefetch(properties) + end + end + context 'ensure' do it 'exists? should return false when the resource is absent' do provider.set(ensure: :absent)