Bug 1746934 - Host Group is not being assigned to Compliance Policy when created using API with host_ids parameter.
Summary: Host Group is not being assigned to Compliance Policy when created using API ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: SCAP Plugin
Version: 6.6.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: 6.6.0
Assignee: Ondřej Pražák
QA Contact: Jameer Pathan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-08-29 14:27 UTC by Jameer Pathan
Modified: 2019-10-22 19:48 UTC (History)
3 users (show)

Fixed In Version: tfm-rubygem-foreman_openscap-1.0.6
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-10-22 19:48:22 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 27754 0 Normal Closed Host Group is not being assigned to Compliance Policy when created using API with host_ids parameter. 2020-05-13 06:18:32 UTC

Description Jameer Pathan 2019-08-29 14:27:12 UTC
Description of problem:
Host Group is not being assigned to Compliance Policy when created using API with Host_ids parameter.

Version-Release number of selected component (if applicable):
- Satellite 6.6.0 snap 17

How reproducible:
Always

Steps to Reproduce:
1. When hostgroup_ids and host_ids both are used to create compliance policy
then only host_ids are getting assigned to compliance policy.

$ curl -k -u "admin:changeme" -X POST -H "Content-Type: application/json; charset=UTF-8" https://hostname.example.com/api/v2/compliance/policies/ -d '{"policy":{"name":"cp5","scap_content_id":1,"scap_content_profile_id":1,"period":"custom","cron_line":"10 * * * *","deploy_by":"manual","hostgroup_ids":[1],"host_ids":[1]}}'

Actual results:
$ curl -k -u "admin:changeme" -X POST -H "Content-Type: application/json; charset=UTF-8" https://hostname.example.com/api/v2/compliance/policies/ -d '{"policy":{"name":"cp5","scap_content_id":1,"scap_content_profile_id":1,"period":"custom","cron_line":"10 * * * *","deploy_by":"manual","hostgroup_ids":[1],"host_ids":[1]}}'
{"created_at":"2019-08-29 13:25:49 UTC","updated_at":"2019-08-29 13:25:49 UTC","id":5,"name":"cp5","period":"custom","weekday":null,"description":null,"scap_content_id":1,"scap_content_profile_id":1,"day_of_month":null,"cron_line":"10 * * * *","tailoring_file_id":null,"tailoring_file_profile_id":null,"deploy_by":"manual","organizations":[],"locations":[],"hosts":[{"id":1,"name":"hostname.example.com"}],"hostgroups":[]}

Expected results:
$ curl -k -u "admin:changeme" -X POST -H "Content-Type: application/json; charset=UTF-8" https://hostname.example.com/api/v2/compliance/policies/ -d '{"policy":{"name":"cp5","scap_content_id":1,"scap_content_profile_id":1,"period":"custom","cron_line":"10 * * * *","deploy_by":"manual","hostgroup_ids":[1],"host_ids":[1]}}'
{"created_at":"2019-08-29 13:25:49 UTC","updated_at":"2019-08-29 13:25:49 UTC","id":5,"name":"cp5","period":"custom","weekday":null,"description":null,"scap_content_id":1,"scap_content_profile_id":1,"day_of_month":null,"cron_line":"10 * * * *","tailoring_file_id":null,"tailoring_file_profile_id":null,"deploy_by":"manual","organizations":[],"locations":[],"hosts":[{"id":1,"name":"hostname.example.com"}],"hostgroups":[{"id":1,"name":"test","title":"test"}]}

Additional info:

Comment 4 Ondřej Pražák 2019-09-02 06:55:35 UTC
Created redmine issue https://projects.theforeman.org/issues/27754 from this bug

Comment 5 Bryan Kearney 2019-09-02 08:03:09 UTC
Upstream bug assigned to oprazak

Comment 6 Bryan Kearney 2019-09-02 08:03:11 UTC
Upstream bug assigned to oprazak

Comment 7 Bryan Kearney 2019-09-04 16:03:19 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/27754 has been resolved.

Comment 10 Jameer Pathan 2019-09-09 11:36:20 UTC
Verified

Verified with:
- Satellite 6.6.0 snap 19
- tfm-rubygem-foreman_openscap-1.0.6-1.el7sat.noarch

Test steps:
- Create Compliance policy using both hostgroup_ids and host_ids
# curl -k -u "admin:changeme" -X POST -H "Content-Type: application/json; charset=UTF-8" https://hostname.example.com/api/v2/compliance/policies/ -d '{"policy":{"name":"cp5","scap_content_id":1,"scap_content_profile_id":1,"period":"custom","cron_line":"10 * * * *","deploy_by":"manual","hostgroup_ids":[1],"host_ids":[1],"location_ids":[2],"organization_ids":[1]}}'
{"created_at":"2019-09-09 11:26:48 UTC","updated_at":"2019-09-09 11:26:48 UTC","id":5,"name":"cp5","period":"custom","weekday":null,"description":null,"scap_content_id":1,"scap_content_profile_id":1,"day_of_month":null,"cron_line":"10 * * * *","tailoring_file_id":null,"tailoring_file_profile_id":null,"deploy_by":"manual","organizations":[{"id":1,"name":"Default Organization","title":"Default Organization"}],"locations":[{"id":2,"name":"Default Location","title":"Default Location"}],"hosts":[{"id":1,"name":"hostname.example.com"}],"hostgroups":[{"id":1,"name":"hg1","title":"hg1"}]}

Comment 11 Bryan Kearney 2019-10-22 19:48:22 UTC
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/RHSA-2019:3172


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