Table of Contents |
---|
Numberedheadings | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
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. This tutorial uses the Cloud Administrator default account and does not show proper authentication Before you begin this tutorial, you should create a datacenter (for API instructions, see Create an enterprise and usersWhen 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 enterpriseThe following request creates an enterprise with enterprise resource allocation limits. cURL: Success status code: 201 Request payload: Response payload: Create an enterprise-datacenter limit for the new enterpriseAn 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: Success status code: 201 Request payload: Response payload: Switch to the new enterpriseTo 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 usersThe 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 adminThe 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 userModify 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 libraryThe 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 libraryAn 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 IDTo 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 repositoriesUsing the enterprise ID, retrieve all the repositories for your enterprise. cURL: Success status code: 200 Request payload: -- none -- Response payload: Perform the refreshTo 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 templateIf 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 repositoryIf 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 oneIf 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 definitionYou 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 |