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.
...
VDC_ENUMERATE
VAPP_CUSTOMISE_SETTINGS
ENTERPRISE_ENUMERATE
VDC_MANAGE_VAPP
VAPP_DEPLOY_UNDEPLOY
AUTHENTICATED
Preparation
First we retrieve the virtual datacenter that will be used. From this we will need the links with rel enterprise and virtualappliances. We will create a new virtual appliance in the virtual datacenter. And we also need the hypervisorType of the virtual datacenter.
Then we will retrieve the enterprise, in order to access the repository and the and the virtual machine templatestemplates for the hypervisor of the virtual datacenter. To create the new virtual machine, we will take the virtual appliance and add the templates for the new new virtual machines.
Get all virtual datacenters
Tip |
---|
...
API Documentation For the Abiquo API documentation of this feature, see Abiquo API Resources and the page for this resource VirtualDatacenterResource. |
API roles required
...
GET all virtual datacenters
Code Block |
---|
* This action requires the privileges AUTHENTICATED, VDC_ENUMERATE |
...
Optionally create a virtual appliance
Tip |
---|
...
API Documentation For the Abiquo API documentation of this feature, see Abiquo API Resources and the page for this resource VirtualApplianceResource. |
...
...
API roles required:
...
CREATE a virtual appliance
Code Block |
---|
* This action requires the privilege VDC_MANAGE_VAPP
|
cURL:
Code Block |
---|
curl -X POST https://example.com/api/cloud/virtualdatacenters/490/virtualappliances \
-H 'Accept:application/vnd.abiquo.virtualappliance+json; version=4.2' \
-H 'Content-Type:application/vnd.abiquo.virtualappliance+json; version=4.2' \
-d @requestpayload.xml \
-u user:password --verbose |
Success status code: 201
Request payload:
Code Block |
---|
{
"name":"vapp_vdc_m01j_001",
"iconUrl":"https://upload.wikimedia.org/wikipedia/commons/a/af/Tux.png"
} |
Response payload:
Code Block |
---|
{
"id":836,
"error":0,
"highDisponibility":0,
"name":"vapp_vdc_m01j_001",
"publicApp":0,
"state":"NOT_DEPLOYED",
"iconUrl":"https://upload.wikimedia.org/wikipedia/commons/a/af/Tux.png",
"notAllocatedVirtualMachines":0,
"onVirtualMachines":0,
"offVirtualMachines":0,
"pausedVirtualMachines":0,
"allocatedVirtualMachines":0,
"configuredVirtualMachines":0,
"unknownVirtualMachines":0,
"lockedVirtualMachines":0,
"links":[
{
"title":"vapp_vdc_m01j_001",
"rel":"edit",
"type":"application/vnd.abiquo.virtualappliance+json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836"
},
{
"title":"vdc_m01j",
"rel":"virtualdatacenter",
"type":"application/vnd.abiquo.virtualdatacenter+json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490"
},
{
"title":"AWS_enterprise_forBilling",
"rel":"enterprise",
"type":"application/vnd.abiquo.enterprise+json",
"href":"https://example.com:443/api/admin/enterprises/65"
},
{
"title":"virtual machines",
"rel":"virtualmachines",
"type":"application/vnd.abiquo.virtualmachines+json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines"
},
{
"title":"virtual appliances state",
"rel":"state",
"type":"application/vnd.abiquo.virtualappliancestate+json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/state"
},
{
"title":"undeploy",
"rel":"undeploy",
"type":"application/vnd.abiquo.acceptedrequest+json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/action/undeploy"
},
{
"title":"deploy",
"rel":"deploy",
"type":"application/vnd.abiquo.acceptedrequest+json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/action/deploy"
},
{
"title":"price",
"rel":"price",
"type":"text/plain",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/action/price"
},
{
"title":"layers",
"rel":"layers",
"type":"application/vnd.abiquo.layers+json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/layers"
},
{
"title":"alerts",
"rel":"alerts",
"type":"application/vnd.abiquo.alerts+json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/alerts"
},
{
"title":"spec",
"rel":"spec",
"type":"application/vnd.abiquo.virtualappliancespec+json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/action/spec"
},
{
"title":"tasks",
"rel":"tasks",
"type":"application/vnd.abiquo.tasks+json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/tasks"
},
{
"title":"scalinggroups",
"rel":"scalinggroups",
"type":"application/vnd.abiquo.scalinggroups+json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/scalinggroups"
},
{
"title":"metricsmetadata",
"rel":"metricsmetadata",
"type":"application/vnd.abiquo.metricsmetadata+json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/metrics"
},
{
"title":"collectd",
"rel":"collectd",
"type":"application/json",
"href":"https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/metrics/collectd"
}
]
} |
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.
Tip | |
---|---|
title | API Documentation For the Abiquo API documentation of this feature, see Abiquo API Resources and the page for this resource VirtualMachineTemplateResource. |
API Roles required:
...
GET all of the virtual machine templates that are compatible with KVM
Code Block |
---|
* This action requires the privilege VDC_ENUMERATE,VDC_MANAGE,VDC_MANAGE_VAP |
...
Now we will create the virtual machine. To do this, you will need:
the virtual machines link from the virtual appliance you created
Code Block |
---|
https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines |
the "edit" link to the compatible template (from the previous step). Note that the link here is in the template format. Change the rel entry from "edit" to "virtualmachinetemplate" to use it to create the virtual machine
Code Block |
---|
{ "title": "amzn-ami-hvm-2015.03.0.x86_64-gp2", "rel": "edit", "type": "application/vnd.abiquo.virtualmachinetemplate+json", "href": "https://example.com:443/api/admin/enterprises/65/datacenterrepositories/2/virtualmachinetemplates/1168" }, |
a "hardwareprofile" link for one of the hardware profiles allowed for the template
Code Block |
---|
{ "title": "t2.micro", "rel": "hardwareprofile", "type": "application/vnd.abiquo.hardwareprofile+json", "href": "https://example.com:443/api/cloud/locations/2/hardwareprofiles/3078" }, |
...
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.
Tip |
---|
...
API Documentation For the Abiquo API documentation of this feature, see Abiquo API Resources and the page for this resource VirtualMachineResource. |
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 |
...
Then we can either deploy the virtual machine VM or the virtual appliance using the links in the corresponding entity. For example, in from the virtual machine above VM, the deploy link is:
Code Block |
---|
{ "title": "virtual machine deploy", "rel": "deploy", "type": "application/vnd.abiquo.acceptedrequest+json", "href": "https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines/6376/action/deploy" }, |
Deploy a virtual machine
Tip |
---|
...
API Documentation For the Abiquo API |
...
documentation of this feature, see Abiquo API Resources and the pages for this resource VirtualMachineResource and VirtualApplianceResource. |
...
DEPLOY a virtual machine
Code Block |
---|
* This action requires the privilege VAPP_DEPLOY_UNDEPLOY |
...
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:
...
UNDEPLOY a virtual machine
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 |
The newly created task
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" } ] } |
...
We can query the progress using:
...
...
The task
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
Code Block |
---|
{ "taskId": "cec70487-6d29-4fde-b6ef-e3488f5fe239", "userId": "10", "type": "UNDEPLOY", "ownerId": "6376", "state": "FINISHED_SUCCESSFULLY", "creationTimestamp": 1519922809, "timestamp": 1519922843, "jobs": { "links": [], "collection": [ { "id": "cec70487-6d29-4fde-b6ef-e3488f5fe239.51224d77-a9d0-4384-aedb-f9efa795c742", "parentTaskId": "cec70487-6d29-4fde-b6ef-e3488f5fe239", "type": "DECONFIGURE", "description": "Undeploy task's deconfigure on virtual machine with id 6376", "state": "DONE", "rollbackState": "UNKNOWN", "creationTimestamp": 1519922809, "timestamp": 1519922842, "links": [] }, { "id": "b5eaf47e-1a21-4d3b-8c98-a0514eb4334d", "parentTaskId": "cec70487-6d29-4fde-b6ef-e3488f5fe239", "type": "FREE_RESOURCES", "description": "FRE-OK - Free resources OK", "state": "DONE", "rollbackState": "UNKNOWN", "creationTimestamp": 1519922809, "timestamp": 1519922843, "links": [] } ] }, "links": [ { "rel": "self", "href": "https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines/6376/tasks/cec70487-6d29-4fde-b6ef-e3488f5fe239" }, { "rel": "parent", "href": "https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines/6376/tasks" }, { "rel": "result", "type": "application/vnd.abiquo.virtualmachine+json", "href": "https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines/6376" }, { "title": "cloudadmin", "rel": "user", "type": "application/vnd.abiquo.user+json", "href": "https://example.com:443/api/admin/enterprises/65/users/10" }, { "title": "ABQ_ee11c510-026b-4000-af9f-2c876cdeba46", "rel": "virtualmachine", "type": "application/vnd.abiquo.virtualmachine+json", "href": "https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances/836/virtualmachines/6376" } ] } |