I'm starting working with the API and have some troubles (working on 1.5.1
currently)
My goal is to create a host and associate some Puppet classes with params
before the machine get instantiated and registers into Foreman(later, with
some external tools). I do this because I want my boot script call Puppet
that will apply what I'll define using API calls to Foreman.
I'm following the doc :
http://theforeman.org/api.html
POST /api/hosts
Create a host.
ParamsParam nameDescriptionhost *
required
Value: Must be a Hashhost[name] *
required
Value: Must be String*host[environment_id] *
optional
Value: Must be String
The only required arguments are host and host['name'].
So in my custom Foreman Python class I do :
def createHost(self,hostname):
return self.api.post("/api/hosts",{"host":{"name":hostname}})
And I get :
{u'host': {u'errors': {u'operatingsystem_id': [u"can't be blank"],
u'root_pass': [u'should be 8 characters or more', u'should not be blank -
consider setting a global or host group default'], u'environment_id':
[u"can't be blank"], u'ptable_id': [u'cant be blank unless a custom
partition has been defined'], u'mac': [u'is invalid', u"can't be blank"],
u'architecture_id': [u"can't be blank"]}, u'id': None, u'full_messages':
[u"Environment can't be blank", u'MAC address is invalid', u"MAC address
can't be blank", u"Architecture can't be blank", u"Operatingsystem can't be
blank", u'Root password should be 8 characters or more', u'Root password
should not be blank - consider setting a global or host group default',
u'Partition Table cant be blank unless a custom partition has been
defined']}}
WTF ?!
Doc says arguments are optional.
API(v1 or v2) says arguments are mandatory.
OFC I'll never be able to pass those arguments, I just don't know them and
don't care about them.
What am I doing wrong ?