...
Numberedheadings | ||||
---|---|---|---|---|
| ||||
Send a GET request to the API login resource to obtain an authorization tokenIf you wish to use token authentication, which is more secure and required for 2FA, do these steps. Use basic authentication and get the token from the X-Abiquo-Token header. Or if you are using 2FA, you can get the 2FA verification code in the usual way (by email or from Google Authenticator). Log in again and send the 2FA verification code. Now you can get the token from the X-Abiquo-Token header of the response. In your API requests, use the token in a header with the following format. In these examples we have shortened the token to make the requests easier to read. For more details, see You can also get the token from the UI! Go to the browser Developer console on the Network tab and in the request responses look for the X-Abiquo-Token header. Get the template detailsGet the enterprise, for example, by using the "has" parameter to filter by a text string in the enterprise names from the list enterprises request. https://wiki.abiquo.com/api/latest/EnterprisesResource.html#list-enterprises If you are not already working with this enterprise, switch enterprise by updating the user from any enterprise (underscore character) to the new enterprise. https://wiki.abiquo.com/api/latest/UsersResource.html#update-a-user-of-an-enterprise
Get the link to the enterprise's datacenter repository for the appropriate datacenter. The link to the datacenter repositories can be found in the Enterprise entity. From this link you can get the datacenter repositories. https://wiki.abiquo.com/api/latest/DatacenterRepositoriesResource.html#list-datacenter-repositories Select the appropriate repo and then get the link to the virtual machine templates. Get the templates, and find the appropriate template. You can use the "has" parameter to search for the template by name. The template will contain a link to the template disks. Get the template disks, and find the disk you wish to replace. Get the diskUrl and currentPath of the disk. Response payload: Create the replacement objectFrom the above response, we need
From the example above, for the first disk with sequence a number of "0", we have the following. diskReplace.json From the above response, the URL from the disk edit link is used as the diskUrl and the path is used as the currentPath in the JSON request payload to modify the template object. Here is an example object. For the "requiredHDInMB" you must enter the correct capacity or deployed size of the disk. The capacity value is stored in the disk file itself. See Abiquo does not validate the value that you enter and if you enter an incorrect value, the platform will try to deploy the disk with its true capacity. The deploy may fail and the platform will not be able to properly check that the disk will fit on the hypervisor datastore. Important note: You cannot resize (expand) a boot disk before you deploy a VM. After you expand any disk, remember to update the configuration of the disk in the VM operating system. The default value for the diskControllerType is "IDE" and the default value for the diskController is NULL. If your template uses a different controller, such as "SCSI" and "lsilogic", you must add these values in the diskReplace.json entity, as shown above. If you do not add them, the platform will overwrite your template with its default values. You should note that the AM API does not support all of the values that are supported by the Abiquo API. Replace the fileReplace the file using the Appliance manager API. The URL to post to contains the enterprise ID and the template folder in the following format. The template folder is the folder path on the NFS Repository, without the file name. For our example: The folder path is as follows: The template path does not contain the ID of the datacenter repository. It contains the folder name from /opt/vm_repository. Use this information to build the request to replace the disk. If your folder name contains spaces, encode the section of the name that contains spaces for the URL. For example, for a disk with "abc abc" in the name, you should encode it to With this encoding, the server will correctly read the URL as "abc%20abc". If you use the request without encoding, it may destroy your original disk file. cURL Replace newdisk.vmdk with the name of your disk file on the local file system. Save the disk replacement object you created previously to a file called diskReplace.json Success status code: 201 Created Check the disk fileYou can check the new disk file on the file system using the details in the Location link in the above response. And in this case, we retrieved the template disks and checked the details of the disk file in the API. |
...