# Using python to add new hosts?

**URL:** <https://forums.suse.com/t/using-python-to-add-new-hosts/4039>\
**Category:** General\
**Created:** [September 17, 2016, 5:34pm UTC](https://forums.suse.com/t/using-python-to-add-new-hosts/4039 "2016-09-17T17:34:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MistyicWizard](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@MistyicWizard](https://forums.suse.com/u/MistyicWizard)\
**Post date:** [September 17, 2016, 5:34pm UTC](https://forums.suse.com/t/using-python-to-add-new-hosts/4039/1 "2016-09-17T17:34:20Z")

</div>

I am trying to add a new host using python with rancher api.

I get a response 400, and the this what I see in the web ui:

Error setting machine configuration from flags provided: generic driver requires the --generic-ip-address option

Any idea why?  
Here is the code:

#!/bin/python  
import requests

headers = {‘Content-Type’: ‘application/json’}  
data = { “authKey”: ‘null’,  
“labels”: {},  
“engineInstallUrl”: “[https://get.docker.com](https://get.docker.com)”,  
“engineStorageDriver”: ‘null’,  
“genericConfig”:  
{ “ipAddress”:  
“[newlocalhost.example.com](http://newlocalhost.example.com)”,  
“sshKey”: ‘’,  
“sshPort”: “22”,  
“sshUser”: “root”  
},  
“description”: “Docker Hosting client.”,  
“authCertificateAuthority”: ‘null’,  
“name”: “newlocalhost”,  
“dockerVersion”: ‘null’  
}  
requests.post(‘[http://rancher.example.com:8080/v1/projects/1a5/machines](http://rancher.example.com:8080/v1/projects/1a5/machines)’, auth=(‘xxxxxx’,‘yyyy’), headers=headers, data=data)

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [September 18, 2016, 2:14am UTC](https://forums.suse.com/t/using-python-to-add-new-hosts/4039/2 "2016-09-18T02:14:15Z")

</div>

I haven’t tried to run it or anything but the request object seems OK.

Some of the details don’t make sense though, validation errors return 422, and any 4xx error would result in no entry going into the database, which would mean no machine entry, call to docker-machine, or error response from that…
