Problem:
I need edit subnets. So I’m sending PUT request on …/api/subnets/xx and sending there data ‘{“subnet”: {“subnet_parameters_attributes”: [{“name”: “dhcp”, “value”: null}, {“name”: “discover”, “value”: null}, {“name”: “tftp_id”, “value”: null}]}}’. In response I got 200 status but values are not changed.
I need to remove tftp,dhcp and discover proxies from some subnets.
Expected outcome:
Updated values
Foreman and Proxy versions:
1.21
Foreman and Proxy plugin versions:
Distribution and version:
Debian Buster Other relevant data:
Relevant output from production log:
2019-11-19T14:30:23 [I|app|333a17b9] Processing by Api::V2::SubnetsController#update as JSON
2019-11-19T14:30:23 [I|app|333a17b9] Parameters: {“subnet”=>{“subnet_parameters_attributes”=>[{“name”=>“dhcp”, “value”=>"[FILTER
ED]"}, {“name”=>“discover”, “value”=>"[FILTERED]"}, {“name”=>“tftp_id”, “value”=>"[FILTERED]"}]}, “apiv”=>“v2”, “id”=>“196”}
2019-11-19T14:30:23 [D|app|333a17b9] Authenticated user admin against INTERNAL authentication source
2019-11-19T14:30:23 [D|app|333a17b9] Current user set to foreman_admin (admin)
2019-11-19T14:30:23 [I|app|333a17b9] Authorized user admin(Admin User)
2019-11-19T14:30:23 [I|app|333a17b9] Current user set to admin (admin)
2019-11-19T14:30:23 [D|app|333a17b9] Current location set to none
2019-11-19T14:30:23 [D|app|333a17b9] Current organization set to none
2019-11-19T14:30:23 [D|app|333a17b9] Current location set to none
2019-11-19T14:30:23 [D|app|333a17b9] Current organization set to none
2019-11-19T14:30:23 [I|app|333a17b9] Rendering api/v2/subnets/update.json.rabl
2019-11-19T14:30:23 [I|app|333a17b9] Rendered api/v2/subnets/update.json.rabl (45.9ms)
If i try get GET /api/subnets/:subnet_id/parameters I see values I set through API. But this is not changing a fact that proxy settings for subnet is intact. So I don’t want to change paramenters but proxy setting per subnet. Is it possbile?
Name of topic: I see that you change name of topic from update subnet to update subnet parameters, please revert it or change to update proxies( as this is how they are named in web gui)
Done. Subnet parameters and proxy references are two different things. I suggest you use hammer with -d option and see what does it send if you can’t find something.
But what I would like to do is to remove them from subnet. At least dhcp, because even that we add subnet as static to host it still check dhcp settings on proxy and fails as it doesn’t find any. We use dhcp just for provision subnet.
if you’re using hammer and want to remove dhcp proxy from a subnet, try hammer subnet update --id 1 --dhcp-id NIL (assuming that the subnet’s id is 1).
Why you have in API documentation that we can update them, with info which values are valid? And then in example there is PUT call for parameters? And here you tell me that we can change just parameters. Isn’t hammer calling same API?
Yes, hammer uses the same API endpoint in that command, but it doesn’t change the parameters. The example (at Foreman :: API v2 at least) shows changing of subnet’s parameters. If you want to change tftp/dhcp/etc proxy, you need to send it’s id (or null to remove) as a parameter of the API call (not nested under subnet_parameters_attributes).
In other words, if we compare yours API request with hammers’:
Yours: