- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
json string for custom dhcp option.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-24-2017 05:23 AM
Hi, I am trying to figure out a way to script adding of a dhcp and dns host to Infoblox. This part works:
curl -k1 -u admin:infoblox -H "Content-Type: application/json" -X POST https://infoblox/wapi/v2.5/record:host -d '{ "name":"test002.domain.net", "ipv4addrs":[{"ipv4addr":"func:nextavailableip:x.x.x.x/23","mac":"aa:bb:cc:11:22:45"}]}'
But how do I add host-name to that? Our kickstart grabs it's hostname from dhcp. I have tried stuff like:
{"num" : "12" , "value": "test002.domain.net"}
or "option" : "host-name" , "value": "test003.domain.net"
or "name" : "host-name" , "value": "test002.domain.net"
It probably is something that will make me go duh, but I cant seem to find it. Any direction would be appreciated
Re: json string for custom dhcp option.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-25-2017 07:02 AM
Latest try:
curl -k1 -u admin:infoblox -H "Content-Type: application/json" -X POST https://infoblox/wapi/v2.5/record:host -d '{ "name":"test003.domain.net", "ipv4addrs":[{"ipv4addr":"func:nextavailableip:x.x.x.x/23","mac":"aa:bb:cc:11:22:55"}],"options" : [ { "name": "host-name", "value": "test003.domain.net" } ] }'
This causes a time out. No error, no result. Probably a syntax error in my string that I do not see?
Re: json string for custom dhcp option.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-07-2017 07:43 AM
the 'options' need to be attached to each address, not to the host, so you just need to re-arrange the bracketing.
from this:
"ipv4addrs":[{ "ipv4addr":"func:nextavailableip:x.x.x.x/23", "mac":"aa:bb:cc:11:22:55" }], "options" : [{ "name": "host-name", "value": "test003.domain.net" } ]}'
to this:
"ipv4addrs":[{ "ipv4addr":"func:nextavailableip:x.x.x.x/23", "mac":"aa:bb:cc:11:22:55" "options" : [{ "name": "host-name", "value": "test003.domain.net" } }], ]}'
Re: json string for custom dhcp option.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-28-2017 09:04 AM
GHorne, this is a good answer - but I have a question about the MAC and DHCP properties.
Isn't this a bad implementation of the underlying objects?
If I go into the DNS Records, and pull up a Host record, the DHCP enabled, and MAC Address are properties of a specific IP Address within the Host record. Yet, the REST API forces you to supply the MAC/DHCP options as a sub-property of the ipv4addrs property, not ipv4addr.
What if you wanted to add multiple IPs to the Host, and attach a specific MAC to each one, and enable DHCP? I'm using the following currently, but it just doesn't make sense logically to me:
{ "name": "test.mydomain.com", "ipv4addrs": [ { "configure_for_dhcp": true, "mac": "00:10:aa:bb:cc:00", "ipv4addr": { "_parameters": { "num": 1, "exclude": [ "192.168.1.0", "192.168.1.1" ] }, "_object_parameters": { "network": "192.168.1.0/23" }, "_object_function": "next_available_ip", "_object": "network", "_result_field": "ips" } } ] }
This just doesn't make intuitive sense to me, as I expect the Mac and configure_for_dhcp to be properties of the ipv4addr, not ipv4addrs. What am I missing?
Re: json string for custom dhcp option.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-30-2018 02:29 PM
the ipv4addrs[] is an array of ip address objects. These objects have multiple fields, MAC, DHCP options, etc. And one of those fields is the actual IP adddress 'ipv4addr'. So it is just a field that holds the IP address.
Strictly speaking, we should have called that field 'ipaddr' since the parent array defines if it is v4 or v6, but we went with this naming convention instead.
If you had multiple addresses, it would look like this:
"ipv4addrs": [ { "ipv4addr": "45.0.0.3", "mac": "de:af:ca:fe:c0:fe" }, { "ipv4addr": "45.0.2.4", "mac": "de:af:ca:fe:c0:f1" } ],