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

How to Create reservations with REST and PowerShell

New Member
Posts: 3
13105     0

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.

Re: How to Create reservations with REST and PowerShell

Adviser
Posts: 181
13105     0

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

New Member
Posts: 3
13105     0

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

Adviser
Posts: 181
13105     0

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

New Member
Posts: 3
13105     0

Thanks, that looks like something I recognise and can put into our environment. :-)

Re: How to Create reservations with REST and PowerShell

[ Edited ]
Guru
Posts: 26
13106     0

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

New Member
Posts: 1
13106     0

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.

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You