This tutorial describes how to create an enterprise and some users, as well as how to download some templates from a remote template repository. In this tutorial you will perform the tasks of the cloud administrator and enterprise administrator.
Before you begin working with the API tutorials, you should complete the following prerequisites:
- The platform should be installed in a test environment, see Installation
- The platform should have a license added, on the License tab in Configuration View#Licenses
- You should have basic general knowledge of the Abiquo platform, see the Get Started section
- You should have worked with the Abiquo user interface, for example, by working through the Abiquo Quick Tutorial
- You should have API credentials and a chosen authentication method, see Authentication
- This tutorial uses the Cloud Administrator default account and does not show proper authentication
1. 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.
1.1 Create the enterprise
The following request creates an enterprise with enterprise resource allocation limits.
cURL:
curl -X POST https://mjsabiquo.bcn.abiquo.com/api/admin/enterprises \
-H 'Accept:application/vnd.abiquo.enterprise+json; version=3.8' \
-H 'Content-Type:application/vnd.abiquo.enterprise+json; version=3.8' \
-d @requestpayload.json \
-u user:password --verbose
Success status code: 201
Request payload:
{
"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:
Click here to expand...
{
"links": [
{
"title": "Tioco",
"rel": "edit",
"type": "application/vnd.abiquo.enterprise+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2"
},
{
"title": "users",
"rel": "users",
"type": "application/vnd.abiquo.users+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users"
},
{
"title": "properties",
"rel": "properties",
"type": "application/vnd.abiquo.enterpriseproperties+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/properties"
},
{
"title": "template definitions lists",
"rel": "appslib/templateDefinitionLists",
"type": "application/vnd.abiquo.templatedefinitionlists+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/appslib/templateDefinitionLists"
},
{
"title": "template defintion paths",
"rel": "appslib/templateDefinitions",
"type": "application/vnd.abiquo.templatedefinitions+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/appslib/templateDefinitions"
},
{
"title": "repositories",
"rel": "datacenterrepositories",
"type": "application/vnd.abiquo.datacenterrepositories+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories"
},
{
"title": "virtual machines",
"rel": "virtualmachines",
"type": "application/vnd.abiquo.virtualmachines+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/action/virtualmachines"
},
{
"title": "virtual appliances",
"rel": "virtualappliances",
"type": "application/vnd.abiquo.virtualappliances+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/action/virtualappliances"
},
{
"title": "ips",
"rel": "ips",
"type": "application/vnd.abiquo.privateips+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/action/ips"
},
{
"title": "virtual datacenters",
"rel": "cloud/virtualdatacenters",
"type": "application/vnd.abiquo.virtualdatacenters+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/action/virtualdatacenters"
},
{
"title": "reserved machines",
"rel": "reservedmachines",
"type": "application/vnd.abiquo.machines+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/reservedmachines"
},
{
"title": "limits",
"rel": "limits",
"type": "application/vnd.abiquo.limits+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/limits"
},
{
"title": "volumes",
"rel": "volumes",
"type": "application/vnd.abiquo.volumes+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/action/volumes"
},
{
"title": "external networks",
"rel": "externalnetworks",
"type": "application/vnd.abiquo.vlans+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/action/externalnetworks"
},
{
"title": "pending tasks",
"rel": "pendingtasks",
"type": "application/vnd.abiquo.tasks+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/action/pendingtasks"
},
{
"title": "credentials",
"rel": "credentials",
"type": "application/vnd.abiquo.publiccloudcredentialslist+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/credentials"
},
{
"title": "virtual appliances specs",
"rel": "vappspecs",
"type": "application/vnd.abiquo.virtualappliancespecs+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/vappspecs"
}
],
"ramSoftLimitInMb": 10240,
"ramHardLimitInMb": 20480,
"cpuCountSoftLimit": 20,
"cpuCountHardLimit": 20,
"diskSoftLimitInMb": 10240,
"diskHardLimitInMb": 20480,
"storageSoftInMb": 0,
"storageHardInMb": 0,
"vlansSoft": 10,
"vlansHard": 10,
"publicIpsSoft": 10,
"publicIpsHard": 10,
"repositorySoftInMb": 0,
"repositoryHardInMb": 0,
"id": 2,
"name": "Tioco",
"isReservationRestricted": false,
"workflow": false,
"twoFactorAuthenticationMandatory": false
}
1.2 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:
curl -X POST https://mjsabiquo.bcn.abiquo.com/api/admin/enterprises/2/limits \
-H 'Accept:application/vnd.abiquo.limit+json; version=3.8' \
-H 'Content-Type:application/vnd.abiquo.limit+json; version=3.8' \
-d @requestpayload.json \
-u user:password --verbose
Success status code: 201
Request payload:
{
"cpuCountHardLimit": 0,
"ramSoftLimitInMb": 0,
"links": [
{
"href": "https://mjsabiquo.bcn.abiquo.com/api/admin/datacenters/4",
"rel": "location"
}
],
"vlansHard": 0,
"publicIpsHard": 0,
"publicIpsSoft": 0,
"ramHardLimitInMb": 0,
"vlansSoft": 0,
"cpuCountSoftLimit": 0
}
Response payload:
Click here to expand...
{
"links": [
{
"title": "Abiquo",
"rel": "enterprise",
"type": "application/vnd.abiquo.enterprise+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/1"
},
{
"title": "hypervisors",
"rel": "hypervisors",
"type": "application/vnd.abiquo.hypervisortypes+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/1/limits/5/hypervisors"
},
{
"title": "edit datacenter limits 5",
"rel": "edit",
"type": "application/vnd.abiquo.limit+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/1/limits/5"
},
{
"title": "external networks",
"rel": "externalnetworks",
"type": "application/vnd.abiquo.vlans+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/1/limits/5/externalnetworks"
},
{
"title": "virtualappliances",
"rel": "action",
"type": "application/vnd.abiquo.virtualappliances+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/1/limits/5/action/virtualappliances"
},
{
"title": "BCDC",
"rel": "location",
"type": "application/vnd.abiquo.datacenter+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/datacenters/4"
},
{
"title": "Default Tier 1",
"rel": "tier",
"type": "application/vnd.abiquo.tier+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/datacenters/4/storage/tiers/13"
},
{
"title": "Default Tier 2",
"rel": "tier",
"type": "application/vnd.abiquo.tier+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/datacenters/4/storage/tiers/14"
},
{
"title": "Default Tier 3",
"rel": "tier",
"type": "application/vnd.abiquo.tier+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/datacenters/4/storage/tiers/15"
},
{
"title": "Default Tier 4",
"rel": "tier",
"type": "application/vnd.abiquo.tier+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/datacenters/4/storage/tiers/16"
},
{
"title": "Default Tier",
"rel": "datastoretier",
"type": "application/vnd.abiquo.datastoretier+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/datacenters/4/datastoretiers/4"
}
],
"ramSoftLimitInMb": 0,
"ramHardLimitInMb": 0,
"cpuCountSoftLimit": 0,
"cpuCountHardLimit": 0,
"diskSoftLimitInMb": 0,
"diskHardLimitInMb": 0,
"storageSoftInMb": 0,
"storageHardInMb": 0,
"vlansSoft": 0,
"vlansHard": 0,
"publicIpsSoft": 0,
"publicIpsHard": 0,
"repositorySoftInMb": 0,
"repositoryHardInMb": 0,
"id": 5
}
You can now get the main cloud admin (whose user ID is 1) from whichever enterprise they are in by using a query over all enterprises represented by the underscore character "_".
curl -X GET "https://mjsabiquo.bcn.abiquo.com/api/admin/enterprises/_/users/1" \
-H "Accept: application/vnd.abiquo.user+json;version=3.8"
And you can switch enterprise to the new tenant by editing the user entity, adding a link to the correct enterprise and performing a put request to the user in any enterprise.
So for example, to switch to the new enterprise.
curl -X PUT "https://mjsabiquo.bcn.abiquo.com/api/admin/enterprises/_/users/1" \
-H "Accept: application/vnd.abiquo.user+json;version=3.8" \
-H "Content-Type: application/vnd.abiquo.user+json;version=3.8" \
-d @requestpayload.json \
-u user:password --verbose
{
"links": [
{
"rel": "enterprise",
"href": "https://mjsabiquo.bcn.abiquo.com/api/admin/enterprises/2"
},
...
1.3 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.
Create an Enterprise Admin
The enterprise admin user will administer the tenant. This user is allowed to create users within the tenant. The ID of the ENTERPRISE_ADMIN role is 3. The username is given as the "nick" element. Modify and submit the following request to create an enterprise admin user.
Click here to expand...
cURL:
curl -X POST https://mjsabiquo.bcn.abiquo.com/api/admin/enterprises/2/users \
-H 'Accept:application/vnd.abiquo.user+json; version=3.8' \
-H 'Content-Type:application/vnd.abiquo.user+json; version=3.8' \
-d @requestpayload.xml \
-u user:password --verbose
Success status code: 201
Request payload:
{
"surname": "Admin",
"name": "Ent",
"links": [
{
"href": "{{protocol}}{{host}}/api/admin/roles/3",
"rel": "role"
}
],
"locale": "EN",
"nick": "entadmin",
"firstLogin": true,
"active": true,
"locked": false,
"password": "entadmin",
"email": "entadmin@example.com",
"description": "tutorial user"
}
Response payload:
{
"links": [
{
"title": "Tioco",
"rel": "enterprise",
"type": "application/vnd.abiquo.enterprise+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2"
},
{
"title": "ENTERPRISE_ADMIN",
"rel": "role",
"type": "application/vnd.abiquo.role+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/roles/3"
},
{
"title": "entadmin",
"rel": "edit",
"type": "application/vnd.abiquo.user+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users/5"
},
{
"title": "virtual machines",
"rel": "virtualmachines",
"type": "application/vnd.abiquo.virtualmachines+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users/5/action/virtualmachines"
},
{
"title": "pending tasks",
"rel": "pendingtasks",
"type": "application/vnd.abiquo.tasks+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users/5/action/pendingtasks"
},
{
"title": "applications",
"rel": "applications",
"type": "application/vnd.abiquo.applications+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users/5/applications"
}
],
"id": 5,
"name": "Ent",
"nick": "entadmin",
"locale": "EN",
"surname": "Admin",
"active": true,
"email": "entadmin@example.com",
"description": "tutorial user",
"firstLogin": true,
"locked": false,
"authType": "ABIQUO"
}
Create a Cloud User
Modify and submit the following request to create a cloud user with the USER role.
Click here to expand...
cURL:
curl -X POST https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users \
-H 'Accept:application/vnd.abiquo.user+json; version=3.8' \
-H 'Content-Type:application/vnd.abiquo.user+json; version=3.8' \
-d @requestpayload.xml \
-u user:password --verbose
Success status code: 201
Request payload:
{
"surname": "User",
"name": "Cloud",
"links": [
{
"href": "{{protocol}}{{host}}/api/admin/roles/2",
"rel": "role"
}
],
"locale": "EN",
"nick": "clouduser",
"firstLogin": true,
"active": true,
"locked": false,
"password": "clouduser",
"email": "clouduser@example.com",
"description": "tutorial cloud user"
}
Response payload:
{
"links": [
{
"title": "Tioco",
"rel": "enterprise",
"type": "application/vnd.abiquo.enterprise+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2"
},
{
"title": "USER",
"rel": "role",
"type": "application/vnd.abiquo.role+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/roles/2"
},
{
"title": "clouduser",
"rel": "edit",
"type": "application/vnd.abiquo.user+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users/6"
},
{
"title": "virtual machines",
"rel": "virtualmachines",
"type": "application/vnd.abiquo.virtualmachines+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users/6/action/virtualmachines"
},
{
"title": "pending tasks",
"rel": "pendingtasks",
"type": "application/vnd.abiquo.tasks+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users/6/action/pendingtasks"
},
{
"title": "applications",
"rel": "applications",
"type": "application/vnd.abiquo.applications+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users/6/applications"
}
],
"id": 6,
"name": "Cloud",
"nick": "clouduser",
"locale": "EN",
"surname": "User",
"active": true,
"email": "clouduser@example.com",
"description": "tutorial cloud user",
"firstLogin": true,
"locked": false,
"authType": "ABIQUO"
}
1.4 Switch enterprises
Unable to render {include} The included page could not be found.
2. Add Virtual Machine Templates to the Appliance Library
The Appliance Library stores virtual machine templates so that users can easily deploy virtual machines from these templates. Templates can be downloaded from a remote repository or uploaded from a local machine. The appliance library templates are available to the virtual datacenters. From there an enterprise administrator or user can add the virtual machine template to a virtual appliance for deployment in the cloud.
2.1 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.
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 EnterpriseResource - Retrieve the list of enterprise identifiers and names
Get the Enterprise Repositories
Using the enterprise ID, retrieve all the repositories for your enterprise.
cURL:
curl --verbose -X GET https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories \
-H "Accept: application/vnd.abiquo.datacenterrepositories+json; version=3.8;" \
-u user:password
Success status code: 200
Request payload:
-- none --
Response payload:
Click here to expand...
{
"links": [],
"collection": [
{
"links": [
{
"title": "Tioco",
"rel": "enterprise",
"type": "application/vnd.abiquo.enterprise+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2"
},
{
"title": "192.168.2.10:/volume1/nfs-devel-claranet",
"rel": "edit",
"type": "application/vnd.abiquo.datacenterrepository+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1"
},
{
"title": "virtual machine templates",
"rel": "virtualmachinetemplates",
"type": "application/vnd.abiquo.virtualmachinetemplates+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates"
},
{
"title": "disks",
"rel": "disks",
"type": "application/vnd.abiquo.disks+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/action/disks"
},
{
"title": "refresh",
"rel": "refresh",
"type": "application/vnd.abiquo.acceptedrequest+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/actions/refresh"
},
{
"title": "tasks",
"rel": "tasks",
"type": "application/vnd.abiquo.tasks+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/tasks"
},
{
"title": "BCDC",
"rel": "datacenter",
"type": "application/vnd.abiquo.datacenter+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/datacenters/1"
},
{
"rel": "applianceManagerRepositoryUri",
"href": "http://mjsabiquo.bcn.abiquo.com:8009/am/erepos/2"
}
],
"name": "virtual image repo",
"repositoryLocation": "192.168.2.10:/volume1/nfs-devel-claranet"
}
]
}
To refresh the enterprise datacenter repository, perform a put request to the refresh link in the datacenter repository entity shown above.
cURL:
curl --verbose -X PUT https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/13/datacenterrepositories/8/actions/refresh \
-H "Accept: application/vnd.abiquo.acceptedrequest+json; version=3.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.
{
"links": [
{
"rel": "status",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/tasks/15007309-8b96-40b3-9fc5-afe1c96c31b9"
}
],
"entity": "You can keep track of the progress in the link"
}
Remember that the refresh is an asynchronous task, so you should wait until it has completed to go on to the next step.
2.2 Retrieve a compatible template
If you have already downloaded 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 (Core) and limit the number of templates returned to 1.
Remember that in Abiquo, you create a virtual machine 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 needed a fully template entity for just one template, you could remove the collection information or perform another request to retrieve just the desired template.
Click here to expand...
cURL:
curl --verbose -X GET https://mjsabiquo.bcn.abiquo.com/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates?hypervisorTypeName=VMX_04&limit=1&has=m0n0wall \
-H "Accept: application/vnd.abiquo.virtualmachinetemplates+json; version=3.8;" \
-u user:password
Response payload:
{
"links": [
{
"rel": "first",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates?hypervisorTypeName=VMX_04&limit=1&has=m0n0wall&by=state"
},
{
"rel": "next",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates?hypervisorTypeName=VMX_04&startwith=1&limit=1&has=m0n0wall&by=state"
},
{
"rel": "last",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates?hypervisorTypeName=VMX_04&startwith=1&limit=1&has=m0n0wall&by=state"
}
],
"collection": [
{
"links": [
{
"title": "Tioco",
"rel": "enterprise",
"type": "application/vnd.abiquo.enterprise+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2"
},
{
"title": "Others",
"rel": "category",
"type": "application/vnd.abiquo.category+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/config/categories/1"
},
{
"title": "m0n0wall",
"rel": "edit",
"type": "application/vnd.abiquo.virtualmachinetemplate+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates/7"
},
{
"title": "tasks",
"rel": "tasks",
"type": "application/vnd.abiquo.tasks+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates/7/tasks"
},
{
"title": "repository",
"rel": "datacenterrepository",
"type": "application/vnd.abiquo.datacenterrepository+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1"
},
{
"title": "virtual machines",
"rel": "virtualmachines",
"type": "application/vnd.abiquo.virtualmachines+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates/7/action/virtualmachines"
},
{
"title": "disks",
"rel": "disks",
"type": "application/vnd.abiquo.disks+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates/7/disks"
},
{
"title": "scsi0:0",
"rel": "disk0",
"type": "application/vnd.abiquo.disk+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates/7/disks/8"
},
{
"title": "template definition",
"rel": "templatedefinition",
"href": "http://files.template-repository.abiquo.com/m0n0wall/m0n0wall-1.3b18-i386-monolithicFlat.1.5.ovf"
},
{
"title": "template path",
"rel": "templatePath",
"href": "http://mjsabiquo.bcn.abiquo.com:8009/am/erepos/2/templates/2/files.template-repository.abiquo.com/m0n0wall/"
}
],
"chefEnabled": false,
"cpuRequired": 1,
"creationDate": "2016-09-27T09:35:10.000+0000",
"creationUser": "SYSTEM",
"description": "m0n0wall is a project aimed at creating a complete, embedded firewall software package that, when used together with an embedded PC, provides 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, password: abiquo. Configure MANUALLY the private IP of abicloud and it's done.",
"ethernetDriverType": "E1000",
"iconUrl": "http://abispace.s3.amazonaws.com/m0n0wall/m0n0wall_logo.png",
"id": "7",
"name": "m0n0wall",
"osType": "LINUX_2_6",
"ramRequired": 128,
"shared": false,
"state": "DONE",
"variables": {},
"enableCpuHotAdd": false,
"enableRamHotAdd": false,
"enableDisksHotReconfigure": false,
"enableNicsHotReconfigure": false,
"enableRemoteAccessHotReconfigure": false
}
],
"totalSize": 2
}
2.3 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 (TemplateDefinitionListResource) 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.
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 definitions.
Click here to expand...
cURL:
curl --verbose -X GET https://mjsabiquo.bcn.abiquo.com/api/admin/enterprises/2/appslib/templateDefinitionsLists \
-H "Accept: application/vnd.abiquo.templatedefinitionslists+json; version=3.8;" \
-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 returned by this query. I searched for the template name and cut and paste the required template.
Click here to expand...
...
{
"links": [
{
"title": "Tioco",
"rel": "enterprise",
"type": "application/vnd.abiquo.enterprise+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2"
},
{
"title": "Firewall",
"rel": "category",
"type": "application/vnd.abiquo.category+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/config/categories/8"
},
{
"title": "Repository 2.0",
"rel": "templateDefinitionList",
"type": "application/vnd.abiquo.templatedefinitionlist+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/appslib/templateDefinitionLists/2"
},
{
"title": "Zentyal 2.2.2 x86_64.",
"rel": "edit",
"type": "application/vnd.abiquo.templatedefinition+json",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/appslib/templateDefinitions/14"
}
],
"description": "Zentyal 2.2.2 ready to be used on your abiquo. http://wiki.abiquo.com/display/Abiquo/Zentyal+image.",
"iconUrl": "http://files.template-repository.abiquo.com/zentyal-2.2.2-x86_64/zentyal.png",
"id": 14,
"name": "Zentyal 2.2.2 x86_64.",
"osType": "UNRECOGNIZED",
"productName": "Zentyal 2.2.2 x86_64.",
"url": "http://files.template-repository.abiquo.com/zentyal-2.2.2-x86_64/desc.ovf",
"templateDefinitionDisks": [
{
"links": [],
"diskFormatType": "VMDK_STREAM_OPTIMIZED",
"diskFileSize": 1005318656,
"hdRequired": 12884901888
}
]
}
...
Create a template from a template definition
You can create a template in the Apps library from a link to the template definition retrieved above. This is equivalent to downloading a template from the remote repository to the Apps library. To create the virtual machine 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 virtual machine. The template ID is given in the task link
Click here to expand...
cURL:
curl -X POST https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates \
-H 'Accept:application/vnd.abiquo.acceptedrequest+json;version=3.8' \
-H 'Content-Type:application/vnd.abiquo.virtualmachinetemplaterequest+json;version=3.8' \
-d @requestpayload.json \
-u user:password --verbose
Success status code: 202
Request payload:
{
"links": [
{
"https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/appslib/templateDefinitions/14",
"rel": "templateDefinition"
}
]
}
Response payload:
{
"links": [
{
"rel": "status",
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates/18/tasks/d2e1d5cd-052d-4676-9a8e-84d358516266"
}
],
"entity": "You can keep track of the progress in the link"
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.