Host create api doesn't work in foreman 1.8.2

Hi,

I tried to use Foreman API create a host, but it failed,
[sxin@goldstan ] $ curl -k -u admin:password -H "Accept: version=2,
application/json" -H "Content-Type: application/json" -X POST -d '{
"name":"goldtest.abc.com","hostgroup_id":3,"mac":"A0:48:1C:90:3E:5E" }'
https://foreman.abc.com/api/hosts
{
"error": {"id":null,"errors":{"interfaces.mac":["can't be
blank"]},"full_messages":["Mac can't be blank"]}
}

I do have this mac, but it seems not correct. btw, I created default OS,
hostgroup and partition tables, install media, etc. only stuck on
interfaces.mac.
Here is the log in production.log:
2015-06-19 19:02:50 [E] Unprocessable entity Host::Managed (id: new):
Mac can't be blank

Can anyone please help on this?

Thanks
Sinux

Anyone please help?

··· On Friday, June 19, 2015 at 7:04:10 PM UTC+8, sinux shen wrote: > > Hi, > > I tried to use Foreman API create a host, but it failed, > [sxin@goldstan ] $ curl -k -u admin:password -H "Accept: version=2, > application/json" -H "Content-Type: application/json" -X POST -d '{ "name":" > goldtest.abc.com","hostgroup_id":3,"mac":"A0:48:1C:90:3E:5E" }' > https://foreman.abc.com/api/hosts > { > "error": {"id":null,"errors":{"interfaces.mac":["can't be > blank"]},"full_messages":["Mac can't be blank"]} > } > > I do have this mac, but it seems not correct. btw, I created default OS, > hostgroup and partition tables, install media, etc. only stuck on > interfaces.mac. > Here is the log in production.log: > 2015-06-19 19:02:50 [E] Unprocessable entity Host::Managed (id: new): > Mac can't be blank > > Can anyone please help on this? > > Thanks > Sinux > >

I believe this is a bug in our API V2 when we merged the new NIC code.
Do not use "mac" attribute, but "interfaces_attributes" instead.

LZ

··· On Fri, Jun 19, 2015 at 04:04:10AM -0700, sinux shen wrote: > Hi, > > I tried to use Foreman API create a host, but it failed, > [sxin@goldstan ] $ curl -k -u admin:password -H "Accept: version=2, > application/json" -H "Content-Type: application/json" -X POST -d '{ > "name":"goldtest.abc.com","hostgroup_id":3,"mac":"A0:48:1C:90:3E:5E" }' > https://foreman.abc.com/api/hosts > { > "error": {"id":null,"errors":{"interfaces.mac":["can't be > blank"]},"full_messages":["Mac can't be blank"]} > } > > I do have this mac, but it seems not correct. btw, I created default OS, > hostgroup and partition tables, install media, etc. only stuck on > interfaces.mac. > Here is the log in production.log: > 2015-06-19 19:02:50 [E] Unprocessable entity Host::Managed (id: new): > Mac can't be blank > > Can anyone please help on this? > > Thanks > Sinux > > -- > You received this message because you are subscribed to the Google Groups "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an email to foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/d/optout.


Later,
Lukas #lzap Zapletal

Hi, Lukas,

Do you mean interfaces.mac or interfaces_attributes, I tried both,
curl -k -u admin:password -H "Accept: version=2, application/json" -H
"Content-Type: application/json" -X POST -d '{ "name":
"goldtest.abc.com","hostgroup_id":3,"interfaces.mac":"A0:48:1C:90:3E:5E" }'
https://foreman.abc.com/api/hosts

Thanks

but it still prompt the same error.

··· On Monday, June 22, 2015 at 6:34:44 PM UTC+8, Lukas Zapletal wrote: > > I believe this is a bug in our API V2 when we merged the new NIC code. > Do not use "mac" attribute, but "interfaces_attributes" instead. > > LZ > > On Fri, Jun 19, 2015 at 04:04:10AM -0700, sinux shen wrote: > > Hi, > > > > I tried to use Foreman API create a host, but it failed, > > [sxin@goldstan ] $ curl -k -u admin:password -H "Accept: version=2, > > application/json" -H "Content-Type: application/json" -X POST -d '{ > > "name":"goldtest.abc.com","hostgroup_id":3,"mac":"A0:48:1C:90:3E:5E" }' > > https://foreman.abc.com/api/hosts > > { > > "error": {"id":null,"errors":{"interfaces.mac":["can't be > > blank"]},"full_messages":["Mac can't be blank"]} > > } > > > > I do have this mac, but it seems not correct. btw, I created default OS, > > hostgroup and partition tables, install media, etc. only stuck on > > interfaces.mac. > > Here is the log in production.log: > > 2015-06-19 19:02:50 [E] Unprocessable entity Host::Managed (id: new): > > Mac can't be blank > > > > Can anyone please help on this? > > > > Thanks > > Sinux > > > > -- > > You received this message because you are subscribed to the Google > Groups "Foreman users" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to foreman-user...@googlegroups.com . > > To post to this group, send email to forema...@googlegroups.com > . > > Visit this group at http://groups.google.com/group/foreman-users. > > For more options, visit https://groups.google.com/d/optout. > > > -- > Later, > Lukas #lzap Zapletal >

I tried the following:

curl -k -u admin:password -H "Accept: version=2, application/json" -H
"Content-Type: application/json" -X POST -d '{ "name":"goldtest.example.com",interfaces_attributes":{
"0":{"mac":"00:1a:4a:55:3a:0e"} },"hostgroup_id":3 }'
https://foreman.example.com/api/hosts/

{

"error": {"id":null,"errors":{"interfaces.mac":["can't be
blank"]},"full_messages":["Mac can't be blank"]}

}

does interfaces_attributes need more than one parameters?

Thanks
Sinux

··· On Saturday, June 27, 2015 at 11:13:08 PM UTC+8, sinux shen wrote: > > Hi, Lukas, > > Do you mean interfaces.mac or interfaces_attributes, I tried both, > curl -k -u admin:password -H "Accept: version=2, application/json" -H > "Content-Type: application/json" -X POST -d '{ "name": > "goldtest.abc.com","hostgroup_id":3,"interfaces.mac":"A0:48:1C:90:3E:5E" > }' https://foreman.abc.com/api/hosts > > Thanks > > but it still prompt the same error. > > On Monday, June 22, 2015 at 6:34:44 PM UTC+8, Lukas Zapletal wrote: >> >> I believe this is a bug in our API V2 when we merged the new NIC code. >> Do not use "mac" attribute, but "interfaces_attributes" instead. >> >> LZ >> >> On Fri, Jun 19, 2015 at 04:04:10AM -0700, sinux shen wrote: >> > Hi, >> > >> > I tried to use Foreman API create a host, but it failed, >> > [sxin@goldstan ] $ curl -k -u admin:password -H "Accept: version=2, >> > application/json" -H "Content-Type: application/json" -X POST -d '{ >> > "name":"goldtest.abc.com","hostgroup_id":3,"mac":"A0:48:1C:90:3E:5E" >> }' >> > https://foreman.abc.com/api/hosts >> > { >> > "error": {"id":null,"errors":{"interfaces.mac":["can't be >> > blank"]},"full_messages":["Mac can't be blank"]} >> > } >> > >> > I do have this mac, but it seems not correct. btw, I created default >> OS, >> > hostgroup and partition tables, install media, etc. only stuck on >> > interfaces.mac. >> > Here is the log in production.log: >> > 2015-06-19 19:02:50 [E] Unprocessable entity Host::Managed (id: new): >> > Mac can't be blank >> > >> > Can anyone please help on this? >> > >> > Thanks >> > Sinux >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups "Foreman users" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an email to foreman-user...@googlegroups.com. >> > To post to this group, send email to forema...@googlegroups.com. >> > Visit this group at http://groups.google.com/group/foreman-users. >> > For more options, visit https://groups.google.com/d/optout. >> >> >> -- >> Later, >> Lukas #lzap Zapletal >> >

Have you seen Foreman ?

It's all there, I haven't tested this new API yet.

··· -- Later, Lukas #lzap Zapletal