Introducing SOC Insights for BloxOne Threat Defense: Boost your SOC efficiency with AI-driven insights to eliminate manual work and accelerate investigation and response times. Read the blog announcement here.

API & Integration, DevOps,NetOps,SecOps

Reply

Allocate ip issue - invalid network/range specified

New Member
Posts: 2
2526     0

I got error while integrate with tool  through infoblox and it say invalid network/range specified

 

wrapper.add_host_record_for(host_fqdn, 'func:nextavailableip:{}'.format(network.ipam_network.network_ref))\n
File \"./src/ipam/infoblox/infoblox_wrapper.py\", line 204, in add_host_record_for\n
File \"./src/ipam/infoblox/infoblox_wrapper.py\", line 181, in add_host_record\n
File \"./src/ipam/infoblox/infoblox_wrapper.py\", line 58, in _run_post_command\n
Exception: Infoblox return code: 400, response text: { \"Error\": \"AdmConProtoError: Invalid network/range specified in ipv4addr (func:nextavailableip:network/ZG5zLm5ldHdvcmskMTcyLjI3LjE2MS40OC8yOC8w:172.27.161.48/28/default)\", \n
\"code\": \"Client.Ibap.Proto\", \n
\"text\": \"Invalid network/range specified in ipv4addr (func:nextavailableip:network/ZG5zLm5ldHdvcmskMTcyLjI3LjE2MS40OC8yOC8w:172.27.161.48/28/default)\"\n}"}

Re: Allocate ip issue - invalid network/range specified

Adviser
Posts: 181
2527     0

Hi,

 

Could you please ensure that the Reference ID you are passing is accurate?

 

Also it would help if you could post your code here for debugging.

 

This is the command I use and it goes through fine.

Sample Code:

curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://grid-master/wapi/v2.11/record:host?_return_fields%2B=name,ipv4addrs&_return_as_object=1 " -d '{"name":"wapi.info.com","ipv4addrs":[{"ipv4addr":"func:nextavailableip:network/ZG5zLm5ldHdvcmskMTkyLjE2OC4xLjAvMjQvMA:192.168.1.0/24/default "}]}'

Output:

{"result": {"_ref": "record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5pbmZvLndhcGk:wapi.info.com/default", "ipv4addrs": [{"_ref": "record:host_ipv4addr/ZG5zLmhvc3RfYWRkcmVzcyQuX2RlZmF1bHQuY29tLmluZm8ud2FwaS4xOTIuMTY4LjEuMS4:192.168.1.5/wapi.info.com/default", "configure_for_dhcp": false, "host": "wapi.info.com", "ipv4addr": "192.168.1.5" }], "name": "wapi.info.com", "view": "default" }}

Re: Allocate ip issue - invalid network/range specified

New Member
Posts: 2
2527     0

"""
Provided in this module are the 6 signature methods that define interactions with Infoblox.
"""


def is_hostname_valid(infoblox, server):
"""
Call out to Infoblox to verify that a given hostname is not already in use.

Code defined here will be executed at the Pre-Create Resource trigger point.
"""
wrapper = infoblox.get_api_wrapper()
host = wrapper.get_host_by_name(server.hostname)
return host is None


def allocate_ip(infoblox, server, network):
"""
Call out to Infoblox to allocate an IP address for a given hostname.
The return value from this function can be 'dhcp'.

Code defined here will be executed at the Pre-Create Resource trigger point.
"""
ip = None
wrapper = infoblox.get_api_wrapper()
host_fqdn = '{}.{}'.format(server.hostname + "." + server.dns_domain, network.dns_domain)
wrapper.add_host_record_for(host_fqdn, 'func:nextavailableip:{}'.format(network.ipam_network.network_ref))

#host_record = wrapper.get_host_by_name(server.hostname)
#host_record = wrapper.get_records(server.hostname + "." + server.dns_domain)
host_record = wrapper.get_records(server.hostname + "." + server.dns_domain, view='default', record_type='a')
if host_record:
host_ipv4addrs = host_record['ipv4addrs']
ip = host_ipv4addrs[0]['ipv4addr']

return ip


def setup_dhcp_for_host(infoblox, hostname, mac_address):
"""
Code defined here will be executed at the Pre-Network Configuration trigger point.
"""
wrapper = infoblox.get_api_wrapper()
wrapper.setup_dhcp_for_host(hostname, mac_address)


def restart_dhcp_service(infoblox):
"""
Code defined here will be executed at the Pre-Network Configuration trigger point.
"""
wrapper = infoblox.get_api_wrapper()
wrapper.restart_dhcp_service()


def delete_host(infoblox, host_fqdn):
"""
Call out to Infoblox to remove a host record and free up that hostname/IP.

Code defined here will be executed at the Post-Decomission trigger point.
"""
wrapper = infoblox.get_api_wrapper()
wrapper.delete_host_record(host_fqdn)

Showing results for 
Search instead for 
Did you mean: 

Recommended for You