セカンダリIPの払い出しの予約を行い、VMのnicに割り当てたり、LVSのVIPに割り当てたりできる。
# cloudstack-api listVirtualMachines -t id,displayname,nic +--------------------------------------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | id | displayname | nic | +--------------------------------------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 508bc470-baa9-49be-1234-53bdbfd48e40 | lvs1 | [{'networkid': 'f33ad0e3-d934-1234-b002-4fc2d2c648fd', 'macaddress': '11:00:6e:4e:00:0f', 'isolationuri': 'vlan://2942', 'type': 'Isolated', 'broadcasturi': 'vlan://2942', 'traffictype': 'Guest', 'netmask': '255.255.252.0', 'ipaddress': '10.6.1.111', 'id': '6b3b825f-dca1-437c-1234-d5ac2852e757', 'networkname': 'pascal-network1', 'gateway': '10.6.0.1', 'isdefault': True}] | | 8189f435-772c-4621-1234-868d140f4029 | adm1 | [{'networkid': 'f33ad0e3-d934-1234-b002-4fc2d2c648fd', 'macaddress': '11:00:23:08:00:06', 'type': 'Isolated', 'id': 'bd59ed71-165b-1234-a12a-2cc84c219c04', 'traffictype': 'Guest', 'netmask': '255.255.252.0', 'ipaddress': '10.6.1.102', 'networkname': 'pascal-network1', 'gateway': '10.6.0.1', 'isdefault': True}] | | 862d8e91-6c98-455e-1234-1dcf4b6145f8 | web1 | [{'networkid': 'f33ad0e3-d934-1234-b002-4fc2d2c648fd', 'macaddress': '11:00:6b:24:00:03', 'isolationuri': 'vlan://2942', 'type': 'Isolated', 'broadcasturi': 'vlan://2942', 'traffictype': 'Guest', 'netmask': '255.255.252.0', 'ipaddress': '10.6.1.101', 'id': '55212871-acff-4693-1234-83edb338ef89', 'networkname': 'pascal-network1', 'gateway': '10.6.0.1', 'isdefault': True}] | +--------------------------------------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
割り当てるVMのnicのidを指定して、addIpToNicを実行
※VMを削除するとセカンダリIPも一緒に削除されるので、削除される可能性の低いVMで割り当て処理を行う
e.g. ikt-adm1
# cloudstack-api addIpToNic --nicid bd59ed71-165b-1234-a12a-2cc84c219c04 { "addiptovmnicresponse": { "jobid": "b401a50f-d8ca-4003-1234-5367c3e56461" } }
addIpToNicのレスポンスから確認したjobidを指定して、queryAsyncJobResultを実行する。
レスポンスのipaddressから払いだされたIPアドレスが確認できる。
# cloudstack-api queryAsyncJobResult --jobid b401a50f-d8ca-4003-1234-5367c3e56461 { "queryasyncjobresultresponse": { "accountid": "1c227d7a-9913-413d-1234-b0f603b22d28", "cmd": "org.apache.cloudstack.api.command.user.vm.AddIpToVmNicCmd", "created": "2015-08-03T11:04:02+0900", "jobid": "b401a50f-d8ca-4003-1234-5367c3e56461", "jobprocstatus": 0, "jobresult": { "nicsecondaryip": { "id": "f866208e-069f-4bea-1234-811dc2827a14", "ipaddress": "10.6.0.240", "networkid": "f33ad0e3-d934-4e9e-1234-4fc2d2c648fd", "nicid": "bd59ed71-165b-1234-a12a-2cc84c219c04" } }, "jobresultcode": 0, "jobresulttype": "object", "jobstatus": 1, "userid": "0cf872f3-cb52-45e4-1234-7b208b3e8c77" } }
# cloudstack-api listPublicIpAddresses -t ipaddress,id +----------------+--------------------------------------+ | ipaddress | id | +----------------+--------------------------------------+ | 210.140.56.139 | fdf10bcf-31cd-4a37-1234-9f837b73827a | +----------------+--------------------------------------+
# cloudstack-api enableStaticNat --ipaddressid fdf10bcf-31cd-4a37-1234-9f837b73827a --virtualmachineid 8189f435-772c-4621-1234-868d140f4029 --vmguestip 10.6.0.240 { "enablestaticnatresponse": { "success": "true" } }
# cloudstack-api listNics --virtualmachineid 508bc470-baa9-49be-1234-53bdbfd48e40