Project

General

Profile

Actions

Bug #18742

closed

Undocumented behavior with assigning all entities by specifying option with no value

Added by Daniel Lobato Garcia over 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Category:
Organizations and locations
Difficulty:
Triaged:
Team Backlog:
Fixed in Releases:
Found in Releases:
In Kanboard:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1359852

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):
hammer-cli-foreman 0.9.0

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'.

Actions

Also available in: Atom PDF