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 1388148

Summary: API host PUT uses fields not in host hash as filter
Product: Red Hat Satellite Reporter: Peter Vreman <peter.vreman>
Component: HostsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.2CC: bbuckingham, inecas, jcallaha
Target Milestone: UnspecifiedKeywords: Triaged
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: 2017-08-08 15:51:44 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:
Bug Depends On:    
Bug Blocks: 1122832    

Description Peter Vreman 2016-10-24 15:18:55 UTC
Description of problem:
I got the following undocumented feature that setting the environment_id not inside the require host hash then it will be used for filtering.

See the commands below, when i specify the current environment_id in the PUT i get a result.
When i specify a different environment_id then it returns a resource not found

[prod] root@li-lp-1800:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"environment_id\":\"71\"}" -XPUT https://localhost:443/api/v2/hosts/107 | jq .environment_id
71
[prod] root@li-lp-1800:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"environment_id\":\"70\"}" -XPUT https://localhost:443/api/v2/hosts/107
{
  "error": {"message":"Resource host not found by id '107'"}
}



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


How reproducible:


Steps to Reproduce:
1. PUT a hosts with a value of environment_id that is different from the current one, but not inside the host:{} hash
2. 
3.

Actual results:
Error resource not found.


Expected results:
Value of environment_id is ignore or an error is given that an unsupported field is passed.

Additional info:

Comment 3 Peter Vreman 2017-08-08 15:51:44 UTC
Closing, with 6.2.10 the filtering works reliable and consistent. It first uses the environment_id for filtering and then will search for the host. If the provided environment does not exists then it gives an error that does not exists

Correct environment_id and host_id

[crash/LI] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"environment_id\":\"503\"}" -XPUT https://localhost:443/api/v2/hosts/3 | jq .id
3

Hosts is not in environment_id 503

[crash/LI] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"environment_id\":\"503\"}" -XPUT https://localhost:443/api/v2/hosts/7
{
  "error": {"message":"Resource host not found by id '7'"}
}

Environment does not exists

[crash/LI] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"environment_id\":\"99503\"}" -XPUT https://localhost:443/api/v2/hosts/7
{"message":"Environment not found by id '99503'"}