Infoblox Exchange Cybersecurity Roadshow 2020 – Join us!
North America | Europe | Middle East/Africa | Asia-Pacific

API & Integration

Reply
Accepted Solution

Adding domain-name for roaminghost entry

DSchmalen
Techie
Posts: 8
3384     0

Hey,

 

I'm currently trying to figure out how to set the domain-name option via WAPI for a roaminghost object. I tested 2 possibilities so far and didn't find a working solution: (I'm working with PHP and the CURL extension)

- Adding DHCP options like this ->

array("use_option" => "domain-name", "value" => $domain)

- Adding DHCP options with additional DHCP code and name like this ->

array("name" => "domain-name", "num" => "15", "use_option" => "domain-name", "value" => $domain)

Both ways didn't work. Does anyone have a working solution for this? (no matter what programming language)

 

The boolean "use_options" is set TRUE and works fine with DHCP option 12.

"use_options" => TRUE,

Anybody? Smiley Tongue

 

Kind regards,

Daniel

Re: Adding domain-name for roaminghost entry

GHorne Community Manager
Community Manager
Posts: 248
3385     0

Can you show us the complete payload you are using to modify the object ?

 

DHCP options will be an array of objects, e.g:

 

[ 
   { ’name’: ’dhcp-lease-time’,
     ’num’: 51,
     ’use_option’: True,
     ’value’: ’43200’
   }
]

 

I think you might be getting errors because you're passing name-value pairs as individual array elements.

 

The default value of 'use_option' is TRUE, so it is kinda redundant, It only really applies when you want to do odd things like disable an option in an inheritance override.

 

The syntax for all this is described in the 'dhcpoption : DHCP option' section of the API manual.

You should be able to use either 'name' or 'num', both are not required. And if you use both, but get their names wrong, you will probably get errors.

 

 

Re: Adding domain-name for roaminghost entry

[ Edited ]
DSchmalen
Techie
Posts: 8
3385     0

Thanks for the respond. My code looks like this:

 

$query = '/roaminghost';
$postfields = array("name" => $name, 
				"mac" => $mac, 
				"match_client" => "MAC_ADDRESS", 
				"address_type" => "IPV4",								
			        "use_options" => TRUE,
				"options" => array(array("name" => "host-name", "num" => 12,"value" => $name),
array("name" => "domain-name", "num" => "15", "use_option" => "domain-name", "value" => $domain)), "comment" => $comment); $this->curl_post($query,$postfields);

The function curl_post looks like this:

private function curl_post($query,$postfields) {
			curl_setopt($this->curl, CURLOPT_POST, true);
			curl_setopt($this->curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
			curl_setopt($this->curl, CURLOPT_URL, $this->base_url . $query);
			curl_setopt($this->curl, CURLOPT_POSTFIELDS, json_encode($postfields));		
			$this->set_curl_response = curl_exec($this->curl);
			$this->set_curl_info_http_code = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
		}

 

Does this help?

 

Usually the domain-name is inherited by the grid, but for roaminghosts I want to overwrite this inheritance by passing manually a domain name.

Re: Adding domain-name for roaminghost entry

DSchmalen
Techie
Posts: 8
3385     0

I just fixed the problem:

 

 

$query = '/roaminghost';
$postfields = array("name" => $name, 
				"mac" => $mac, 
				"match_client" => "MAC_ADDRESS", 
				"address_type" => "IPV4",								
				"use_options" => TRUE,
				"options" => array(array("name" => "host-name", "num" => 12,"value" => $name),
							    array("name" => "domain-name", "num" => 15,"value" => $domain)),
				"comment" => $comment);
$this->curl_post($query,$postfields);

 

The solution was to just pass the dhcp option 15 without any special marking like it is stated in the WAPI docs. So like any other dhcp option too you have to pass the name, the numerical value (check RF2131) and the value you want to insert.

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You