Project

General

Profile

Bug #13982

API description for creating hosts incorrectly lists "interfaces_attributes"'s "primary" as optional

Added by Pieter Hollants almost 4 years ago. Updated almost 4 years ago.

Status:
Duplicate
Priority:
High
Assignee:
-
Category:
API
Target version:
-
Difficulty:
easy
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

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":[]}


Related issues

Is duplicate of Foreman - Bug #14239: Creating a host via API fails with cryptic error when no primary interface is set explicitlyClosed2016-03-16

History

#1 Updated by Dominic Cleal almost 4 years ago

  • Is duplicate of Bug #14239: Creating a host via API fails with cryptic error when no primary interface is set explicitly added

#2 Updated by Dominic Cleal almost 4 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.

Also available in: Atom PDF