API create virtual datacenters and virtual machines how to
This how to describes how to create a cloud and deploy a VM. In this tutorial you will perform the tasks of the cloud administrator, enterprise administrator and enterprise user. This tutorial uses the Cloud Administrator default account and does not show proper authentication.
To perform this tutorial to create a virtual datacenter, you will need a datacenter or public cloud region, and an enterprise with permission to use it. To allow an enterprise to use a datacenter or public cloud region, edit the enterprise and add it to allowed locations or create an enterprise limit in the API. If you are working with public cloud, you should also add credentials for your enterprise.
Create a virtual datacenter
Manage virtual datacenters: Administrators create virtual datacenters to organize the infrastructure for providing the cloud service. From here they can create virtual appliances in the virtual datacenter and the Abiquo platform will deploy them to the physical infrastructure based on the Virtual machine allocation .
Get the location
You will create the virtual datacenter in an "allowed location", which is a datacenter or public cloud region that the enterprise is allowed to work with. Choose whether you want to retrieve public cloud regions or datacenters and use the appropriate media type.
By default, Abiquo will add the ID of the enterprise you are working with as a query parameter. If you are the cloud administrator or another user with appropriate privileges, you can retrieve the locations of another enterprise by entering another ID.
cURL:
curl -X GET https://example.com:443/api/cloud/locations?enterprise=256 \
-H 'Accept:application/vnd.abiquo.datacenters+json; version=4.6' \
-u user:password --verbose
Success status code: 200
Request payload:
--none--
Response payload:
{
"totalSize": 1,
"links": [
{
"rel": "first",
"href": "https://example.com:443/api/cloud/locations?enterprise=276&limit=25&by=name&asc=true"
},
{
"rel": "last",
"href": "https://example.com:443/api/cloud/locations?enterprise=276&startwith=0&limit=25&by=name&asc=true"
}
],
"collection": [
{
"id": 1,
"name": "Abiquo-DC",
"location": "Teide",
"links": [
{
"title": "Abiquo-DC",
"rel": "edit",
"type": "application/vnd.abiquo.datacenter+json",
"href": "https://example.com:443/api/admin/datacenters/1"
},
{
"title": "racks",
"rel": "racks",
"type": "application/vnd.abiquo.racks+json",
"href": "https://example.com:443/api/admin/datacenters/1/racks"
},
{
"title": "remote services",
"rel": "remoteservices",
"type": "application/vnd.abiquo.remoteservices+json",
"href": "https://example.com:443/api/admin/datacenters/1/remoteservices"
},
{
"title": "update resources",
"rel": "updateusedresources",
"type": "",
"href": "https://example.com:443/api/admin/datacenters/1/action/updateusedresources"
},
{
"title": "datastores",
"rel": "datastores",
"type": "application/vnd.abiquo.datastores+json",
"href": "https://example.com:443/api/admin/datacenters/1/datastores"
},
{
"title": "hypervisors",
"rel": "hypervisors",
"type": "application/vnd.abiquo.hypervisortypes+json",
"href": "https://example.com:443/api/admin/datacenters/1/hypervisors"
},
{
"title": "enterprises",
"rel": "enterprises",
"type": "application/vnd.abiquo.enterprises+json",
"href": "https://example.com:443/api/admin/datacenters/1/action/enterprises"
},
{
"title": "discover",
"rel": "discover",
"type": "application/vnd.abiquo.machines+json",
"href": "https://example.com:443/api/admin/datacenters/1/action/discover"
},
{
"title": "machines state",
"rel": "checkmachinestate",
"type": "application/vnd.abiquo.machinestate+json",
"href": "https://example.com:443/api/admin/datacenters/1/action/checkmachinestate"
},
{
"title": "machines ipmi",
"rel": "checkmachineipmistate",
"type": "application/vnd.abiquo.machineipmistate+json",
"href": "https://example.com:443/api/admin/datacenters/1/action/checkmachineipmistate"
},
{
"title": "tiers",
"rel": "tiers",
"type": "application/vnd.abiquo.tiers+json",
"href": "https://example.com:443/api/admin/datacenters/1/storage/tiers"
},
{
"title": "storage devices",
"rel": "devices",
"type": "application/vnd.abiquo.storagedevices+json",
"href": "https://example.com:443/api/admin/datacenters/1/storage/devices"
},
{
"title": "devices",
"rel": "devices",
"type": "application/vnd.abiquo.devices+json",
"href": "https://example.com:443/api/admin/datacenters/1/devices"
},
{
"title": "network service types",
"rel": "networkservicetypes",
"type": "application/vnd.abiquo.networkservicetypes+json",
"href": "https://example.com:443/api/admin/datacenters/1/networkservicetypes"
},
{
"title": "public networks",
"rel": "network",
"type": "application/vnd.abiquo.vlans+json",
"href": "https://example.com:443/api/admin/datacenters/1/network"
},
{
"title": "external ips",
"rel": "externalips",
"type": "application/vnd.abiquo.externalips+json",
"href": "https://example.com:443/api/admin/datacenters/1/network/action/externalips"
},
{
"title": "limits",
"rel": "getLimits",
"type": "application/vnd.abiquo.limits+json",
"href": "https://example.com:443/api/admin/datacenters/1/action/getlimits"
},
{
"title": "excluded networks",
"rel": "excludednetworks",
"type": "application/vnd.abiquo.excludednetworks+json",
"href": "https://example.com:443/api/admin/datacenters/1/excludednetworks"
},
{
"title": "NARS",
"rel": "remoteservice",
"type": "application/vnd.abiquo.remoteservice+json",
"href": "https://example.com:443/api/admin/remoteservices/4"
},
{
"title": "VIRTUALSYSTEMMONITOR",
"rel": "remoteservice",
"type": "application/vnd.abiquo.remoteservice+json",
"href": "https://example.com:443/api/admin/remoteservices/2"
},
{
"title": "BPMSERVICE",
"rel": "remoteservice",
"type": "application/vnd.abiquo.remoteservice+json",
"href": "https://example.com:443/api/admin/remoteservices/6"
},
{
"title": "DHCPSERVICE",
"rel": "remoteservice",
"type": "application/vnd.abiquo.remoteservice+json",
"href": "https://example.com:443/api/admin/remoteservices/71"
},
{
"title": "VIRTUALFACTORY",
"rel": "remoteservice",
"type": "application/vnd.abiquo.remoteservice+json",
"href": "https://example.com:443/api/admin/remoteservices/1"
},
{
"title": "REMOTEACCESS",
"rel": "remoteservice",
"type": "application/vnd.abiquo.remoteservice+json",
"href": "https://example.com:443/api/admin/remoteservices/61"
},
{
"title": "APPLIANCEMANAGER",
"rel": "remoteservice",
"type": "application/vnd.abiquo.remoteservice+json",
"href": "https://example.com:443/api/admin/remoteservices/3"
},
{
"title": "metricsmetadata",
"rel": "metricsmetadata",
"type": "application/vnd.abiquo.metricsmetadata+json",
"href": "https://example.com:443/api/admin/datacenters/1/metrics"
},
{
"title": "collectd",
"rel": "collectd",
"type": "application/json",
"href": "https://example.com:443/api/admin/datacenters/1/metrics/collectd"
},
{
"title": "alarmssearch",
"rel": "alarmssearch",
"type": "application/vnd.abiquo.alarms+json",
"href": "https://example.com:443/api/admin/datacenters/1/alarms"
},
{
"title": "natnetworks",
"rel": "natnetworks",
"type": "application/vnd.abiquo.natnetworks+json",
"href": "https://example.com:443/api/admin/datacenters/1/natnetworks"
},
{
"title": "Get nat ips",
"rel": "natips",
"type": "application/vnd.abiquo.natips+json",
"href": "https://example.com:443/api/admin/datacenters/1/natnetworks/action/allips"
},
{
"title": "Get nat rules",
"rel": "natrules",
"type": "application/vnd.abiquo.natrules+json",
"href": "https://example.com:443/api/admin/datacenters/1/natnetworks/action/allrules"
},
{
"title": "repository",
"rel": "datacenterrepository",
"type": "application/vnd.abiquo.datacenterrepository+json",
"href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1"
},
{
"title": "floating ips",
"rel": "ips",
"type": "application/vnd.abiquo.publicips+json",
"href": "https://example.com:443/api/cloud/locations/1/ips"
},
{
"title": "devices",
"rel": "devices",
"type": "application/vnd.abiquo.devices+json",
"href": "https://example.com:443/api/cloud/locations/1/devices"
},
{
"title": "available templates",
"rel": "templates",
"type": "application/vnd.abiquo.virtualmachinetemplates+json",
"href": "https://example.com:443/api/cloud/locations/1/templates"
},
{
"title": "remote vdcs",
"rel": "remotevirtualdatacenters",
"type": "application/vnd.abiquo.virtualdatacenters+json",
"href": "https://example.com:443/api/cloud/locations/1/action/remotevirtualdatacenters"
},
{
"title": "remote vms",
"rel": "remotevirtualmachines",
"type": "application/vnd.abiquo.virtualmachines+json",
"href": "https://example.com:443/api/cloud/locations/1/action/remotevirtualmachines"
},
{
"title": "available volumes",
"rel": "volumes",
"type": "application/vnd.abiquo.volumes+json",
"href": "https://example.com:443/api/cloud/locations/1/volumes"
},
{
"title": "available tiers",
"rel": "tiers",
"type": "application/vnd.abiquo.tiers+json",
"href": "https://example.com:443/api/cloud/locations/1/tiers"
},
{
"title": "Abiquo-DC",
"rel": "location",
"type": "application/vnd.abiquo.datacenter+json",
"href": "https://example.com:443/api/cloud/locations/1"
},
{
"title": "backup policies",
"rel": "backuppolicies",
"type": "application/vnd.abiquo.backuppolicies+json",
"href": "https://example.com:443/api/cloud/locations/1/backuppolicies"
},
{
"title": "backup location properties",
"rel": "backupproperties",
"type": "application/vnd.abiquo.backupdatacenterproperties+json",
"href": "https://example.com:443/api/cloud/locations/1/backupproperties"
},
{
"title": "compatible datastore tiers",
"rel": "compatibles",
"type": "application/vnd.abiquo.links+json",
"href": "https://example.com:443/api/cloud/locations/1/datastoretiers/action/compatibles"
},
{
"title": "datastore tiers",
"rel": "datastoretiers",
"type": "application/vnd.abiquo.datastoretiers+json",
"href": "https://example.com:443/api/cloud/locations/1/datastoretiers"
},
{
"title": "metricsmetadata",
"rel": "metricsmetadata",
"type": "application/vnd.abiquo.metricsmetadata+json",
"href": "https://example.com:443/api/cloud/locations/1/metrics"
},
{
"title": "collectd",
"rel": "collectd",
"type": "application/json",
"href": "https://example.com:443/api/cloud/locations/1/metrics/collectd"
},
{
"title": "VMware vCenter",
"rel": "hypervisortype",
"type": "application/vnd.abiquo.hypervisortype+json",
"href": "https://example.com:443/api/config/hypervisortypes/VMX_04"
},
{
"title": "KVM",
"rel": "hypervisortype",
"type": "application/vnd.abiquo.hypervisortype+json",
"href": "https://example.com:443/api/config/hypervisortypes/KVM"
}
]
}
]
}
Â
The important parts of this location entity are the ID and the edit link (shown here). Use this location link when you edit the virtual datacenter entity to create the virtual datacenter.
{
"title": "BCDC",
"rel": "edit",
"type": "application/vnd.abiquo.datacenter+json",
"href": "https://example.com:443/api/cloud/locations/1"
},
Â
Create the virtual datacenter
Modify the virtual datacenter entity shown here to add the location ID to the locations link, the enterprise ID and the hypervisor type (for example, ESXi with vCenter is "VMX_04")
cURL:
Success status code: 201
Request payload:
Response payload:
For more information about changing the default network configuration, see the VLAN customization section of Manage virtual datacenters .
In the UI, by default, Abiquo will create a default virtual appliance, named with the default prefix "vapp_" and the virtual datacenter name, but when you are working with the API, no default virtual appliance is created.
Create and deploy a virtual appliance
Now you can create and configure a virtual appliance (for more details, see Manage virtual appliances). A virtual appliance contains one or more VMs that you can use together to provide a service, such as a web stack or a classroom environment.
Create a virtual appliance
It's easy to create a virtual appliance. You can create one just by providing a virtual appliance with a name and some basic details, and the link to the virtual datacenter where you will create it.
cURL:
Success status code: 201
Request payload:
Response payload:
Â
Use a VM template to create a VM
You will need the link to a virtual appliance, a template in the Apps library, and an enterprise. See the previous Tenants tutorial for how to retrieve compatible templates from the Apps library.
cURL:
Success status code: 201
Request payload:
The link to specify the template is the only required value. In this case, we are also setting the friendly name of the VM and enabling remote access.
Â
Response payload:
Â
Deploy the VM
We are going to deploy the virtual machine on its own. It is also possible to deploy a whole virtual appliance at the same time.
cURL:
Success status code: 202
Request payload:
--none--
Response payload:
Â
The VM will be powered on. Congratulations, you've completed the how to!
Copyright © 2006-2024, Abiquo Holdings SL. All rights reserved