Reply

Update IP status from Unused to Used

[ Edited ]
Authority
Posts: 21
3436     0

Hi All,

 

I am working on a script where i am creating VM and assigning available IP address to it given by concerend team.

Now once the IP is assigned,.

1) I have to find the status of that perticular IP address and 

   - This part i am ok. https://url/wapi/v2.10.5/ipv4address?ip_address=10.1.0.0

2) Update the status of that IP from "Unused" to "Used".

 

Can you please help me with this. Need the API request to modify the status value againest IP address

 

****************

I was trying a PUT request like below

 

https://url/wapi/v2.10.5/record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5pbmZvLndhcGlhbGlhcw:10.124.11.2/default?_return_fields%2B=aliases&_return_as_object=1" -d '{"status": ["Used"]}'

but it is giving error

{
"Error": "AdmConProtoError: Invalid value for _return_as_object: 1\" -d '{\"status\": [\"Used\"]}'",
"code": "Client.Ibap.Proto",
"text": "Invalid value for _return_as_object: 1\" -d '{\"status\": [\"Used\"]}'"
}

Re: Update IP status from Unused to Used

Adviser
Posts: 181
3436     0

Hi,

 

When you create a host record against the IP address, the status automatically changes to "USED". So you wouldn't have to change that manually.

 

You can create a host record using this API:

curl -k -u admin:pwd -H 'content-type: application/json' -X POST "https://grid-master/wapi/v2.11/record:host?_return_fields%2B=name,ipv4addrs&_return_as_object=1" -d '{"name":"host.info.com","ipv4addrs": [{"ipv4addr":"10.10.10.20"}]}'

You can also create a host record with the next available IP in a subnet. NIOS would do the check if it is used/unused.

curl -k -u admin:pwd -H 'content-type: application/json' -X POST "https://grid-master/wapi/v2.11/record:host?_return_fields%2B=name,ipv4addrs&_return_as_object=1 " -d '{"name":"wapi.info.com","ipv4addrs":[{"ipv4addr":{"_object_function":"next_available_ip","_parameters":{"exclude":["10.10.10.1","10.10.10.2"]},"_result_field":"ips","_object" : "network","_object_parameters":{"network":"10.10.10.0/24"}}}]}'

You can find more examples here.

 

Thanks & Regards,

Krishna Vasudevan

Showing results for 
Search instead for 
Did you mean: 

Recommended for You