Reply
Highlighted
Accepted Solution

Create record:host via API in non-default network view

[ Edited ]
bbialek
Techie
Posts: 2
2233     0

Hi. I am working with WAPI v2.6.2, ui shows version 8.1.2-356916.

 

Here's record:host which I created via GUI in non-default network view "testing":

 

    {
        "_ref": "record:host/ZG5zLmhvc3QkLm5vbl9ETlNfaG9zdF9yb290NC4wLjE1MTkzODA3MDg3ODQudmlhX3Vp:via_ui/%20%20",
        "ipv4addrs": [
            {
                "_ref": "record:host_ipv4addr/ZG5zLmhvc3RfYWRkcmVzcyQubm9uX0ROU19ob3N0X3Jvb3Q0LjAuMTUxOTM4MDcwODc4NC52aWFfdWkuMi4wLjAuMi4:2.0.0.2/via_ui/%20%20",
                "configure_for_dhcp": false,
                "host": "via_ui",
                "ipv4addr": "2.0.0.2"
            }
        ],
        "network_view": "testing",
        "view": "  "
    }

I would like to create more hosts like this via API but I am failing to do so.

 

 

For some reason "view" field contains two spaces in the record created via GUI. if I try to send request with same value, like following:

 

{
  "ipv4addrs": [
    {
      "ipv4addr": "2.0.0.1"
    }
  ],
  "name": "via_api",
  "view": "  ",
  "network_view": "testing"
}

API returns misterious error:

 

 

{
    "Error": "AdmConDataError: expected single object, got 4",
    "code": "Client.Ibap.Data",
    "text": "expected single object, got 4"
}

 

 

 

On the other hand, if I fetch GET /views, i am getting following entries:

 

[
    {
        "_ref": "view/ZG5zLnZpZXckLl9kZWZhdWx0:default/true",
        "name": "default",
        "network_view": "default"
    },
    {
        "_ref": "view/ZG5zLnZpZXckLjQ:default.testing/false",
        "name": "default.testing",
        "network_view": "testing"
    }
]

 

 

but adding record:host with view "default" (or "default.testing") and network_view "testing" fails with message "The action is not allowed. A parent was not found." (even though i have 2.0.0.0/28 network defined in "testing" view).

 

What is correct way to create record:host via API in non-default network view?

 

Regards,

Bartosz

 

 

 

 

Re: Create record:host via API in non-default network view

[ Edited ]
Adviser
Posts: 101
2234     0

I tested this successful with a network-view called testing

 

curl -k -u admin:infoblox -H "Content-Type: application/json" -X POST https://192.168.0.12/wapi/v2.7/record:host -d '{"name":"test113.test.net", "view":"default.testing", "ipv4addrs":[{"ipv4addr":"10.222.0.12"}]}'

You need the DNS zone, else it cannot be added. Host objects are DNS Objects in the first place!

 

 

Re: Create record:host via API in non-default network view

[ Edited ]
bbialek
Techie
Posts: 2
2234     0
 
Maybe there is an issue with API 2.6.1?
 
Screenshot from 2018-02-23 11-28-38.png

Re: Create record:host via API in non-default network view

Adviser
Posts: 99
2234     0

When adding from the GUI, the GUI understands you don't have a DNS zone to contain the host.  So it will uncheck the "enable in dns" option.

 

When adding from the API, you need to tell it you don't want it in DNS, otherwise a zone name is required.

 

Here's an example:

 

curl -k1 -u admin:infoblox -X POST 'https://10.9.16.6/wapi/v2.3/record:host' -H "Content-Type: application/json" -d '{ "configure_for_dns": false, "ipv4addrs":[{"configure_for_dhcp": false,"ipv4addr": "10.9.16.209"}],"name": "newhost","view": "Internal"}'

 

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You

Demo: Infoblox IPAM plug-in integration with OpenStack Newton