Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
This tutorial
Numberedheadings
number-formatcustom
h1[h1.decimal]
h2[h2.decimal]
h3[h3.decimal].
h4[h3.decimal].[h4.decimal]
start-numbering-ath3
Info

This guide will be updated shortly

This how-to guide describes how to create an enterprise and some users, as well as how to download some templates from a remote template repository.

In this

...

how-to guide you will perform the tasks of the cloud administrator and enterprise administrator. This

...

how-to guide uses the Cloud Administrator default account and does not show proper authentication.

Before you begin working through this

...

guide, you should create a datacenter (for API instructions, see API infrastructure tutorial), or a public cloud region (although be aware that some of the template management steps are different for public cloud regions)

Create an enterprise and users

When using the Abiquo API to create a tenant (Abiquo enterprise), it is important to first create the enterprise and then allow the enterprise to use datacenters or public cloud regions by creating an enterprise-datacenter limit.

Create the enterprise

The following request creates an enterprise with enterprise resource allocation limits.

cURL:

Success status : 201

Request payload:

Response payload:

Create an enterprise-datacenter limit for the new enterprise

An enterprise-datacenter limit allows an enterprise to use a datacenter or public cloud region. You can also use it to limit the allocation of resources in the datacenter. In this case, because all the limit values are set to 0, the enterprise's resource usage is not limited at this level. However, it is already limited at the enterprise level, and can also be limited at the virtual datacenters level.

cURL:
Code Block
curl -X POST https://example.com/api/admin/enterprises \ 
	 -H 'Accept:application/vnd.abiquo.enterprise+json; version=4.6' \ 
	 -H 'Content-Type:application/vnd.abiquo.enterprise+json; version=4.6' \ 
	 -d @requestpayload.json \ 
	 -u user:password --verbose 

Success status code: 201

Request payload:

Response payload:

Switch to the new enterprise

To perform some operations on the new tenant, it may be convenient to switch to that tenant, as you would do in the user interface. You can do this with a PUT request to update the user that will switch.

If you are working with the main cloud admin user, get the data entity for this user (whose user ID is 1) from whichever enterprise they are in by using a query over all enterprises represented by the underscore character "_", use a query like the following.

To switch the user to the new tenant enterprise, you need to edit the user entity, and add a link to the new enterprise, then update the user. Before you perform the PUT request to update the user, add an email attribute for the user if you didn't already add one.

So for example, to switch user 10 to the new enterprise.

Make sure you remember to add the email address!

For more details and a complete example, see.

You can check the enterprise that you are working with in the user interface.

Create users

The request to create a user is always the same but the user entity will vary depending on the user's role. To create a user you will need to know the ID of the role that you will assign to the user. And the ID of the user's scope. The following examples show how to create a tenant enterprise admin and an ordinary user.

Create an enterprise admin

The enterprise admin user can administer one or more tenant. By default, this user is allowed to create users within the tenant. The ID of the ENTERPRISE_ADMIN role is 3. The ID of the default global scope is 1. The username is given as the "nick" element. Modify and submit the following request to create an enterprise admin user.

cURL:

Success status code: 201

Request payload:

Response payload:

Create a cloud user

Modify and submit the following request to create a cloud user with the USER role.

cURL:

Success status code: 201

Request payload:

Response payload:

Add VM templates to the appliance library

The Apps library stores VM templates so that users can easily deploy VMs from these templates. Templates can be downloaded from a remote repository or uploaded from a local machine. The Apps library templates are available to the virtual datacenters. From there a user can add the VM template to a virtual appliance for deployment in the cloud.

Refresh the apps library

An Apps library belongs to your enterprise and there is one for each of the datacenters you are allowed to access. So to add templates that will only be used by one enterprise, it is best to switch to the enterprise, as described earlier in tutorial.

Get the enterprise ID

To refresh the Apps library using the API, you need to know the enterprise ID and the datacenter repository ID.

If you are working with the default Abiquo enterprise, the ID is "1". Otherwise you can retrieve the enterprise ID using https://wiki.abiquo.com/api/latest/EnterprisesResource.html#list-enterprise-identifiers-and-names

Get the enterprise repositories

Using the enterprise ID, retrieve all the repositories for your enterprise.

cURL:

Success status code: 200

Request payload:

-- none --

Response payload:

Perform the refresh

To refresh the enterprise datacenter repository, perform a put request to the "refresh" link in the datacenter repository entity shown above.

cURL:

Success status: 202

Request payload:

-- none --

Response payload:

The acceptedrequest media type is a reference to the action in progress. You can use this link to track the progress of the asynchronous refresh task.

Remember that the refresh is an asynchronous task, so you should wait until it has completed to go on to the next step.

Retrieve a compatible template

If you have already added some templates to the Apps library, you can just retrieve a template that is compatible with your hypervisor type by performing a query similar to the following one. If there are a lot of templates, you may wish to filter them using query parameters or select a specific template ID to retrieve. In this example, we filter by compatible hypervisorTypeName (VMX_04) and text in the template name and limit the number of templates returned to 1.

Remember that in Abiquo, you create a VM using only a link to a template, you do not need the full template entity.

The result of this query is a collection of templates, so if you only needed one template entity, you could remove the collection information or perform another request to retrieve just the desired template.  

cURL:

Response payload:

Add a new template from a remote repository

If there are no templates in your Apps library and you would like to add some using the API, follow the steps in this section. The most convenient template to download is the m0n0wall template in the default remote repository. However, the following query uses the a remote repository available in the local Abiquo installation.

Registering a remote repository is outside the scope of this tutorial. To register a custom remote repository, either please see the TemplateDefinitionList documentation or register it in Abiquo using the UI.

Template definition lists are available at the enterprise level, so to retrieve them, you just need your enterprise ID. Before you run this query, you may need to open the Remote template repository in the UI, by clicking the + Add template button and selecting "Create from remote template repository".

Retrieve all template definitions and select one

If you wish to retrieve all the template definitions found in the remote repositories registered in your Abiquo environment and available to your enterprise, you can use the following query. Obviously this query may return a large number of results, so one strategy may be to search the result for the ID of the template you wish to use.

Note that the following link contains an uppercase letter "D" in definition.

cURL:

Success status code: 200

Request payload:

-- none --

Response payload:

This is only one template definition taken from the list of hundreds of template definitions that were returned by this query. You can search for the template name and cut and paste the required template.

Create a template from a template definition

You can create a template in the Apps library from a link to a template definition retrieved from the above query. This is equivalent to downloading a template from the remote repository to the Apps library. To create the VM template request entity, you will need the information in the "edit" link section of the template definition above. You can then use this template in a later step to create a VM. The template ID is returned in the accepted request in the task link.

cURL:

Success status code: 202

Request payload:

Response payload:

See also
Code Block
{
  "cpuCountHardLimit": 20, 
  "diskHardLimitInMb": 20480, 
  "isReservationRestricted": false, 
  "ramSoftLimitInMb": 10240, 
  "links": [], 
  "workflow": false, 
  "vlansHard": 10, 
  "publicIpsHard": 10, 
  "publicIpsSoft": 10, 
  "ramHardLimitInMb": 20480, 
  "vlansSoft": 10, 
  "cpuCountSoftLimit": 20, 
  "diskSoftLimitInMb": 10240, 
  "name": "Tioco"
}

Response payload:

Code Block
 {
    "id": 276,
    "name": "Tioco",
    "isReservationRestricted": false,
    "workflow": false,
    "twoFactorAuthenticationMandatory": false,
    "reseller": false,
    "keyNode": false,
    "diskSoftLimitInMb": 10240,
    "diskHardLimitInMb": 20480,
    "storageSoftInMb": 0,
    "storageHardInMb": 0,
    "vmsSoft": 0,
    "vmsHard": 0,
    "vlansSoft": 10,
    "vlansHard": 10,
    "publicIpsSoft": 10,
    "publicIpsHard": 10,
    "repositorySoftInMb": 0,
    "repositoryHardInMb": 0,
    "links": [
        {
            "title": "Tioco",
            "rel": "edit",
            "type": "application/vnd.abiquo.enterprise+json",
            "href": "https://example.com:443/api/admin/enterprises/276"
        },
        {
            "title": "users",
            "rel": "users",
            "type": "application/vnd.abiquo.users+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users"
        },
        {
            "title": "properties",
            "rel": "properties",
            "type": "application/vnd.abiquo.enterpriseproperties+json",
            "href": "https://example.com:443/api/admin/enterprises/276/properties"
        },
        {
            "title": "Global scope",
            "rel": "scope",
            "type": "application/vnd.abiquo.scope+json",
            "href": "https://example.com:443/api/admin/scopes/1"
        },
        {
            "title": "template definitions lists",
            "rel": "appslib/templateDefinitionLists",
            "type": "application/vnd.abiquo.templatedefinitionlists+json",
            "href": "https://example.com:443/api/admin/enterprises/276/appslib/templateDefinitionLists"
        },
        {
            "title": "template defintion paths",
            "rel": "appslib/templateDefinitions",
            "type": "application/vnd.abiquo.templatedefinitions+json",
            "href": "https://example.com:443/api/admin/enterprises/276/appslib/templateDefinitions"
        },
        {
            "title": "repositories",
            "rel": "datacenterrepositories",
            "type": "application/vnd.abiquo.datacenterrepositories+json",
            "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories"
        },
        {
            "title": "virtual machines",
            "rel": "virtualmachines",
            "type": "application/vnd.abiquo.virtualmachines+json",
            "href": "https://example.com:443/api/admin/enterprises/276/action/virtualmachines"
        },
        {
            "title": "virtual appliances",
            "rel": "virtualappliances",
            "type": "application/vnd.abiquo.virtualappliances+json",
            "href": "https://example.com:443/api/admin/enterprises/276/action/virtualappliances"
        },
        {
            "title": "ips",
            "rel": "ips",
            "type": "application/vnd.abiquo.privateips+json",
            "href": "https://example.com:443/api/admin/enterprises/276/action/ips"
        },
        {
            "title": "virtual datacenters",
            "rel": "cloud/virtualdatacenters",
            "type": "application/vnd.abiquo.virtualdatacenters+json",
            "href": "https://example.com:443/api/admin/enterprises/276/action/virtualdatacenters"
        },
        {
            "title": "reserved machines",
            "rel": "reservedmachines",
            "type": "application/vnd.abiquo.machines+json",
            "href": "https://example.com:443/api/admin/enterprises/276/reservedmachines"
        },
        {
            "title": "limits",
            "rel": "limits",
            "type": "application/vnd.abiquo.limits+json",
            "href": "https://example.com:443/api/admin/enterprises/276/limits"
        },
        {
            "title": "providerlimits",
            "rel": "providerlimits",
            "type": "application/vnd.abiquo.providerlimits+json",
            "href": "https://example.com:443/api/admin/enterprises/276/providerlimits"
        },
        {
            "title": "volumes",
            "rel": "volumes",
            "type": "application/vnd.abiquo.volumes+json",
            "href": "https://example.com:443/api/admin/enterprises/276/action/volumes"
        },
        {
            "title": "external networks",
            "rel": "externalnetworks",
            "type": "application/vnd.abiquo.vlans+json",
            "href": "https://example.com:443/api/admin/enterprises/276/action/externalnetworks"
        },
        {
            "title": "pending tasks",
            "rel": "pendingtasks",
            "type": "application/vnd.abiquo.tasks+json",
            "href": "https://example.com:443/api/admin/enterprises/276/action/pendingtasks"
        },
        {
            "title": "credentials",
            "rel": "credentials",
            "type": "application/vnd.abiquo.publiccloudcredentialslist+json",
            "href": "https://example.com:443/api/admin/enterprises/276/credentials"
        },
        {
            "title": "pricingcredentials",
            "rel": "pricingcredentials",
            "type": "application/vnd.abiquo.pricingcredentialslist+json",
            "href": "https://example.com:443/api/admin/enterprises/276/pricingcredentials"
        },
        {
            "title": "virtual appliances specs",
            "rel": "vappspecs",
            "type": "application/vnd.abiquo.virtualappliancespecs+json",
            "href": "https://example.com:443/api/admin/enterprises/276/vappspecs"
        },
        {
            "title": "bills",
            "rel": "bills",
            "type": "application/vnd.abiquo.bills+json",
            "href": "https://example.com:443/api/statistics/enterpriseresources/276/bills"
        },
        {
            "title": "billregisters",
            "rel": "billregisters",
            "type": "application/vnd.abiquo.bills+json",
            "href": "https://example.com:443/api/statistics/enterpriseresources/276/billregisters"
        },
        {
            "title": "estimation",
            "rel": "estimation",
            "type": "text/plain",
            "href": "https://example.com:443/api/statistics/enterpriseresources/276/billregisters/action/estimate"
        },
        {
            "title": "Bill providers",
            "rel": "billproviders",
            "type": "application/vnd.abiquo.billproviders+json",
            "href": "https://example.com:443/api/statistics/enterpriseresources/276/bills/action/providers"
        },
        {
            "title": "Reseller enterprise",
            "rel": "reseller",
            "type": "application/vnd.abiquo.enterprise+json",
            "href": "https://example.com:443/api/admin/enterprises/267"
        }
    ],
    "ramSoft": 0,
    "ramHard": 0,
    "cpuSoft": 0,
    "cpuHard": 0
}

Create an enterprise-datacenter limit for the new enterprise

An enterprise-datacenter limit allows an enterprise to use a datacenter or public cloud region. You can also use it to limit the allocation of resources in the datacenter. In this case, because all the limit values are set to 0, the enterprise's resource usage is not limited at this level. However, it is already limited at the enterprise level, and can also be limited at the virtual datacenters level.

cURL:

Code Block
curl -X POST https://example.com/api/admin/enterprises/2/limits \ 
	 -H 'Accept:application/vnd.abiquo.limit+json; version=4.2' \ 
	 -H 'Content-Type:application/vnd.abiquo.limit+json; version=4.2' \ 
	 -d @requestpayload.json \ 
	 -u user:password --verbose 

Success status code: 201

Request payload:

Code Block
{
  "cpuCountHardLimit": 0, 
  "ramSoftLimitInMb": 0, 
  "links": [
    {
      "href": "https://example.com/api/admin/datacenters/1", 
      "rel": "location"
    }
  ], 
  "vlansHard": 0, 
  "publicIpsHard": 0, 
  "publicIpsSoft": 0, 
  "ramHardLimitInMb": 0, 
  "vlansSoft": 0, 
  "cpuCountSoftLimit": 0
}

Response payload:

Code Block
{
    "id": 1045,
    "enabledHardwareProfiles": false,
    "diskSoftLimitInMb": 0,
    "diskHardLimitInMb": 0,
    "storageSoftInMb": 0,
    "storageHardInMb": 0,
    "vmsSoft": 0,
    "vmsHard": 0,
    "vlansSoft": 0,
    "vlansHard": 0,
    "publicIpsSoft": 0,
    "publicIpsHard": 0,
    "repositorySoftInMb": 0,
    "repositoryHardInMb": 0,
    "links": [
        {
            "title": "Tioco",
            "rel": "enterprise",
            "type": "application/vnd.abiquo.enterprise+json",
            "href": "https://example.com:443/api/admin/enterprises/276"
        },
        {
            "title": "edit datacenter limits 1045",
            "rel": "edit",
            "type": "application/vnd.abiquo.limit+json",
            "href": "https://example.com:443/api/admin/enterprises/276/limits/1045"
        },
        {
            "title": "external networks",
            "rel": "externalnetworks",
            "type": "application/vnd.abiquo.vlans+json",
            "href": "https://example.com:443/api/admin/enterprises/276/limits/1045/externalnetworks"
        },
        {
            "title": "virtualappliances",
            "rel": "action",
            "type": "application/vnd.abiquo.virtualappliances+json",
            "href": "https://example.com:443/api/admin/enterprises/276/limits/1045/action/virtualappliances"
        },
        {
            "title": "Abiquo-DC",
            "rel": "location",
            "type": "application/vnd.abiquo.datacenter+json",
            "href": "https://example.com:443/api/admin/datacenters/1"
        },
        {
            "title": "NFS Tier",
            "rel": "tier",
            "type": "application/vnd.abiquo.tier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/storage/tiers/1"
        },
        {
            "title": "Nexenta Tier 2",
            "rel": "tier",
            "type": "application/vnd.abiquo.tier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/storage/tiers/2"
        },
        {
            "title": "Default Tier 3",
            "rel": "tier",
            "type": "application/vnd.abiquo.tier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/storage/tiers/3"
        },
        {
            "title": "LVM Tier 4",
            "rel": "tier",
            "type": "application/vnd.abiquo.tier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/storage/tiers/4"
        },
        {
            "title": "datastoretier_hyperv_2_33",
            "rel": "datastoretier",
            "type": "application/vnd.abiquo.datastoretier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/datastoretiers/40"
        },
        {
            "title": "datastoretier_DC1_sharedds1_nfs",
            "rel": "datastoretier",
            "type": "application/vnd.abiquo.datastoretier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/datastoretiers/44"
        },
        {
            "title": "datastoretierESXI6.0_2.29",
            "rel": "datastoretier",
            "type": "application/vnd.abiquo.datastoretier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/datastoretiers/58"
        },
        {
            "title": "datastoretier_DC1_sharedds2_nfs",
            "rel": "datastoretier",
            "type": "application/vnd.abiquo.datastoretier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/datastoretiers/59"
        },
        {
            "title": "datastoretier_ESXI_2_56",
            "rel": "datastoretier",
            "type": "application/vnd.abiquo.datastoretier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/datastoretiers/63"
        },
        {
            "title": "datastoretierESXI6.0_2.23",
            "rel": "datastoretier",
            "type": "application/vnd.abiquo.datastoretier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/datastoretiers/69"
        },
        {
            "title": "datastoretier_KVM",
            "rel": "datastoretier",
            "type": "application/vnd.abiquo.datastoretier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/datastoretiers/70"
        },
        {
            "title": "datastoretier_ESXI67_DC1",
            "rel": "datastoretier",
            "type": "application/vnd.abiquo.datastoretier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/datastoretiers/73"
        },
        {
            "title": "datastoretierESXI6.55555",
            "rel": "datastoretier",
            "type": "application/vnd.abiquo.datastoretier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/datastoretiers/74"
        },
        {
            "title": "datastoretierESXI5.5_2.51",
            "rel": "datastoretier",
            "type": "application/vnd.abiquo.datastoretier+json",
            "href": "https://example.com:443/api/admin/datacenters/1/datastoretiers/75"
        }
    ],
    "ramSoft": 0,
    "ramHard": 0,
    "cpuSoft": 0,
    "cpuHard": 0
} 

Switch to the new enterprise

To perform some operations on the new tenant, it may be convenient to switch to that tenant, as you would do in the user interface. You can do this with a PUT request to update the user that will switch.

If you are working with the main cloud admin user, get the data entity for this user (whose user ID is 1) from whichever enterprise they are in by using a query over all enterprises represented by the underscore character "_", use a query like the following.

Code Block
curl -X GET "https://example.com/api/admin/enterprises/_/users/1" \
	 -H "Accept: application/vnd.abiquo.user+json;version=4.6"

To switch the user to the new tenant enterprise, you need to edit the user entity, and add a link to the new enterprise, then update the user. Before you perform the PUT request to update the user, add an email attribute for the user if you didn't already add one.

So for example, to switch user 10 to the new enterprise.

Code Block
curl -X PUT "https://example.com/api/admin/enterprises/_/users/10" \
	 -H "Accept: application/vnd.abiquo.user+json;version=4.6" \
     -H "Content-Type: application/vnd.abiquo.user+json;version=4.6" \
	 -d @requestpayload.json \ 
	 -u user:password --verbose 

Make sure you remember to add the email address!

Code Block
{
    "links": [
        {
            "rel": "enterprise",
            "href": "https://example.com/api/admin/enterprises/276"
        },
...
    "email" : "cloudadmin@example.com",
...

For more details and a complete example, see Switch enterprises via API.

You can check the enterprise that you are working with in the user interface.

Create users

The request to create a user is always the same but the user entity will vary depending on the user's role. To create a user you will need to know the ID of the role that you will assign to the user. And the ID of the user's scope. The following examples show how to create a tenant enterprise admin and an ordinary user.

Create an enterprise admin

The enterprise admin user can administer one or more tenant. By default, this user is allowed to create users within the tenant. The ID of the ENTERPRISE_ADMIN role is 3. The ID of the default global scope is 1. The username is given as the "nick" element. Modify and submit the following request to create an enterprise admin user.

cURL:

Code Block
curl -X POST https://example.com/api/admin/enterprises/276/users \ 
	 -H 'Accept:application/vnd.abiquo.user+json; version=4.6' \ 
	 -H 'Content-Type:application/vnd.abiquo.user+json; version=4.6' \ 
	 -d @requestpayload.xml \ 
	 -u user:password --verbose 

Success status code: 201

Request payload:

Code Block
{
  "surname": "Admin",
  "name": "Ent",
  "links": [
    {
      "href": "https://example.com/api/admin/roles/3",
      "rel": "role"
    },
    {
      "href": "https://example.com/api/admin/scopes/1",
      "rel": "scope"
    }
  ], 
  "locale": "EN", 
  "nick": "ent276admin", 
  "firstLogin": true, 
  "active": true, 
  "locked": false, 
  "password": "ent276admin", 
  "email": "ent276admin@example.com",
  "phone": "555123456",	 
  "description": "API tutorial user"
}

Response payload:

Code Block
{
    "id": 201,
    "nick": "ent276admin",
    "name": "Enterprise",
    "surname": "Admin",
    "description": "API tutorial user",
    "email": "ent276admin@example.com",
    "locale": "EN",
    "authType": "ABIQUO",
    "active": true,
    "firstLogin": true,
    "locked": false,
    "links": [
        {
            "title": "Tioco",
            "rel": "enterprise",
            "type": "application/vnd.abiquo.enterprise+json",
            "href": "https://example.com:443/api/admin/enterprises/276"
        },
        {
            "title": "ENTERPRISE_ADMIN",
            "rel": "role",
            "type": "application/vnd.abiquo.role+json",
            "href": "https://example.com:443/api/admin/roles/3"
        },
        {
            "title": "ent276admin",
            "rel": "edit",
            "type": "application/vnd.abiquo.user+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users/201"
        },
        {
            "title": "Global scope",
            "rel": "scope",
            "type": "application/vnd.abiquo.scope+json",
            "href": "https://example.com:443/api/admin/scopes/1"
        },
        {
            "title": "virtual machines",
            "rel": "virtualmachines",
            "type": "application/vnd.abiquo.virtualmachines+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users/201/action/virtualmachines"
        },
        {
            "title": "pending tasks",
            "rel": "pendingtasks",
            "type": "application/vnd.abiquo.tasks+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users/201/action/pendingtasks"
        },
        {
            "title": "applications",
            "rel": "applications",
            "type": "application/vnd.abiquo.applications+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users/201/applications"
        },
        {
            "title": "enable two factor authentication",
            "rel": "enable2fa",
            "type": "application/vnd.abiquo.twofactorauthcredentials+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users/201/action/enable2fa"
        },
        {
            "title": "async tasks",
            "rel": "asynctasks",
            "type": "application/vnd.abiquo.asynctasks+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users/201/asynctasks"
        }
    ]
} 
Create a cloud user

Modify and submit the following request to create a cloud user with the USER role.

cURL:

Code Block
curl -X POST https://example.com:443/api/admin/enterprises/276/users \ 
	 -H 'Accept:application/vnd.abiquo.user+json; version=4.6' \ 
	 -H 'Content-Type:application/vnd.abiquo.user+json; version=4.6' \ 
	 -d @requestpayload.xml \ 
	 -u user:password --verbose 

Success status code: 201

Request payload:

Code Block
{
  "surname": "User", 
  "name": "Cloud", 
  "links": [
    {
      "href": "https://example.com/api/admin/roles/2", 
      "rel": "role"
    },
    {
      "href": "https://example.com/api/admin/scopes/1",
      "rel": "scope"
    }
  ], 
  "locale": "EN", 
  "nick": "cloud276user", 
  "firstLogin": true, 
  "active": true, 
  "locked": false, 
  "password": "cloud276user", 
  "email": "cloud276user@example.com", 
  "phone": "555123456",
  "description": "API tutorial cloud user"
}

Response payload:

Code Block
{
    "id": 203,
    "nick": "cloud276user",
    "name": "Cloud",
    "surname": "User",
    "description": "tutorial cloud user",
    "email": "cloud276user@example.com",
    "locale": "EN",
    "authType": "ABIQUO",
    "active": true,
    "firstLogin": true,
    "locked": false,
    "links": [
        {
            "title": "Tioco",
            "rel": "enterprise",
            "type": "application/vnd.abiquo.enterprise+json",
            "href": "https://example.com:443/api/admin/enterprises/276"
        },
        {
            "title": "USER",
            "rel": "role",
            "type": "application/vnd.abiquo.role+json",
            "href": "https://example.com:443/api/admin/roles/2"
        },
        {
            "title": "cloud276user",
            "rel": "edit",
            "type": "application/vnd.abiquo.user+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users/203"
        },
        {
            "title": "Global scope",
            "rel": "scope",
            "type": "application/vnd.abiquo.scope+json",
            "href": "https://example.com:443/api/admin/scopes/1"
        },
        {
            "title": "virtual machines",
            "rel": "virtualmachines",
            "type": "application/vnd.abiquo.virtualmachines+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users/203/action/virtualmachines"
        },
        {
            "title": "pending tasks",
            "rel": "pendingtasks",
            "type": "application/vnd.abiquo.tasks+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users/203/action/pendingtasks"
        },
        {
            "title": "applications",
            "rel": "applications",
            "type": "application/vnd.abiquo.applications+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users/203/applications"
        },
        {
            "title": "enable two factor authentication",
            "rel": "enable2fa",
            "type": "application/vnd.abiquo.twofactorauthcredentials+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users/203/action/enable2fa"
        },
        {
            "title": "async tasks",
            "rel": "asynctasks",
            "type": "application/vnd.abiquo.asynctasks+json",
            "href": "https://example.com:443/api/admin/enterprises/276/users/203/asynctasks"
        }
    ]
} 

Add VM templates to the appliance library

The Apps library stores VM templates so that users can easily deploy VMs from these templates. Templates can be downloaded from a remote repository or uploaded from a local machine. The Apps library templates are available to the virtual datacenters. From there a user can add the VM template to a virtual appliance for deployment in the cloud.

Refresh the apps library

An Apps library belongs to your enterprise and there is one for each of the datacenters you are allowed to access. So to add templates that will only be used by one enterprise, it is best to switch to the enterprise, as described earlier in tutorial.

Get the enterprise ID

To refresh the Apps library using the API, you need to know the enterprise ID and the datacenter repository ID.

If you are working with the default Abiquo enterprise, the ID is "1". Otherwise you can retrieve the enterprise ID using https://wiki.abiquo.com/api/latest/EnterprisesResource.html#list-enterprise-identifiers-and-names

Get the enterprise repositories

Using the enterprise ID, retrieve all the repositories for your enterprise.

cURL:

Code Block
curl --verbose -X GET https://example.com:443/api/admin/enterprises/276/datacenterrepositories \
	-H "Accept: application/vnd.abiquo.datacenterrepositories+json; version=4.6;"  \
	-u user:password

Success status code: 200

Request payload:

-- none --

Response payload:

Code Block
{
    "links": [],
    "collection": [
        {
            "name": "virtual image repo",
            "repositoryLocation": "10.60.2.10:/volume1/qa-repository",
            "links": [
                {
                    "title": "Tioco",
                    "rel": "enterprise",
                    "type": "application/vnd.abiquo.enterprise+json",
                    "href": "https://example.com:443/api/admin/enterprises/276"
                },
                {
                    "title": "10.60.2.10:/volume1/qa-repository",
                    "rel": "edit",
                    "type": "application/vnd.abiquo.datacenterrepository+json",
                    "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1"
                },
                {
                    "title": "virtual machine templates",
                    "rel": "virtualmachinetemplates",
                    "type": "application/vnd.abiquo.virtualmachinetemplates+json",
                    "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/virtualmachinetemplates"
                },
                {
                    "title": "template publishers",
                    "rel": "templatepublishers",
                    "type": "application/vnd.abiquo.templatepublishers+json",
                    "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/templatepublishers"
                },
                {
                    "title": "disks",
                    "rel": "disks",
                    "type": "application/vnd.abiquo.disks+json",
                    "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/action/disks"
                },
                {
                    "title": "refresh",
                    "rel": "refresh",
                    "type": "application/vnd.abiquo.acceptedrequest+json",
                    "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/actions/refresh"
                },
                {
                    "title": "tasks",
                    "rel": "tasks",
                    "type": "application/vnd.abiquo.tasks+json",
                    "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/tasks"
                },
                {
                    "title": "Abiquo-DC",
                    "rel": "datacenter",
                    "type": "application/vnd.abiquo.datacenter+json",
                    "href": "https://example.com:443/api/admin/datacenters/1"
                },
                {
                    "rel": "applianceManagerRepositoryUri",
                    "href": "https://example.com:443/am/erepos/276"
                }
            ]
        }
    ]
} 
Perform the refresh

To refresh the enterprise datacenter repository, perform a put request to the "refresh" link in the datacenter repository entity shown above.

cURL:

Code Block
curl --verbose -X PUT https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/actions/refresh \
	-H "Accept: application/vnd.abiquo.acceptedrequest+json; version=4.6;" \
	-u user:password

Success status: 202

Request payload:

-- none --

Response payload:

The acceptedrequest media type is a reference to the action in progress. You can use this link to track the progress of the asynchronous refresh task.

Code Block
{
    "message": "You can keep track of the progress in the link",
    "links": [
        {
            "title": "status",
            "rel": "status",
            "type": "application/vnd.abiquo.task+json",
            "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/tasks/346f62cb-f0f4-4f62-bd7a-5365c169eeb8"
        }
    ]
} 

Remember that the refresh is an asynchronous task, so you should wait until it has completed to go on to the next step.

Retrieve a compatible template

If you have already added some templates to the Apps library, you can just retrieve a template that is compatible with your hypervisor type by performing a query similar to the following one. If there are a lot of templates, you may wish to filter them using query parameters or select a specific template ID to retrieve. In this example, we filter by compatible hypervisorTypeName (VMX_04) and text in the template name and limit the number of templates returned to 1.

Remember that in Abiquo, you create a VM using only a link to a template, you do not need the full template entity.

The result of this query is a collection of templates, so if you only needed one template entity, you could remove the collection information or perform another request to retrieve just the desired template.  

cURL:

Code Block
curl --verbose -X GET https://example.com/api/admin/enterprises/276/datacenterrepositories/1/virtualmachinetemplates?hypervisorTypeName=VMX_04&limit=1&has=yVM \
	-H "Accept: application/vnd.abiquo.virtualmachinetemplates+json; version=4.6;" \
	-u user:password   

Response payload:

Code Block
{
    "totalSize": 3,
    "links": [
        {
            "rel": "first",
            "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/virtualmachinetemplates?hypervisorTypeName=VMX_04&limit=1&has=yVM&by=state&asc=true"
        },
        {
            "rel": "next",
            "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/virtualmachinetemplates?hypervisorTypeName=VMX_04&startwith=1&limit=1&has=yVM&by=state&asc=true"
        },
        {
            "rel": "last",
            "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/virtualmachinetemplates?hypervisorTypeName=VMX_04&startwith=2&limit=1&has=yVM&by=state&asc=true"
        }
    ],
    "collection": [
        {
            "id": "2",
            "name": "yVM_Abiquo_enterprise",
            "description": "A virtual machine",
            "osType": "LINUX_2_6",
            "cpuRequired": 1,
            "ramRequired": 48,
            "shared": true,
            "state": "DONE",
            "creationDate": "2017-02-06T23:37:41.000+0000",
            "creationUser": "SYSTEM",
            "chefEnabled": false,
            "loginUser": "root",
            "loginPassword": "temporal",
            "ethernetDriverType": "E1000",
            "variables": {},
            "enableCpuHotAdd": false,
            "enableRamHotAdd": false,
            "enableDisksHotReconfigure": false,
            "enableNicsHotReconfigure": false,
            "enableRemoteAccessHotReconfigure": false,
            "enableOnlyHPRecommended": false,
            "generateGuestInitialPassword": false,
            "productCodes": [],
            "links": [
                {
                    "title": "Tioco",
                    "rel": "enterprise",
                    "type": "application/vnd.abiquo.enterprise+json",
                    "href": "https://example.com:443/api/admin/enterprises/276"
                },
                {
                    "title": "Others",
                    "rel": "category",
                    "type": "application/vnd.abiquo.category+json",
                    "href": "https://example.com:443/api/config/categories/1"
                },
                {
                    "title": "yVM_Abiquo_enterprise",
                    "rel": "edit",
                    "type": "application/vnd.abiquo.virtualmachinetemplate+json",
                    "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/virtualmachinetemplates/2"
                },
                {
                    "title": "tasks",
                    "rel": "tasks",
                    "type": "application/vnd.abiquo.tasks+json",
                    "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/virtualmachinetemplates/2/tasks"
                },
                {
                    "title": "repository",
                    "rel": "datacenterrepository",
                    "type": "application/vnd.abiquo.datacenterrepository+json",
                    "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1"
                },
                {
                    "title": "virtual machines",
                    "rel": "virtualmachines",
                    "type": "application/vnd.abiquo.virtualmachines+json",
                    "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/virtualmachinetemplates/2/action/virtualmachines"
                },
                {
                    "title": "disks",
                    "rel": "disks",
                    "type": "application/vnd.abiquo.disks+json",
                    "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/virtualmachinetemplates/2/disks"
                },
                {
                    "title": "Hard disk 1",
                    "rel": "disk0",
                    "type": "application/vnd.abiquo.disk+json",
                    "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/virtualmachinetemplates/2/disks/2"
                },
                {
                    "title": "template definition",
                    "rel": "templatedefinition",
                    "href": "http://packer-repo.s3.amazonaws.com/yVM/yVM.ovf"
                },
                {
                    "title": "template path",
                    "rel": "templatePath",
                    "href": "https://example.com:443/am/erepos/276/templates/1/packer-repo.s3.amazonaws.com/yVM/"
                },
                {
                    "title": "Global scope",
                    "rel": "scope",
                    "type": "application/vnd.abiquo.scope+json",
                    "href": "https://example.com:443/api/admin/scopes/1"
                }
            ]
        }
    ]
} 

Add a new template from a remote repository

If there are no templates in your Apps library and you would like to add some using the API, follow the steps in this section. The most convenient template to download is the m0n0wall template in the default remote repository. However, the following query uses the a remote repository available in the local Abiquo installation.

Registering a remote repository is outside the scope of this tutorial. To register a custom remote repository, either please see the TemplateDefinitionList documentation or register it in Abiquo using the UI.

Template definition lists are available at the enterprise level, so to retrieve them, you just need your enterprise ID. Before you run this query, you may need to open the Remote template repository in the UI, by clicking the + Add template button and selecting "Create from remote template repository".

Retrieve all template definitions and select one

If you wish to retrieve all the template definitions found in the remote repositories registered in your Abiquo environment and available to your enterprise, you can use the following query. Obviously this query may return a large number of results, so one strategy may be to search the result for the ID of the template you wish to use.

Note that the following link contains an uppercase letter "D" in definition.

cURL:

Code Block
curl --verbose -X GET https://example.com/api/admin/enterprises/276/appslib/templateDefinitionLists \
	-H "Accept: application/vnd.abiquo.templatedefinitionslists+json; version=4.6;" \
	-u user:password

Success status code: 200

Request payload:

-- none --

Response payload:

This is only one template definition taken from the list of hundreds of template definitions that were returned by this query. You can search for the template name and cut and paste the required template.

Code Block
...
                    {
                        "id": 2065,
                        "url": "http://files.template-repository.abiquo.com/m0n0wall/m0n0wall-1.3b18-i386-monolithicFlat.1.5.ovf",
                        "name": "m0n0wall 1.3b18-i386",
                        "description": "m0n0wall is a project aimed at creating a complete, embedded firewall software package that, when used together with an embedded PC, provides \n            all the important features of commercial firewall boxes (including ease of use) at a fraction of the price (free software). https://PUBLIC:IP and use Username: admin, \n            password: abiquo. Configure MANUALLY the private IP of abicloud and it's done.",
                        "productName": "m0n0wall 1.3b18-i386",
                        "iconUrl": "http://files.template-repository.abiquo.com/m0n0wall/m0n0wall_logo.png",
                        "osType": "LINUX_2_6",
                        "ethernetDriverType": "E1000",
                        "links": [
                            {
                                "title": "Tioco",
                                "rel": "enterprise",
                                "type": "application/vnd.abiquo.enterprise+json",
                                "href": "https://example.com:443/api/admin/enterprises/276"
                            },
                            {
                                "title": "Firewall",
                                "rel": "category",
                                "type": "application/vnd.abiquo.category+json",
                                "href": "https://example.com:443/api/config/categories/11"
                            },
                            {
                                "title": "Repository 2.0",
                                "rel": "templateDefinitionList",
                                "type": "application/vnd.abiquo.templatedefinitionlist+json",
                                "href": "https://example.com:443/api/admin/enterprises/276/appslib/templateDefinitionLists/85"
                            },
                            {
                                "title": "m0n0wall 1.3b18-i386",
                                "rel": "edit",
                                "type": "application/vnd.abiquo.templatedefinition+json",
                                "href": "https://example.com:443/api/admin/enterprises/276/appslib/templateDefinitions/2065"
                            }
                        ],
                        "templatedefinitiondisks": [
                            {
                                "label": "scsi0:0",
                                "diskFormatType": "VMDK_FLAT",
                                "diskFileSize": 27262976,
                                "hdRequired": 27262976,
                                "diskControllerType": "SCSI",
                                "diskController": "lsilogic",
                                "links": []
                            }
                        ]
                    }, 
...
Create a template from a template definition

You can create a template in the Apps library from a link to a template definition retrieved from the above query. This is equivalent to downloading a template from the remote repository to the Apps library. To create the VM template request entity, you will need the information in the "edit" link section of the template definition above. You can then use this template in a later step to create a VM. The template ID is returned in the accepted request in the task link.

cURL:

Code Block
curl -X POST https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/virtualmachinetemplates \ 
     -H 'Accept:application/vnd.abiquo.acceptedrequest+json;version=4.6' \ 
     -H 'Content-Type:application/vnd.abiquo.virtualmachinetemplaterequest+json;version=4.6' \ 
     -d @requestpayload.json \ 
     -u user:password --verbose

Success status code: 202

Request payload:

Code Block
 {
  "links": [
    {
      "title": "m0n0wall 1.3b18-i386",
      "rel": "templateDefinition",
      "type": "application/vnd.abiquo.templatedefinition+json",
      "href": "https://example.com/api/admin/enterprises/276/appslib/templateDefinitions/2065/actions/repositoryInstall"
    }
  ]
}

Response payload:

Code Block
{
    "message": "You can keep track of the progress in the link",
    "links": [
        {
            "title": "status",
            "rel": "status",
            "type": "application/vnd.abiquo.task+json",
            "href": "https://example.com:443/api/admin/enterprises/276/datacenterrepositories/1/virtualmachinetemplates/2094/tasks/dc86d3d1-63fa-46be-bbdb-302e71ce9e1b"
        }
    ]
} 

See also Appliance manager template API upload and download for information on how to upload templates from the local filesystem using the Appliance Manager API.