...
To capture a VM using the API:
Retrieve the virtual appliance that the VM will be captured into
Retrieve the VM with resources from the hypervisor in Abiquo
Retrieve the network addresses from the platform and add them to the VM object
Send a POST request with the VM object to virtual machines URL of the virtual appliance
Retrieve the virtual appliance
...
Tip |
---|
If you don't have the link to virtual appliances, firstĀ List virtual datacenters, and look for the "href" value of the virtualappliances link |
Code Block |
---|
curl -X GET https://example.com/api/cloud/virtualdatacenters/2/virtualappliances \
-H 'Accept:application/vnd.abiquo.virtualappliances+json; version=4.2' \
-u user:password --verbose |
From the virtual appliance objects, look for your virtual appliance, and find the virtualmachines link.
...
Code Block |
---|
curl -X GET https://example.com/api/admin/datacenters/4/racks/4/machines/2/virtualmachines?sync=true \ -H 'Accept:application/vnd.abiquo.virtualmachines+json; version=4.2' \ -u user:password --verbose |
Then search for your VM in the response and obtain the "virtualmachine" link
Expand | ||
---|---|---|
|
...
Code Block |
---|
curl -X GET https://example.com/api/admin/datacenters/4/racks/4/machines/2/virtualmachines/265?sync=true \ -H 'Accept:application/vnd.abiquo.virtualmachineflat+json; version=4.2' \ -u user:password --verbose |
This is our base virtualmachine flat object and as you can see there is no IP address for the NIC, so we will add that next.
Expand | ||
---|---|---|
|
...
Code Block |
---|
{ "title": "external networks", "rel": "externalnetworks", "type": "application/vnd.abiquo.vlans+json", "href": "https://example.com:443/api/admin/enterprises/2/limits/5/externalnetworks" }, |
Then perform a get request to retrieve the external networks.
Code Block |
---|
curl -X GET https://example.com/api/admin/enterprises/2/limits/5/externalnetworks \ -H 'Accept:application/vnd.abiquo.vlans+json; version=4.2' \ -u user:password --verbose |
...
Code Block |
---|
curl -X GET https://example.com/api/admin/enterprises/2/limits/5/externalnetworks/7/ips \ -H 'Accept:application/vnd.abiquo.externalips+json; version=4.2' \ -u user:password --verbose |
Expand | |
---|---|
|
...
|
Select the IP address that you would like to add to the VM.
...
Now go back and get the virtualmachineflat object that you retrieved from the hypervisor. Find the edit link (the "rel" value will be edit and copy it to create two links. Change the "rel" value of the first link to "virtualmachine" and the second one to "imported".
Expand | ||||
---|---|---|---|---|
The original link with a "rel" value of "edit".
The two new links to replace it
|
...
Code Block |
---|
curl -X POST http://example.com/api/cloud/virtualdatacenters/2/virtualappliances/2/virtualmachines \ -H 'Accept:application/vnd.abiquo.virtualmachineflat+json; version=4.2' \ -H 'Content-Type:application/vnd.abiquo.virtualmachineflat+json; version=4.2' \ -d @requestpayload.json \ -u user:password --verbose |
The virtualmachineflat object that you should send in the requestpayload.json file should be similar to the following example.
Expand | ||
---|---|---|
|
...