- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
How to Create reservations with REST and PowerShell
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 09:37 AM
Instead of creating Host entries, we create IPv4 reservations - Data Management->DHCP->SubNet->Add->Reservation
I would like to do this via PowerShell but have been unable to find anything that explains how to do it.
Reading the code in the most excellent module "Posh-IBWAPI" (Available from the PowerShell gallery), as well as The Definitive Guide To Rest Examples (https://community.infoblox.com/t5/API-Integration/The-definitive-list-of-REST-examples/td-p/1214) I have figured out a lot about how to manipulate Infoblox with REST; except for how to create IPv4 DHCP Reservations.
I realise this could also be a case of not knowing the terminology as I am not super au fait with Infoblox.
Any direct links to this specific information or code examples would be very much appreciated.
Solved! Go to Solution.
Re: How to Create reservations with REST and PowerShell
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2019 03:06 AM
Hi,
You can do this by creating a fixed address reservation.
Here is a sample curl command. You can modify it according to your need.
curl -k -u admin:Infoblox -H 'content-type: application/json' -X POST "https://127.0.0.1/wapi/v2.9/fixedaddress?_return_fields%2B=ipv4addr,mac&_return_as_object=1" -d '{"ipv4addr":"172.26.1.200","mac":"00:00:00:00:00:00"}'
Hope this is helpful,
Krishna
Re: How to Create reservations with REST and PowerShell
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2019 04:00 AM
Hi Kvasudevan,
Thanks, but as I don't know curl, it isn't really useful for me, but thanks for trying.
Re: How to Create reservations with REST and PowerShell
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2019 04:04 AM
Hi,
Here is a powershell code snippet
$url = "https://127.0.0.1/wapi/v2.9/fixedaddress?_return_fields%2B=ipv4addr,mac&_return_as_object=1" $pwd = ConvertTo-SecureString "Infoblox" -AsPlainText -Force $creds = New-Object Management.Automation.PSCredential ('admin', $pwd) $reservation_details = @{ ipv4addr="172.26.1.100" mac="00:00:00:00:00:00"} $body = $reservation_details | ConvertTo-Json Invoke-RestMethod -Uri $url -Method POST -Credential $creds -ContentType 'application/json' -Body $body
Re: How to Create reservations with REST and PowerShell
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2019 07:03 AM
Thanks, that looks like something I recognise and can put into our environment. :-)
Re: How to Create reservations with REST and PowerShell
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 05:17 AM - edited 06-23-2020 05:17 AM
How would one add Extensible Attibutes to this script. Assume EA1 = a number 999, and EA2 = "text"
Re: How to Create reservations with REST and PowerShell
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 12:06 PM
In case anyone is looking for the same thing I was in the future, which was how to create IPv4 Reservations instead of an IPv4 fixed address reservation, you just need to exclude the option 'mac' and replace it with match_client = 'RESERVED.' So use the same code that was posted in the previous post, but $reservation_details should look like this:
$reservation_details = @{ ipv4addr="172.26.1.100" match_client="RESERVED"}
Hope that helps.