Project

General

Profile

Actions

Feature #8992

open

Have api use a free dhcp ip address when updating a hosts subnet to one that has dhcp

Added by Ronny M over 9 years ago. Updated over 9 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

When using the api to change a hosts subnet to one that has dhcp, the api call fails with error message: IP address is invalid

Instead of the error I would like the api to use a free dhcp ipaddress for the choosen subnet.

Actions #1

Updated by Dominic Cleal over 9 years ago

  • Category set to API
Actions #2

Updated by Ronny M over 9 years ago

Sorry error in description should be:

{"host":{"id":53,"errors":{"ip":["Does not match selected Subnet"]},"full_messages":["IP address Does not match selected Subnet"]}}

when only updating/changing subnet. (host already had an ip adress in the old subnet)

and

{"host":{"id":53,"errors":{"ip":["is invalid"]},"full_messages":["IP address is invalid"]}}

when trying to also update ip to an empty string to see if it would trigger the auto-ip.

If I update subnet to the same subnet as it already is then the call with not give an error, but thats because nothing changes.

Actions #3

Updated by Dominic Cleal over 9 years ago

Can you try setting the IP to a null value at the same time, rather than an empty string? "ip": null in JSON terms.

Actions #4

Updated by Ronny M over 9 years ago

Get the same errors as before :(

curl -s -H 'Accept:application/json' -H 'Content-Type: application/json' -k -u admin:changeme -X PUT -d '{"host":{"subnet_id":7,"ip":null}}' https://foreman/api/v2/hosts/53 {"error": {"id":53,"errors":{"ip":["is invalid"]},"full_messages":["IP address is invalid"]}

curl -s -H 'Accept:application/json' -H 'Content-Type: application/json' -k -u admin:changeme -X PUT -d '{"host":{"subnet_id":7}}' https://foreman/api/v2/hosts/53 {"error": {"id":53,"errors":{"ip":["Does not match selected Subnet"]},"full_messages":["IP address Does not match selected Subnet"]}

Actions

Also available in: Atom PDF