Question: Update host location via hammer

Is there a way to update host location via hammer?

Problem:
Not able to update a host location via hammer

hammer host update --id=14 --location-id=75
Could not update the host:
Resource host not found by id ‘14’

hammer host info --id=14
Id: 14
Name: yjtacwvhumr.yehlaejeqq

hammer location info --id=75
Id: 75
Title: lBbFIVuava
Name: lBbFIVuava

via debug we can see:

[ INFO 2018-12-14T12:31:38 API] Server: XXXXX
[ INFO 2018-12-14T12:31:38 API] PUT /api/hosts/14
[DEBUG 2018-12-14T12:31:38 API] Params: {
“location_id” => 75,
“host” => {
“location_id” => 75,
“puppetclass_ids” => ,
“compute_attributes” => {},
“content_facet_attributes” => {},
“subscription_facet_attributes” => {}
}
}
[DEBUG 2018-12-14T12:31:38 API] Headers: {}
[DEBUG 2018-12-14T12:31:38 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[ERROR 2018-12-14T12:31:38 API] 404 Not Found
[DEBUG 2018-12-14T12:31:38 API] {
“error” => {
“message” => “Resource host not found by id ‘14’”
}

Eg seems hammer try to filter hosts by the supplied location-id

Other relevant data:
For the moment we are able to update the location via API

Usage Scenario:
When subscribing a host via subscription-manager, the host is automatically subscribed to Default Location, but it’s intended to be used by a user that has access to other location (user location), and we want to assign the user location to that host.

This is not possible AFAIK. It’s the same as in WebUI, where in host form (for existing host) select boxes for location (and organization) are disabled. The reason is, host is linked to many resources that might not be available in given location. The only way how to move host between locations/organizations is via bulk actions (UI only) where you choose whether you want to fix mismatch (assign the linked resource to location that’s being assigned) or fail on mismatch (print error message). Perhaps we need something similar in CLI.

The location-id and organization-id parameters you see have different meaning. It’s “current location” in which you’re working for this hammer command. Hence when you ask to update host with id 14 which belongs to location 2 for example, but you specify you work in location 75, it won’t find the host, this host does not exist in location 75.

If we implement this, we’d probably need something like “–new-location-id” to distinguish between “current context” and “host’s location”

Many thanks @Marek_Hulan for the explanations.