Bug #17673

Hammer commands don't accept name options when there's id equivalent in defaultsis configured

Added by Tomáš Strachota 6 months ago. Updated 6 months ago.

Status:New
Priority:Normal
Assigned To:-
Category:Hammer core
Target version:Foreman - Team Marek backlog
Difficulty: Bugzilla link:1402646
Found in release: Pull request:
Story points-
Velocity based estimate-

Description

Description of problem:

Currently if .hammer/defaults.yml is defined with default organization,
any hammer command run with --organization option other than the default will not be honoured.

Version-Release number of selected component:
hammer-cli 0.8.0
hammer-cli-foreman 0.8.0

Steps to Reproduce:

1. Hammer organization defined:

# hammer organization list
---|--------|--------|------------
ID | NAME   | LABEL  | DESCRIPTION
---|--------|--------|------------
1  | redhat | redhat |
4  | test   | test   |
---|--------|--------|------------

1. Without hammer defaults configured (example using hostgroup command):

# hammer hostgroup list --organization redhat
---|-------------|-------------|------------------|------------------------------|------
ID | NAME        | TITLE       | OPERATING SYSTEM | ENVIRONMENT                  | MODEL
---|-------------|-------------|------------------|------------------------------|------
1  | Development | Development | RedHat 7.2       | KT_redhat_Library_puppetcv_2 |
---|-------------|-------------|------------------|------------------------------|------

# hammer hostgroup list --organization test
---|------|-------|------------------|-------------|------
ID | NAME | TITLE | OPERATING SYSTEM | ENVIRONMENT | MODEL
---|------|-------|------------------|-------------|------
2  | test | test  | RedHat 7.2       |             |
---|------|-------|------------------|-------------|------

3. With configured hammer default:

# cat .hammer/defaults.yml
---
:defaults:
  :organization_id:
    :value: '1'
  :location_id:
    :value: '2'

4. Run hammer command specifying other --organization option.

hammer hostgroup list --organization test
---|-------------|-------------|------------------|------------------------------|------
ID | NAME        | TITLE       | OPERATING SYSTEM | ENVIRONMENT                  | MODEL
---|-------------|-------------|------------------|------------------------------|------
1  | Development | Development | RedHat 7.2       | KT_redhat_Library_puppetcv_2 |
---|-------------|-------------|------------------|------------------------------|------

Actual result: It gives the list of Hostgroup of the default.

5. Run hammer command specifying other organization by --organisation-id

hammer hostgroup list --organization-id 4
---|------|-------|------------------|-------------|------
ID | NAME | TITLE | OPERATING SYSTEM | ENVIRONMENT | MODEL
---|------|-------|------------------|-------------|------
2  | test | test  | RedHat 7.2       |             |
---|------|-------|------------------|-------------|------

Actual result: It gives the correct list of Hostgroup in organization test(id 4)

Expected result:
With hammer default.yml configured, we should be able to use
organization by name (not only organization-id) to get correct result.

Additional info:
This is issue with all --<resource> options and their --<resource>-id equivalents accross the whole hammer.

History

#1 Updated by Tomáš Strachota 6 months ago

  • Subject changed from Hammer commands don't accept name options when there's id equivalent in defaultsis configured to Hammer commands don't accept name options when there's id equivalent in defaultsis configured
  • Category changed from Other commands to Hammer core
  • Target version set to Team Marek backlog

Also available in: Atom PDF