Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1614360

Summary: hammer hostgroup create/update --compute-resource fails to query CR
Product: Red Hat Satellite Reporter: Lukas Pramuk <lpramuk>
Component: Host GroupAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.4CC: akarsale, apatel, dhlavacd, inecas, kgaikwad, lpramuk, mbacovsk, mhulan, mshira, rabajaj, tstrachota
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-08-10 09:17:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Lukas Pramuk 2018-08-09 13:41:48 UTC
Description of problem:
hammer hostgroup create/update --compute-resource fails to query CR since it uses wrong api call for the query:

GET /api/compute_resources 
Params: { "name" => "libvirt" }

This call basically returns all compute resources:

Could not create the hostgroup:
  Error: Found more than one compute_resource.


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

How reproducible:
deterministic

Steps to Reproduce:
1. Have more than 1 CR

# hammer compute-resource list 
---|---------------|---------
ID | NAME          | PROVIDER
---|---------------|---------
1  | docker        | Docker  
2  | libvirt       | Libvirt 
---|---------------|---------

2. Try to create/update a hostgroup querying CR by name

# hammer hostgroup create --name 'libvirt hosts' --compute-resource libvirt
Could not create the hostgroup:
  Error: Found more than one compute_resource.


Actual results:
fails to create/update HG when referring CR by name (by id works)

Expected results:
successful HG creation/update when referring CR also by name

Comment 2 Lukas Pramuk 2018-08-09 14:11:37 UTC
When referring to compute profile by name it also uses wrong api call listing all 3 compute profiles:

# hammer hostgroup create --name 'libvirt hosts' --compute-resource-id 2 --compute-profile 1-Small
Could not create the hostgroup:
  Error: Found more than one compute_profile.

...
[ INFO 2018-08-09T10:05:47 API] GET /api/compute_profiles
[DEBUG 2018-08-09T10:05:47 API] Params: {
    "name" => "1-Small"
}
[DEBUG 2018-08-09T10:05:47 API] Headers: {
    :params => {
        "name" => "1-Small"
    }
}
[DEBUG 2018-08-09T10:05:47 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[DEBUG 2018-08-09T10:05:48 API] Response: {
       "total" => 3,
...

Comment 3 Brad Buckingham 2018-08-09 17:04:17 UTC
Hi Lukas,

Do you know if this is a regression from 6.3? (Thanks!)

Comment 4 Lukas Pramuk 2018-08-10 08:16:08 UTC
With --compute-resource option it can't be regression since the option doesn't exist on 6.3

With --compute-profile option I tested it is broken the same way on 6.3, so no regression too.

Comment 5 Lukas Pramuk 2018-08-10 09:17:12 UTC

*** This bug has been marked as a duplicate of bug 1584785 ***