Div | ||
---|---|---|
| ||
API Deploy in Public Cloud Tutorial |
...
class | tocc |
---|
Table of Contents |
---|
This simple walkthrough shows how to deploy in a scenario in AWS where a virtual datacenter and a template exist for the public cloud region. The user role in this example is a plain user. The privileges needed are displayed for every query.
...
Get all Virtual Datacenters
...
API Roles required
Code Block | ||
---|---|---|
| ||
* This action requires the privileges AUTHENTICATED, VDC_ENUMERATE
|
cURL:
Code Block |
---|
curl -X GET https://example.com/api/cloud/virtualdatacenters \
-H 'Accept:application/vnd.abiquo.virtualdatacenters+json;version=4.2' \
-u user:password --verbose |
Success status code: 200
Request payload:
--none--
Response payload:
The response to this query is a collection of virtual datacenters but in this case, there is only one virtual datacenter.
Expand | ||
---|---|---|
| ||
|
A virtual datacenter contains virtual appliances. It is the root resource of all the virtual appliances that belong to that virtual datacenter. The Abiquo UI automatically creates a VApp when you create or synchronize a VDC, but if you use the API to create the VDC, you will need to create your own VApp from the virtualappliances link. The only data you need to supply is the name, and of course you can supply an optional icon.
Optionally create a Virtual Appliance
Div | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||
API Roles required:
cURL:
Success status code: 201 Request payload:
Response payload:
|
Next we can determine which templates are available to deploy in our virtual datacenter.
...
Get all the templates from the repository that are compatible with your virtual datacenter. In this example we only show one virtual machine template.
...
API Roles required:
Code Block | ||
---|---|---|
| ||
* This action requires the privilege VDC_ENUMERATE,VDC_MANAGE,VDC_MANAGE_VAP
|
cURL:
Code Block |
---|
curl -X GET https://example.com/api/cloud/virtualdatacenters/490/action/templates
-H 'Accept:application/vnd.abiquo.virtualmachinetemplates+json;version=4.2' \
-u user:password --verbose |
Success status code: 200
Request payload:
--none--
Response payload:
Expand | ||
---|---|---|
| ||
|
Create the Virtual Machine
...
So we will send a POST request with the VM object to the virtual machines link of the virtual appliance. Remember that until we deploy, the VM only exists in Abiquo – we haven't launched the VM in AWS yet.
...
...
class | widecode tinycode |
---|
cURL:
Code Block |
---|
curl -X POST https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines \
-H 'Accept:application/vnd.abiquo.virtualmachine+json; version=4.2' \
-H 'Content-Type:application/vnd.abiquo.virtualmachine+json; version=4.2' \
-d @requestpayload.xml \
-u user:password --verbose |
Success status code: 201
Request payload:
Code Block |
---|
{
"links": [
{
"href": "https://example.com:443/api/admin/enterprises/65",
"rel": "enterprise"
},
{
"href": "https://example.com:443/api/admin/enterprises/65/datacenterrepositories/2/virtualmachinetemplates/1168",
"rel": "virtualmachinetemplate"
},
{
"href": "https://example.com:443/api/cloud/locations/2/hardwareprofiles/3078",
"rel": "hardwareprofile"
}
]
} |
Response payload:
Expand | ||
---|---|---|
| ||
|
Deploy
Then we can either deploy the virtual machine or the virtual appliance using the links in the corresponding entity. For example, in the virtual machine above, the deploy link is:
...
Deploy a Virtual Machine
...
| ||
Code Block | ||
---|---|---|
| ||
* This action requires the privilege VAPP_DEPLOY_UNDEPLOY
|
cURL:
Code Block |
---|
curl -X POST https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines/6376/action/deploy \
-H 'Accept:application/vnd.abiquo.acceptedrequest+json;version=4.2' \
-u user:password --verbose |
Success status code: 202
Request payload:
--none--
Response payload:
Code Block |
---|
{
"message": "You can keep track of the progress in the link",
"links": [
{
"rel": "status",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines/6376/tasks/8ceb8256-6599-45f2-8989-e2d8e507c41a"
}
]
} |
Undeploy a Virtual Machine
And undeploy:
...
Code Block | ||
---|---|---|
| ||
* This action requires the privilege VAPP_DEPLOY_UNDEPLOY
curl -X POST http://example.com:9000/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines/6376/action/undeploy \
-H 'Accept:application/vnd.abiquo.acceptedrequest+json; version=4.2' \
-H 'Content-Type:application/vnd.abiquo.virtualmachinetask+json; version=4.2' \
-d @requestpayload.json \
-u user:password --verbose
|
The request payload should be the standard virtual machine task entity
Code Block |
---|
{
"forceVdcLimits": false,
"forceEnterpriseSoftLimits": false,
"forceUndeploy": false,
"links": []
} |
Code Block | ||
---|---|---|
| ||
{
"message": "You can keep track of the progress in the link",
"links": [
{
"rel": "status",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines/6376/tasks/cec70487-6d29-4fde-b6ef-e3488f5fe239"
}
]
} |
Check Progress
We can query the progress using:
...
Code Block | ||
---|---|---|
| ||
* This action requires the privilege VAPP_CUSTOMISE_SETTINGS
curl -X GET https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines/6376/tasks/cec70487-6d29-4fde-b6ef-e3488f5fe239 \
-H 'Accept:application/vnd.abiquo.task+json; version=4.2' \
-u user:password --verbose |
Here the undeploy task finished successfully
Expand | ||
---|---|---|
|