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 1359852 - Undocumented behavior with assigning all entities by specifying option with no value
Summary: Undocumented behavior with assigning all entities by specifying option with n...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Organizations and Locations
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Tomas Strachota
QA Contact: Roman Plevka
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-25 14:37 UTC by Roman Plevka
Modified: 2019-09-26 16:18 UTC (History)
2 users (show)

Fixed In Version: hammer-cli-foreman 0.11.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 18742 0 None None None 2017-03-01 11:03:07 UTC

Description Roman Plevka 2016-07-25 14:37:03 UTC
Description of problem:
There is an undocumented behavior on assigning entities using '--<entity>-ids' and providing no value - ALL entities will be assigned.
Omitting the key will assign no entities.

e.g.:
<not specifying "--domains" nor "--domain-ids" options>
# hammer -u admin -p changeme --csv organization create --name cli_org_2
Message,Id,Name
Organization created,85,cli_org_2

production.log:
2016-07-25 10:17:52 [app] [I] Started POST "/katello/api/organizations" for ::1 at 2016-07-25 10:17:52 -0400
2016-07-25 10:17:52 [app] [I] Processing by Katello::Api::V2::OrganizationsController#create as JSON
2016-07-25 10:17:52 [app] [I]   Parameters: {"name"=>"cli_org_2", "organization"=>{"name"=>"cli_org_2"}, "api_version"=>"v2"}
2016-07-25 10:17:52 [app] [I] Authorized user admin(admin)
2016-07-25 10:17:52 [app] [I] Expire fragment views/tabs_and_title_records-6 (0.2ms)
2016-07-25 10:17:52 [app] [I] Expire fragment views/tabs_and_title_records-1 (0.1ms)
2016-07-25 10:17:52 [app] [I] Expire fragment views/tabs_and_title_records-2 (0.1ms)
2016-07-25 10:17:52 [app] [I] Expire fragment views/tabs_and_title_records-16 (0.1ms)
2016-07-25 10:17:52 [app] [I] Expire fragment views/tabs_and_title_records-18 (0.1ms)
2016-07-25 10:17:52 [app] [I] Expire fragment views/tabs_and_title_records-12 (0.1ms)
2016-07-25 10:17:52 [app] [I] Expire fragment views/tabs_and_title_records-17 (0.1ms)
2016-07-25 10:17:52 [app] [I] Expire fragment views/tabs_and_title_records-9 (0.1ms)
2016-07-25 10:17:54 [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.68/app/views/katello/api/v2/organizations/show.json.rabl within katello/api/v2/layouts/resource (446.9ms)
2016-07-25 10:17:54 [app] [I] Completed 200 OK in 2820ms (Views: 430.0ms | ActiveRecord: 244.4ms)

<specifying "--domains" with no|empty value>
# hammer -u admin -p changeme --csv organization create --name cli_org_1 --domains
Message,Id,Name
Organization created,84,cli_org_1

production.log:
2016-07-25 10:15:50 [app] [I] Started GET "/api/domains?search=" for ::1 at 2016-07-25 10:15:50 -0400
2016-07-25 10:15:50 [app] [I] Processing by Api::V2::DomainsController#index as JSON
2016-07-25 10:15:50 [app] [I]   Parameters: {"search"=>"", "apiv"=>"v2", "domain"=>{}}
2016-07-25 10:15:50 [app] [I] Authorized user admin(admin)
2016-07-25 10:15:50 [app] [I]   Rendered api/v2/domains/index.json.rabl within api/v2/layouts/index_layout (18.2ms)
2016-07-25 10:15:50 [app] [I] Completed 200 OK in 68ms (Views: 20.7ms | ActiveRecord: 17.4ms)
2016-07-25 10:15:50 [app] [I] Started POST "/katello/api/organizations" for ::1 at 2016-07-25 10:15:50 -0400
2016-07-25 10:15:50 [app] [I] Processing by Katello::Api::V2::OrganizationsController#create as JSON
2016-07-25 10:15:50 [app] [I]   Parameters: {"name"=>"cli_org_1", "organization"=>{"name"=>"cli_org_1", "domain_ids"=>[6, 5, 4, 8, 7, 1, 2, 3, 9]}, "api_version"=>"v2"}
2016-07-25 10:15:50 [app] [I] Authorized user admin(admin)
2016-07-25 10:15:51 [app] [I] Expire fragment views/tabs_and_title_records-6 (0.2ms)
2016-07-25 10:15:51 [app] [I] Expire fragment views/tabs_and_title_records-1 (0.1ms)
2016-07-25 10:15:51 [app] [I] Expire fragment views/tabs_and_title_records-2 (0.1ms)
2016-07-25 10:15:51 [app] [I] Expire fragment views/tabs_and_title_records-16 (0.1ms)
2016-07-25 10:15:51 [app] [I] Expire fragment views/tabs_and_title_records-18 (0.1ms)
2016-07-25 10:15:51 [app] [I] Expire fragment views/tabs_and_title_records-12 (0.1ms)
2016-07-25 10:15:51 [app] [I] Expire fragment views/tabs_and_title_records-17 (0.1ms)
2016-07-25 10:15:51 [app] [I] Expire fragment views/tabs_and_title_records-9 (0.2ms)
2016-07-25 10:15:53 [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.68/app/views/katello/api/v2/organizations/show.json.rabl within katello/api/v2/layouts/resource (429.4ms)
2016-07-25 10:15:53 [app] [I] Completed 200 OK in 3008ms (Views: 415.5ms | ActiveRecord: 282.6ms)



- as you can see on the 2nd try, there is a GET request to fetch all domains first in order to pass the returned list to a POST request.

This behavior is not documented in hammer docs.


Version-Release number of selected component (if applicable):
satellite-6.2.0-21.1.el6sat.noarch (sat6.2 RC)

How reproducible:
always

Steps to Reproduce:
1. have some domains created with no assignments
2. create an entity (e.g. Organization) without providing e.g. --domains option: hammer -u admin -p changeme organization create --name cli_org_1
3. create an entity (e.g. Organization) without providing e.g. --domains option: hammer -u admin -p changeme organization create --name cli_org_2 --domains

4. compare the Domain assignments.

Actual results:
none vs. all entities assigned

Expected results:
Hammer should support a special flag for specifying 'all'.

Additional info:

Comment 2 Daniel Lobato Garcia 2017-03-01 10:33:51 UTC
Created redmine issue http://projects.theforeman.org/issues/18742 from this bug

Comment 3 Satellite Program 2017-04-07 10:07:01 UTC
Upstream bug assigned to tstrachota

Comment 4 Satellite Program 2017-04-07 10:07:04 UTC
Upstream bug assigned to tstrachota

Comment 5 Satellite Program 2017-04-20 14:07:10 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/18742 has been resolved.

Comment 7 Roman Plevka 2017-08-30 12:18:59 UTC
failedqa:
on sat6.3.0 snap #13
- did the patch get in? I still observe the same behavior:

# hammer --csv organization create --name foo
Message,Id,Name
Organization created,36,foo

# hammer --csv organization create --name foo2 --domains
Message,Id,Name
Organization created,37,foo2

# hammer organization info --id 37
Id:                     37
Name:                   foo2
Description:            
...
Domains:                

...


# hammer organization info --id 37
...
Domains:                
    foo1
    foo2
    foo3
    khw.lab.eng.bos.redhat.com
...

Comment 9 Tomas Strachota 2017-09-15 15:41:00 UTC
This is fixed in hammer-cli-foreman 0.11.0 it didn't make it to 6.3 repos yet.

Comment 10 Roman Plevka 2017-09-27 21:00:41 UTC
VERIFIED

sat6.3.0-17
empty --domains and --domain-ids parameters now unassign all domains from organization, which is expected.

# hammer organization info --id 4
Id:                     4
Title:                  foo2
Name:                   foo2
...
Domains:                
    foo

# hammer organization update --id 4 --domains
Organization updated
# hammer organization info --id 4
Id:                     4
Title:                  foo2
Name:                   foo2
...
Domains: 

# hammer organization update --id 4 --domain-ids 2
# hammer organization info --id 4
Id:                     4
Title:                  foo2
Name:                   foo2
...
Domains:                
    foo
# hammer organization update --id 4 --domain-ids
Organization updated
# hammer organization info --id 4
Id:                     4
Title:                  foo2
Name:                   foo2
...
Domains:

Comment 11 Bryan Kearney 2018-02-21 17:34:05 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-2018:0336

Comment 12 Bryan Kearney 2018-02-21 17:34:06 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-2018:0336


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