Bug #13982
closedAPI description for creating hosts incorrectly lists "interfaces_attributes"'s "primary" as optional
Description
http://theforeman.org/api/1.10/apidoc/v2/hosts/create.html says:
host[interfaces_attributes][primary]
optional , nil allowed
The "optional" flag seems to be wrong:
$ curl -s -H "Content-Type: application/json" k -u admin:secret -d '{"host":{"hostgroup_id": "1", "name": "test", "environment_id":"1", "interfaces_attributes":{"0":{"ip":"192.168.100.5","mac":"00:11:22:33:44:55","type":"interface","identifier":"eth0"}}}}' http://foreman.test.foo/api/hosts {
"error": {"id":null,"errors":{"interfaces.mac":["can't be blank"]},"full_messages":["Mac can't be blank"]}
}
$ curl -s -H "Content-Type: application/json" k -u admin:secret -d '{"host":{"hostgroup_id": "1", "name": "test", "environment_id":"1", "interfaces_attributes":{"0":{"ip":"192.168.100.5","mac":"00:11:22:33:44:55","primary":"true"}}}}' http://foreman.test.foo/api/hosts {"ip":"192.168.100.5", ... ,"all_puppetclasses":[]}
Updated by Dominic Cleal almost 9 years ago
- Is duplicate of Bug #14239: Creating a host via API fails with cryptic error when no primary interface is set explicitly added
Updated by Dominic Cleal almost 9 years ago
- Status changed from New to Duplicate
I think #14239 has fixed this in a different way, by automatically setting a primary interface if none is specified. The attribute remains optional. Thanks for the report.