Deploy a VM in public cloud using the API
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.
Privileges required
See privilege definitions.
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 virtual machine templates 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 virtual machines.Â
Get all virtual datacenters
Â
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
* This action requires the privileges AUTHENTICATED, VDC_ENUMERATE
cURL:
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.
{
"links": [
{
"rel": "first",
"href": "https://example.com:443/api/cloud/virtualdatacenters?limit=25&by=name&asc=true"
},
{
"rel": "last",
"href": "https://example.com:443/api/cloud/virtualdatacenters?startwith=0&limit=25&by=name&asc=true"
}
],
"collection": [
{
"id": 490,
"hypervisorType": "AMAZON",
"name": "vdc_m01j",
"network": {
"id": 572,
"name": "default_private_network",
"address": "192.168.0.0",
"mask": 24,
"gateway": "192.168.0.1",
"primaryDNS": "10.60.1.4",
"secondaryDNS": "8.8.8.8",
"sufixDNS": "",
"defaultNetwork": false,
"type": "INTERNAL",
"dhcpOptions": {
"links": [],
"collection": []
},
"ipv6": false,
"strict": false,
"providerId": "subnet-6a292931",
"restricted": false,
"internetGatewayRole": false,
"ipRanges": [
{
"firstIp": "192.168.0.5",
"lastIp": "192.168.0.253"
}
],
"excludedFromFirewall": false,
"links": [
{
"title": "vdc_m01j",
"rel": "virtualdatacenter",
"type": "application/vnd.abiquo.virtualdatacenter+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490"
},
{
"title": "default_private_network",
"rel": "edit",
"type": "application/vnd.abiquo.vlan+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/privatenetworks/572"
},
{
"title": "ips",
"rel": "ips",
"type": "application/vnd.abiquo.privateips+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/privatenetworks/572/ips"
},
{
"title": "eu-west-1c",
"rel": "availabilityzone",
"type": "application/vnd.abiquo.availabilityzone+json",
"href": "https://example.com:443/api/cloud/locations/2/availabilityzones/eu-west-1c"
},
{
"title": "load balancers",
"rel": "loadbalancers",
"type": "application/vnd.abiquo.loadbalancers+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/privatenetworks/572/loadbalancers"
},
{
"title": "configuration",
"rel": "configuration",
"type": "application/vnd.abiquo.networkconfiguration+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/privatenetworks/572/configuration"
},
{
"title": "192.168.0.0/24",
"rel": "network_configuration",
"type": "application/vnd.abiquo.networkconfiguration+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/privatenetworks/572/configuration/572"
}
]
},
"providerId": "vpc-04df7462",
"syncState": "NONE",
"links": [
{
"title": "vdc_m01j",
"rel": "edit",
"type": "application/vnd.abiquo.virtualdatacenter+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490"
},
{
"title": "private networks",
"rel": "privatenetworks",
"type": "application/vnd.abiquo.vlans+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/privatenetworks"
},
{
"title": "public networks",
"rel": "network",
"type": "application/vnd.abiquo.vlans+json",
"href": "https://example.com:443/api/admin/datacenters/2/network"
},
{
"title": "default_private_network",
"rel": "defaultvlan",
"type": "application/vnd.abiquo.vlan+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/privatenetworks/572"
},
{
"title": "AWS_enterprise_forBilling",
"rel": "enterprise",
"type": "application/vnd.abiquo.enterprise+json",
"href": "https://example.com:443/api/admin/enterprises/65"
},
{
"title": "virtual appliances",
"rel": "virtualappliances",
"type": "application/vnd.abiquo.virtualappliances+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/virtualappliances"
},
{
"title": "private ips",
"rel": "privateips",
"type": "application/vnd.abiquo.privateips+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/action/privateips"
},
{
"title": "external ips",
"rel": "externalips",
"type": "application/vnd.abiquo.externalips+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/action/externalips"
},
{
"title": "unmanaged ips",
"rel": "unmanagedips",
"type": "application/vnd.abiquo.unmanagedips+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/action/unmanagedips"
},
{
"title": "default vlan",
"rel": "defaultvlan",
"type": "application/vnd.abiquo.vlan+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/action/defaultvlan"
},
{
"title": "volumes",
"rel": "volumes",
"type": "application/vnd.abiquo.volumes+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/volumes"
},
{
"title": "disks",
"rel": "disks",
"type": "application/vnd.abiquo.harddisks+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/disks"
},
{
"title": "ips to purchase",
"rel": "topurchase",
"type": "application/vnd.abiquo.publicips+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/publicips/topurchase"
},
{
"title": "ips purchased",
"rel": "purchased",
"type": "application/vnd.abiquo.publicips+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/publicips/purchased"
},
{
"title": "stateful volumes",
"rel": "statefulcandidates",
"type": "application/vnd.abiquo.volumes+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/volumes/action/statefulcandidates"
},
{
"title": "tiers",
"rel": "tiers",
"type": "application/vnd.abiquo.tiers+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/tiers"
},
{
"title": "available templates",
"rel": "templates",
"type": "application/vnd.abiquo.virtualmachinetemplates+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/action/templates"
},
{
"title": "all virtual machines",
"rel": "virtualmachines",
"type": "application/vnd.abiquo.virtualmachines+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/action/virtualmachines"
},
{
"title": "eu-west-1",
"rel": "region",
"type": "application/vnd.abiquo.region+json",
"href": "https://example.com:443/api/config/hypervisortypes/AMAZON/regions/eu-west-1"
},
{
"title": "amazon-device",
"rel": "device",
"type": "application/vnd.abiquo.device+json",
"href": "https://example.com:443/api/cloud/locations/2/devices/1"
},
{
"title": "firewalls",
"rel": "firewalls",
"type": "application/vnd.abiquo.firewallpolicies+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/firewalls"
},
{
"title": "load balancers",
"rel": "loadbalancers",
"type": "application/vnd.abiquo.loadbalancers+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/loadbalancers"
},
{
"title": "000AmazonDC-IReland",
"rel": "location",
"type": "application/vnd.abiquo.publiccloudregion+json",
"href": "https://example.com:443/api/cloud/locations/2"
},
{
"title": "tasks",
"rel": "tasks",
"type": "application/vnd.abiquo.tasks+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/tasks"
},
{
"title": "location limit",
"rel": "limit",
"type": "application/vnd.abiquo.limit+json",
"href": "https://example.com:443/api/admin/enterprises/65/limits/199"
},
{
"title": "externalnetworks",
"rel": "externalnetworks",
"type": "application/vnd.abiquo.vlans+json",
"href": "https://example.com:443/api/admin/enterprises/65/limits/199/externalnetworks"
},
{
"title": "virtual appliances specs",
"rel": "vappspecs",
"type": "application/vnd.abiquo.virtualappliancespecs+json",
"href": "https://example.com:443/api/cloud/virtualdatacenters/490/vappspecs"
}
],
"diskSoftLimitInMb": 0,
"diskHardLimitInMb": 0,
"storageSoftInMb": 0,
"storageHardInMb": 0,
"vlansSoft": 0,
"vlansHard": 0,
"publicIpsSoft": 0,
"publicIpsHard": 0,
"ramSoft": 0,
"ramHard": 0,
"cpuSoft": 0,
"cpuHard": 0
}
],
"totalSize": 1
}
Â
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
Â
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
Â
cURL:
Â
Success status code: 201
Request payload:
Â
Response payload:
Â
Â
Next we can determine which templates are available to deploy in our virtual datacenter.
Get templates available to the 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 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
cURL:
Success status code: 200
Request payload:
--none--
Response payload:
Create the virtual machine
Now we will create the virtual machine. To do this, you will need:
the virtual machines link from the virtual appliance you created
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
a "hardwareprofile" link for one of the hardware profiles allowed for the template
So the resulting virtual machine object will look like this:
This is the simplest VM object required for creating a virtual machine in AWS.
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.
Â
Â
cURL:
Success status code: 201
Request payload:
Response payload:
Deploy
Then we can either deploy the VM or the virtual appliance using the links in the corresponding entity. For example, from the above VM, the deploy link is:
Deploy a virtual machine
Â
Â
DEPLOY a virtual machine
cURL:
Success status code: 202
Request payload:
--none--
Response payload:
Undeploy a virtual machine
And undeploy:
UNDEPLOY a virtual machine
The request payload should be the standard virtual machine task entity
Â
The newly created task
Check progress
Â
We can query the progress using:
The task
Here the undeploy task finished successfully
Copyright © 2006-2024, Abiquo Holdings SL. All rights reserved