SSO Login is being implemented on this site. Existing users: Your existing password must be reset the first time you login using SSO. Click here to reset your password first before login. Your new username will be your email.

API & Integration, DevOps,NetOps,SecOps

Reply

Create a report used/unused ips in multiples subnets

Techie
Posts: 5
257     0

Hello team,

I need to create a report to send to my customer to knwo how many ip address are free/used in every subnet.

I created a report by using splunk in Infoblox -Reporting, but I am trying to automate it.

Can I download it using API?

Like I couldn't find out how, I am trying to get how many ip address are "unused" using python + requests.

This is my code:

args = {"network": network,
"_return_fields": "status",
"status": "UNUSED"
"_return_as_object": 1
}
r = session.get(url_info + 'ipv4address', data=args)

 I don't know how to search for multiples networks. I could make a request for subnet, but I have a few hundreds.

I have read some examples but I am getting this error.

{'Error': 'AdmConProtoError: Only the POST method is supported for body-only requests.', 'code': 'Client.Ibap.Proto', 'text': 'Only the POST method is supported for body-only requests.'}

I have tried something like this:

args = [{"method": "GET",
"object": "network",
"data": {"network": "172.20.196.0/27"}},
{"method": "GET",
"object": "network",
"data": {"network": "172.20.197.32/27"}},
{"method": "GET",
"object": "network",
"data": {"network": "172.20.197.64/26"}}]

r = session.get(url_info + 'request', data=json.dumps(args))

Any advice would be welcome.

And any other suggestion would be great, I don't know if there is any other way to get free ips in a subnet.

I just need the number, not details.

I want to get these statistics and create and excel with some plots.

I would like to get this goal with python + requests.

 

Thanks,

Re: Create a report used/unused ips in multiples subnets

Techie
Posts: 5
257     0

Hello Ursula,

Thanks for your help.

This an example, I have hundreds of subnets to check.

I do not understand your idea.

Anyway, I am receiving an error.

'Error': 'AdmConProtoError: 172.20.196.0/23 does not match any network'

Re: Create a report used/unused ips in multiples subnets

Authority
Posts: 17
257     0

In your original example you are using get method to for requests object and it supports post. Also you are quering network object. The data object in below curl has the ipv4address that you should query.

 

curl --location --request POST 'https://<grid-master>/wapi/v2.12/request' \
--header 'Content-Type: application/json' \
--data-raw '[{"method": "GET",
"object": "ipv4address",
"data": {
    "network": "1.1.1.0/24",
    "status":"USED"
    }
},
{"method": "GET",
"object": "ipv4address",
"data": {
    "network": "10.10.10.0/24",
    "status":"UNUSED"
    }
},
{"method": "GET",
"object": "ipv4address",
"data": {
    "network": "11.1.1.0/24",
    "status":"UNUSED"
    }
}
]'

 

The above query should work for you and you could filter out the USED or UNUSED ips by specifying them in the request.

 

'Error': 'AdmConProtoError: 172.20.196.0/23 does not match any network'

This error gives the impression that the given network is not present in your grid

 

 

Re: Create a report used/unused ips in multiples subnets

Community Manager
Community Manager
Posts: 162
257     0

"Ursula"s message was spam, it was later modified and a URL was added.  I've marked it as such.  Sorry you got gotten.

Re: Create a report used/unused ips in multiples subnets

Techie
Posts: 5
257     0

That's it!

Thanks!!

Just one thing, Could I filter the output to get just needed fields?

It is just to get only needed fileds to speed parsing that output.

I tried adding "_return_fields" in data but I get an error.

 

Re: Create a report used/unused ips in multiples subnets

Member
Posts: 1
257     0

I think you are having this error because there no such feature is available to filter output or there no way to do it.

Re: Create a report used/unused ips in multiples subnets

Authority
Posts: 17
257     0

You can filter out the output using "_return_fields", you just need to pass it in the args along with the rest of the request body.

Below is a curl for your reference.

 

 

curl -L -X POST 'https://<grid-ip>/wapi/v2.12/request' \
-H 'Content-Type: application/json' \
--data-raw '[
    {
        "method": "GET",
        "object": "ipv4address",
        "data": {
            "network": "1.1.1.0/24",
            "status": "USED"
        },
        "args": {
            "_return_fields": "status"
        }
    },
    {
        "method": "GET",
        "object": "ipv4address",
        "data": {
            "network": "10.10.10.0/24",
            "status": "USED"
        },
        "args": {
            "_return_fields": "status,network"
        }
    }
]'

Re: Create a report used/unused ips in multiples subnets

Techie
Posts: 5
257     0

Hello shukran,

I created the request like this:

{'args': {'_return_fields': 'status'},
'data': {'network': '10.71.80.0/24', 'status': 'USED'},
'method': 'GET',
'object': 'ipv4address'}]

 

It works great and that was really was I requested, but I am getting this error:

{'Error': 'AdmConProtoError: Result set too large (> 1000)',
'code': 'Client.Ibap.Proto',
'text': 'Result set too large (> 1000)'}

 

I could try to chunk the list to get partial results, but I was wondering if I could just get the number of used/unused ips addresses.

I don't need all the details that I am getting for every ip address, just need to know how many ip addresses are free in every subnet.

Is there any way to achieve this?

Showing results for 
Search instead for 
Did you mean: 

Recommended for You