Are you interested in our Early Access Program (EAP)? This program allows you to preview code, test in your lab and provide feedback prior to General Availability (GA) release of all Infoblox products. If so, please click the link here.

API & Integration, DevOps,NetOps,SecOps

Reply

IPv4 address reserve creation is not working

Member
Posts: 2
881     0

Hi team!

 

I am trying to add a ipv4 reservation to an IP address using the infoblox API. I am using the following code:

 

def reserve_ip_addr(self, address, name, comment):
		""" Implements IBA REST API call to reserve IBA IPv4 address 
		Returns None 
		:param address: IP v4 address in CIDR format without subnet
			:param name: reservation name
			:param comment: context 
		"""
		attr= lambda key, val: '"' + key + '":' + '"' + val + '"'
		extattr = lambda key, val: '"' + key + '":' + '{"value":"' + val + '"}'
		rest_url = 'https://' + self.iba_host + '/wapi/v' + self.iba_wapi_version + '/ipv4address'
		payload = '{' + attr("ipv4addr", address) + ',' + \
		attr("names", name) + \
		'}'
		# example extattrs

		#'"extattrs": {' + \
		#extattr("Editor", editor) + "," + \
		'}'
		print payload
		r = requests.post(url=rest_url, auth=(self.iba_user, self.iba_password), verify=self.iba_verify_ssl, data=str(payload))
		r_json = r.json()
		try:
			print r.json()
			if r.status_code == 200 or r.status_code == 201:
				return
			else:
				if 'text' in r_json:
					raise InfobloxGeneralException(r_json['text'])
				else:
					r.raise_for_status()
		except ValueError:
			raise Exception(r)
		except Exception:
			raise
	

I am getting the next error:

Operation create not allowed for ipv4address

 

Any suggestion?

 

Re: IPv4 address reserve creation is not working

Community Manager
Community Manager
Posts: 180
882     0

The object type you want to create is a 'fixedaddress' object. 

 

The rest_url line should look something like this;

 

		rest_url = 'https://' + self.iba_host + '/wapi/v' + self.iba_wapi_version + '/fixedaddress

for a DHCP Fixed Address, use the real client's MAC address.

 

For a DHCP Reservation, use a MAC address of all-zeros:

 

"mac": "00:00:00:00:00:00",

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You