Hammer CLI fails with error Resource organization not found by id X

Solution Verified - Updated -

Environment

  • Red Hat Satellite 6.x

Issue

  • Associating environment with Organization and/or Location fails with following errors
# hammer organization update --id 1 --environment-ids 1,3,4
  Could not update the organization:
    Resource organization not found by id '1'
# hammer location update --id 2 --environment-ids 1,3,4
  Could not update the location:
    Resource location not found by id '2'

Resolution

  • The reported error is due to a non-existing environment ID

  • Verify the correct environment IDs by running the following hammer command

# hammer environment list
---|------------
ID | NAME       
---|------------
2  | common     
1  | production 
---|------------

For more KB articles/solutions related to Red Hat Satellite 6.x hammer Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x hammer-related Issues

Root Cause

Association of environments with Organization and/or Location failed as its unable to find some environment IDs.

Diagnostic Steps

  • Check the correct environment IDs by running below hammer command
# hammer environment list
---|------------
ID | NAME       
---|------------
2  | common     
1  | production 
---|------------
  • Check /var/log/foreman/production.log which provides more information about the error.
2019-06-04T10:23:12 [I|app|] Started PUT "/katello/api/organizations/1" for 10.107.11.14 at 2019-06-04 10:23:12 +0200
2019-06-04T10:23:12 [I|app|134ee9e5] Processing by Katello::Api::V2::OrganizationsController#update as JSON
2019-06-04T10:23:12 [I|app|134ee9e5]   Parameters: {"organization"=>{"environment_ids"=>["1", "3", "4"]}, "api_version"=>"v2", "id"=>"1"}
2019-06-04T10:23:12 [I|app|134ee9e5] Authorized user admin(Admin User)
2019-06-04T10:23:12 [I|app|134ee9e5] Current user set to admin (admin)
2019-06-04T10:23:12 [I|app|134ee9e5] Couldn't find all Environments with 'id': (1, 3, 4) (found 1 results, but was looking for 3). Couldn't find Environments with ids 3, 4. (ActiveRecord::RecordNotFound)

2019-06-04T10:29:44 [I|app|] Started PUT "/api/locations/2" for 10.107.11.14 at 2019-06-04 10:29:44 +0200
2019-06-04T10:29:44 [I|app|a0c8f4cf] Processing by Api::V2::LocationsController#update as JSON
2019-06-04T10:29:44 [I|app|a0c8f4cf]   Parameters: {"location"=>{"environment_ids"=>["1", "3", "4"]}, "apiv"=>"v2", "id"=>"2"}
2019-06-04T10:29:44 [I|app|a0c8f4cf] Authorized user admin(Admin User)
2019-06-04T10:29:44 [I|app|a0c8f4cf] Current user set to admin (admin)
2019-06-04T10:29:44 [I|app|a0c8f4cf] Couldn't find all Environments with 'id': (1, 3, 4) (found 1 results, but was looking for 3). Couldn't find Environments with ids 3, 4. (ActiveRecord::RecordNotFound)

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments