Reply
Accepted Solution

Re-map host entires

rrajavarapu
Techie
Posts: 6
1964     0

Hello,

 

Frequently, we build new servers and assign DNS host records for each VM. While going to production they have to need to change hostnames as per our enviornment.

 

As of now we delete assigned host records and re-map those IPv4's with new host entires.  Can anyone please suggest me to edit them in a single instance.

 

Our WAPI version is v2.2.2.  Thanks in advance.

Re: Re-map host entires

[ Edited ]
MRichard Community Manager
Community Manager
Posts: 101
1964     0

Take a look at Object Body Requests.  You can do this with a single POST with multiple object methods.  The first method will be to return the host you want to update, which is stored and used for the second method, where the hostbame is upated.

Here's an example of a body request.  There are four actions:  store some values, get the host record, modify the host record, and display the saved information.

 

[{
    "method": "STATE:ASSIGN",
    "data": { "old_hostname": "oldname.example.org",
    		  "new_hostname": "newname.example.org",
    		  "dns_view": "Internal" }
 },
 {
    "method": "GET",
    "object": "record:host",
    "data": {"name": "##STATE:old_hostname:##", 
        	 "view": "##STATE:dns_view:##"
        	},
	"assign_state": {"host_ref": "_ref" },
    "enable_substitution": true,
    "discard": true
 },
 {
	"method": "PUT",
	"object": "##STATE:host_ref:##",
	"enable_substitution": true,
	"data": { "name": "##STATE:new_hostname:##"},
	"discard": true
 },
 {
    "method": "STATE:DISPLAY"
}]



Here it is, with whitespace removed and formatted as a curl command:

curl -k -u admin:infoblox -H "Content-Type: application/json"  -X POST 'https://192.168.1.2/wapi/v2.2/request' -d '[{"method":"STATE:ASSIGN","data":{"old_hostname":"oldname.example.org","new_hostname":"newname.example.org","dns_view":"Internal"}},{"method":"GET","object":"record:host","data":{"name":"##STATE:old_hostname:##","view":"##STATE:dns_view:##"},"assign_state":{"host_ref":"_ref"},"enable_substitution":true,"discard":true},{"method":"PUT","object":"##STATE:host_ref:##","enable_substitution":true,"data":{"name":"##STATE:new_hostname:##"},"discard":true},{"method":"STATE:DISPLAY"}]'

 

Re: Re-map host entires

[ Edited ]
rrajavarapu
Techie
Posts: 6
1964     0

Hi Richard,

 

Thank you for providing soultion to achieve it.  Can you also help me out in below error getting while it running via shell script. When we run from command line, it executes fine.

 

{ "Error": "AdmConProtoError: None ('NoneType' object is not iterable)",
  "code": "Server.Ibap.Internal",
  "text": "Internal Error"

 

 

The code in script is

curl -ks -u  admin:admin@123  -X POST https://infoblox.company.colo/wapi/v2.2.2/request -d '[{"method":"STATE:ASSIGN","data":{"old_hostname":"nonprd11.company.colo","new_hostname":"prd11.company.colo","dns_view":"Internal"}},{"method":"GET","object":"record:host","data":{"name":"##STATESmiley Surprisedld_hostname:##","view":"##STATE:dns_view:##"},"assign_state":{"host_ref":"_ref"},"enable_substitution":true,"discard":true},{"method":"PUT","object":"##STATE:host_ref:##","enable_substitution":true,"data":{"name":"##STATE:new_hostname:##"},"discard":true},{"method":"STATESmiley Very HappyISPLAY"}]'

Re: Re-map host entires

MRichard Community Manager
Community Manager
Posts: 101
1964     0

You need to update the HTTP header to specify JSON content in the body.   For example, with curl, include:

 

-H "Content-Type: application/json"

 

in the curl command.

 

 

When I ran it without that, it gave the same error you got.

Highlighted

Re: Re-map host entires

rrajavarapu
Techie
Posts: 6
1964     0

Hello Richard,

 

Thank you.  This time it throws some other error, which seems my object has multiple results.

 

{ "Error": "AdmConProtoError: The operation returned an empty list ([]) assign_state is supported only when the result operation returns a single result.",
  "code": "Client.Ibap.Proto",
  "text": "The operation returned an empty list ([]) assign_state is supported only when the result operation returns a single result."

Re: Re-map host entires

[ Edited ]
MRichard Community Manager
Community Manager
Posts: 101
1965     0

I think it's more likely your search returned zero results, since you are doing an exact match and host records are required to be unique.

Re: Re-map host entires

rrajavarapu
Techie
Posts: 6
1965     0

Hi,

 

The host records are different.

 

nonprd11.company.colo

prd11.company.colo

Showing results for 
Search instead for 
Do you mean 

Recommended for You