- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Howto Get ipve4addr in assign_state when creating a host object record:host
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2020 01:55 AM
I'm using https://ipam.kpn.org/wapi/v2.9.5/request? to create an host object. In the same call I want to assign the ipv4addr retured by this POST to create a PTR record.
The issue is that I'm not able to assign the ipv4addr to a varaible so I can use it in the next POST.
Examples:
The request I fire is:
- I left the creation of a PTR record out of the example, because that is not my issue
[ { "method": "STATE:ASSIGN", "data": { "net": "10.0.2.0/24", "hostname": "myhostname" } }, { "method": "POST", "object": "record:host", "data": { "name": "##STATE:hostname:##", "configure_for_dns": false, "ipv4addrs": [ { "ipv4addr": "func:nextavailableip:##STATE:net:##", "configure_for_dhcp": false } ] }, "args": { "_return_fields": "ipv4addrs" }, "assign_state": { "created_ip_address": "ipv4addrs" }, "enable_substitution": true, "discard": true }, { "method": "STATE:DISPLAY" } ]
The result:
[ { "created_ip_address": [ { "_ref": "record:host_ipv4addr/ZG5zLmhvc3RfYWRkcmVzcyQubm9uX0ROU19ob3N0X3Jvb3QuMi4xNTg4MzIyNjYzMTY3LnNsZGNscjA5OTcuMTAuNDAuMjQzLjIwLg:10.40.243.20/sldclr0997/%20", "configure_for_dhcp": false, "host": "sldclr0997", "ipv4addr": "10.0.2.20" } ], "hostname": "myhostname", "net": "10.0.2.0/24" } ]
So, I can assign the array ipv4addrs to created_ip_address, but what I want is the assign the ipv4addr from the array to a variable. (assign_state).
I expected it to be something like ipv4addrs.ipv4addr or ipv4addrs[0].ipv4addr but that does not work.
I hope someone can help me with this.
Re: Howto Get ipve4addr in assign_state when creating a host object record:host
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 02:54 AM
Hi,
You can use the next_available_ip function to first get the desired IP address, store it in a variable, and then use it while creating host record and PTR record like below:
curl -k -u admin:infoblox -H 'content-type:application/json' -X POST "https://grid-master/wapi/v2.10/request" -d' [ { "method":"STATE:ASSIGN", "data":{ "net":"10.10.10.0/24",
"hostname":"myhostname" } }, { "method":"GET", "object":"network", "data":{ "network":"##STATE:net:##" }, "assign_state":{ "net_ref":"_ref" }, "enable_substitution":true, "discard":true }, { "method":"POST", "object":"##STATE:net_ref:##", "args":{ "_function":"next_available_ip" }, "assign_state":{ "ip_address":"ips[0]" }, "enable_substitution":true, "discard":true }, { "method":"STATE:DISPLAY" } ]'
Use ip_address in subsequent operations.
Hope this helps,
Krishna Vasudevan