Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
IPv4 address reserve creation is not working
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2021 04:38 AM
1851     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
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2021 11:16 PM
1852     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",