Assign IP Address to VS

To assign an IP address to a virtual server, use the following request:

POST /virtual_machines/:virtual_machine_id/ip_addresses.xml
POST /virtual_machines/:virtual_machine_id/ip_addresses.json

XML Request Example

curl -i -X POST -H 'Accept: application/xml' -H 'Content-type: application/xml' -u user:userpass -d '<ip_address><address>5.1.1.10</address><network_interface_id>84</network_interface_id><ip_net_id>147</ip_net_id><ip_range_id>210</ip_range_id><used_ip>1</used_ip></ip_address>' --url http://onapp.test/virtual_machines/12/ip_addresses.xml

JSON Request Example

curl -i -X POST -H 'Accept: application/json' -H 'Content-type: application/json' -u user:userpass -d '{"ip_address": {"network_interface_id": 86,"ip_net_id":"999","ip_range_id":"205","ip_version":6}}' --url http://onapp.test/virtual_machines/12/ip_addresses.json


Where:

ip_address - the array of parameters to allocate an IP address to VS

address - enter an IP address that you want to assign to VS

network_interface_id* - specify an ID of a network interface the IP address should be assigned to

ip_net_id - specify an ID of the IP net from which the IP address should be assigned

ip_range_id - specify an ID of the IP range from which the IP address should be assigned

used_ip - set to "1" to assign a used IP address, otherwise, set to "0"

own_ip - set to "1" to assign an IP address assigned to the current user, otherwise, set to "0"

ip_version - the version of the protocol that can be set to "6" for IPv6 or to "4" for IPv4

If you set an IPv6 or IPv4 version, the IP address is allocated automatically so you can skip the address parameter in the request.


Page History

v.5.10

  • added the ip_net_id and ip_range_id parameters

v. 5.9

  • added the ip_version parameter to automatically allocate an IPv6 or IPv4 address

v. 5.4

  • the ip_address_id parameter has been changed to address and it now accepts the full IP address