THE GAME HAS CHANGED

Introducing Infoblox Universal DDI ManagementTM

Watch the launch to discover the new era of management for critical network services. Watch Now

API & Integration, DevOps,NetOps,SecOps

Reply

IPv4 address reserve creation is not working

New Member
Posts: 2
1946     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

Moderator
Moderator
Posts: 321
1947     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