Skip to content

Commit

Permalink
When no pool quantity is set, then do not set quantity to 1
Browse files Browse the repository at this point in the history
* Bug fix for: ansible#66478
* When no quantity is set, then candlepin server usually uses
  default value 1. When more quantities are required, then
  candlepin server can automatically choose correct minimal
  value.
  • Loading branch information
jirihnidek committed Jan 28, 2020
1 parent 1152774 commit e27a195
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 5 additions & 3 deletions lib/ansible/modules/packaging/os/redhat_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,9 @@ def subscribe_by_pool_ids(self, pool_ids):

for pool_id, quantity in sorted(pool_ids.items()):
if pool_id in available_pool_ids:
args = [SUBMAN_CMD, 'attach', '--pool', pool_id, '--quantity', quantity]
args = [SUBMAN_CMD, 'attach', '--pool', pool_id]
if quantity is not None:
args.extend(['--quantity', to_native(quantity)])
rc, stderr, stdout = self.module.run_command(args, check_rc=True)
else:
self.module.fail_json(msg='Pool ID: %s not in list of available pools' % pool_id)
Expand Down Expand Up @@ -839,8 +841,8 @@ def main():
module.fail_json(msg='Unable to parse pool_ids option.')
pool_id, quantity = list(value.items())[0]
else:
pool_id, quantity = value, 1
pool_ids[pool_id] = str(quantity)
pool_id, quantity = value, None
pool_ids[pool_id] = quantity
consumer_type = module.params["consumer_type"]
consumer_name = module.params["consumer_name"]
consumer_id = module.params["consumer_id"]
Expand Down
7 changes: 2 additions & 5 deletions test/units/modules/packaging/os/test_redhat_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,7 @@ def test_without_required_parameters(capfd, patch_redhat_subscription):
[
'/testbin/subscription-manager',
'attach',
'--pool', 'ff8080816b8e967f016b8e99632804a6',
'--quantity', '1'
'--pool', 'ff8080816b8e967f016b8e99632804a6'
],
{'check_rc': True},
(0, '', '')
Expand All @@ -567,8 +566,7 @@ def test_without_required_parameters(capfd, patch_redhat_subscription):
[
'/testbin/subscription-manager',
'attach',
'--pool', 'ff8080816b8e967f016b8e99747107e9',
'--quantity', '1'
'--pool', 'ff8080816b8e967f016b8e99747107e9'
],
{'check_rc': True},
(0, '', '')
Expand Down Expand Up @@ -658,7 +656,6 @@ def test_without_required_parameters(capfd, patch_redhat_subscription):
'/testbin/subscription-manager',
'attach',
'--pool', 'ff8080816b8e967f016b8e99632804a6',
'--quantity', '1'
],
{'check_rc': True},
(0, '', '')
Expand Down

0 comments on commit e27a195

Please sign in to comment.