Hide Forgot
Description of problem: When we create discovery rule with org and location, post request failed with error: MissingValueError: Cannot find a value for the "location" field. Searched for keys named ('location_ids', 'location', 'locations'), but available keys are [u'name', u'updated_at', u'created_at', u'hostname', u'enabled', u'hostgroup_id', u'max_count', u'priority', 'search_', u'id']. In [13]: attrs1 = DiscoveryRule(server_config).create_json(create_missing=True) In [14]: attrs1.keys() Out[14]: [u'search', u'name', u'updated_at', u'created_at', u'hostname', u'enabled', u'hostgroup_id', u'max_count', u'priority', u'id'] In [15]: attrs2 = DiscoveryRule(server_config, id=attrs1['id']).read_json() In [16]: attrs2.keys() Out[16]: [u'organizations', u'search', u'name', u'hosts_limit', u'hostname', u'enabled', u'hostgroup_id', u'locations', u'priority', u'hostgroup_name', u'hosts', u'id'] >>> set(attrs2.keys()) - set(attrs1.keys()) # Keys In GET response, but not POST. Out[18]: {u'hostgroup_name', u'hosts', u'hosts_limit', u'locations', u'organizations'} Version-Release number of selected component (if applicable): sat6.3 snap2 How reproducible: Steps to Reproduce: 1. Make an HTTP POST call to /api/v2/discovery_rules/ with organization & location 2. Look at the keys of the JSON response payload. Actual results: Expected results: Additional info:
Similar issue with PUT requests.. MissingValueError: Cannot find a value for the "location" field. Searched for keys named ('location_ids', 'location', 'locations'), but available keys are [u'name', u'updated_at', u'created_at', u'hostname', u'enabled', u'hostgroup_id', u'max_count', u'priority', 'search_', u'id'].
Now we show it in Discovery 9.1. $ curl-foreman /api/v2/discovery_rules/ { "total": 1, "subtotal": 1, "page": 1, "per_page": 100, "search": null, "sort": { "by": null, "order": null }, "results": [ { "name": "always", "enabled": true, "hostgroup_id": 1, "hostgroup_name": "CentOS 7.0", "hostname": "somehost-<%= rand(999999) %>", "priority": 200, "search": "cpu_count > 0", "hosts_limit": 0, "id": 1, "hosts": [ ], "organizations": [ { "id": 1, "name": "MyOrg" }, { "id": 4, "name": "OtherOrg" } ], "locations": [ { "id": 2, "name": "MyLoc" }, { "id": 3, "name": "SecondLoc" } ] } ] }
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/19647 has been resolved.
So, documentation says both "discovery_rule[location_ids]" and "discovery_rule[organization_ids]" are optional for POST, but they seem to be required. Created bug 1494585 for that.
Upstream bug assigned to lzap
Thank you for your interest in Satellite 6. We have evaluated this request, and we do not expect this to be implemented in the product in the foreseeable future. We are therefore closing this out as WONTFIX. If you have any concerns about this, please feel free to contact Rich Jerrido or Bryan Kearney. Thank you.