This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 1314775 - hammer activation-key --unlimited-content-hosts flag is confusing
hammer activation-key --unlimited-content-hosts flag is confusing
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Hammer (Show other bugs)
6.2.0
Unspecified Unspecified
unspecified Severity medium (vote)
: GA
: --
Assigned To: Zach Huntington-Meath
Katello QA List
http://projects.theforeman.org/issues...
: Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-03-04 07:59 EST by Roman Plevka
Modified: 2016-07-27 07:30 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-07-27 07:30:14 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Foreman Issue Tracker 14333 None None None 2016-04-22 12:11 EDT

  None (edit)
Description Roman Plevka 2016-03-04 07:59:39 EST
Description of problem:
unlimited-hosts flag is not required by `hammer activation-key create` as there's no limit set by default if no --max-content-hosts is used.

the `hammer activation-key update` on the other hand uses `--unlimited-content-hosts` flag for changing the limit to `unlimited`. However, this flag requires a boolean value (true/false, yes/no, 1/0). So we can have an AK with unlimited content hosts and update it using `--unlimited-content-hosts true`. The other way around - setting it back to limited, requires `--max-content-hosts` no matter what:

```
# hammer -u admin -p changeme activation-key update --unlimited-content-hosts false --id 78 --organization-id 3

Could not update the activation key:
  Validation failed: Max content hosts cannot be nil
```

making the use of `hammer activation-key update --unlimited-content-hosts false` useless as the same effect is being done using `--max-content-hosts` option only.

I believe we can drop `--unlimited-content-hosts` option from `create` subcommand
and change the behaviour of the same option in `update` subcommand not to accept any bool valie (only check for falg presence). 

Version-Release number of selected component (if applicable):
6.2.0

How reproducible:
always

Steps to Reproduce:
1. hammer activation-key create --unlimited-content-hosts --organization-id 1 --name foo
2. hammer activation-key create --organization-id 1 --name bar
3. compare the content host limit of both activation keys

# for the `update` subcommand:
4. create AK with no content host limit
5. hammer activation key update --organization-id 1 --id 70 --unlimited-content-hosts false

Actual results:
as described above

Expected results:
no `--unlimited-content-host` option `create` subcommand,
make the same flag in `update` subcommand not to require any boolean value (presence-based check only)

Additional info:
snap 2.1
Comment 4 Zach Huntington-Meath 2016-03-23 14:02:15 EDT
Created redmine issue http://projects.theforeman.org/issues/14333 from this bug
Comment 5 Bryan Kearney 2016-04-22 12:08:32 EDT
Moving to POST since upstream bug http://projects.theforeman.org/issues/14333 has been closed
-------------
Zach Huntington-Meath
Applied in changeset commit:hammer-cli-katello|fb494a72c1f4206004490cdfde11d36709aa9267.
Comment 6 Roman Plevka 2016-05-30 09:17:12 EDT
VERIFIED
Sat6.2.0 Beta (GA13.1)

The option now acts like a flag and makes more sense:

<pre>
# hammer -u admin -p changeme activation-key create --unlimited-hosts --organization-id 1 --name foo
Activation key created
# hammer activation-key create --organization-id 1 --name bar
[Foreman] Password for admin: 
Activation key created
# hammer activation-key list --organization-id 1
[Foreman] Password for admin: 
---|---------|----------------|-----------------------|-------------
ID | NAME    | HOST LIMIT     | LIFECYCLE ENVIRONMENT | CONTENT VIEW
---|---------|----------------|-----------------------|-------------
12 | foo     | 0 of Unlimited |                       |             
13 | bar     | 0 of Unlimited |                       |             
---|---------|----------------|-----------------------|-------------

# hammer activation-key update --organization-id 1 --id 12 --help
Usage:
    hammer activation-key update [OPTIONS]

Options:
...
 --max-hosts MAX_HOSTS                               maximum number of registered content hosts
...
 --unlimited-hosts                                   set hosts max to unlimited
 -h, --help                                          print help

# hammer -u admin -p changeme activation-key update --organization-id 1 --id 12 --max-hosts 1
Activation key updated
# hammer -u admin -p changeme activation-key list --organization-id 1
---|---------|----------------|-----------------------|-------------
ID | NAME    | HOST LIMIT     | LIFECYCLE ENVIRONMENT | CONTENT VIEW
---|---------|----------------|-----------------------|-------------
12 | foo     | 0 of 1         |                       |             
13 | bar     | 0 of Unlimited |                       |             
---|---------|----------------|-----------------------|-------------

# hammer activation-key update --organization-id 1 --id 12 --unlimited-hosts
[Foreman] Password for admin: 
Activation key updated
hammer -u admin -p changeme activation-key list --organization-id 1---|---------|----------------|-----------------------|-------------
ID | NAME    | HOST LIMIT     | LIFECYCLE ENVIRONMENT | CONTENT VIEW
---|---------|----------------|-----------------------|-------------
12 | foo     | 0 of Unlimited |                       |             
13 | bar     | 0 of Unlimited |                       |             
---|---------|----------------|-----------------------|-------------



</pre>
Comment 7 Bryan Kearney 2016-07-27 07:30:14 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:1501

Note You need to log in before you can comment on or make changes to this bug.