Reply
Highlighted

How to set the Domain Name of a network through API

zhiz
Techie
Posts: 2
2374     0

Hi, I can create network view and add network through API.

However, to make our system work, we need to set the Domian Name (in the IPV4 DHCP options) of the network just added.

Is there an API call to do that?

In addition, can we add a Zone in DNS through API?

Thanks in advance.

Re: How to set the Domain Name of a network through API

[ Edited ]
hvictor
Techie
Posts: 1
2375     0

First time response!  Hope this helps..

 

Was finally able to add a DHCP Router in the IP DHCP Options via WAPI!  Figure it shouldn't be far off from where you are wanting to go.  Please, just use this as a means to an end and not an actual solution!

 

Here is the Code:

(The Java Boolean got me!  Remember it's true not True!!)

(Needed to google building a java Array filled with hashes for the $json value)

 

use strict;

use Data:Smiley Very Happyumper;
use JSON;
use LWP;
use LWP:Smiley Frustratedimple;
use POSIX qw(strftime);

 

...

 

my $json = '{
"options":
[
{
"value": "1.1.1.1",
"vendor_class": "DHCP",
"name": "routers",
"use_option": true
}
]
}';


my $req = HTTP::Request->new(PUT => $baseURI . 'network/ZG5zLm5ldHdvcmskMTAuMTY5EyLjAvMjYvMTk5'); #This _ref was manually updated in this script, format was important.
$req->authorization_basic($username, $passwd);
$req->header('Content-Type' => 'application/json');
$req->content($json);
$agent->request($req)->as_string;

#print Dumper($req);
#exit;

my $r = $agent->request($req);
print "Provisioned $name and default gateway : " . $r->content;

 

I hope this helps your endeavour.  

Showing results for 
Search instead for 
Do you mean 

Recommended for You

This widget could not be displayed.

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin

" class="expert-of-month-image"/>