Abiquo Documentation Cookies Policy

Our Documentation website uses cookies to improve your experience. Please visit our Cookie Policy page for more information about cookies and how we use them.


Abiquo 4.7

Skip to end of metadata
Go to start of metadata

 

  This document describes how to upload and replace existing template disks using the Appliance manager API.

No URL and path validation

The request used in this section does NOT check that the disk URL refers to the currentPath.

Check that you are posting to the correct URL and that you have entered the correct values before running this request.

Use Case

  • Upload or download a template
  • Use it to create a VM 
  • Update the template.  Abiquo supports changes to:
    • file content
    • size
    • format
    • capacity
    Update the disk using the Appliance manager API 
  • When the user next deploys the VM, the platform will copy the updated disk

Steps

  1. Get the template details from the Abiquo API
  2. Create the replacement data object
  3. Replace the file using the Appliance manager API

Example

 

1. Get the template details

First get 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

 Click here to show or hide the generic request example

PUT_adm_ents_ALL_users_X_CT_user_j_AC_user_j.0001.txt

cURL:

curl -X PUT http://localhost:9000/api/admin/enterprises/_/users/959 \ 
	 -H 'Accept:application/vnd.abiquo.user+json; version=4.2' \ 
	 -H 'Content-Type:application/vnd.abiquo.user+json; version=4.2' \ 
	 -d @requestpayload.json \ 
	 -u user:password --verbose 

Success status code: 200

Request payload:

{
  "authType": "ABIQUO", 
  "surname": "620", 
  "name": "619", 
  "links": [
    {
      "href": "http://localhost:9009/api/admin/roles/919", 
      "type": "application/vnd.abiquo.role+json", 
      "rel": "role", 
      "title": "617"
    }, 
    {
      "href": "http://localhost:9009/api/admin/enterprises/1276/users/959", 
      "type": "application/vnd.abiquo.user+json", 
      "rel": "edit", 
      "title": "621"
    }, 
    {
      "href": "http://localhost:9009/api/admin/scopes/943", 
      "type": "application/vnd.abiquo.scope+json", 
      "rel": "scope", 
      "title": "Global scope"
    }, 
    {
      "href": "http://localhost:9009/api/admin/enterprises/1276/users/959/action/virtualmachines", 
      "type": "application/vnd.abiquo.virtualmachines+json", 
      "rel": "virtualmachines", 
      "title": "virtual machines"
    }, 
    {
      "href": "http://localhost:9009/api/admin/enterprises/1276/users/959/action/pendingtasks", 
      "type": "application/vnd.abiquo.tasks+json", 
      "rel": "pendingtasks", 
      "title": "pending tasks"
    }, 
    {
      "href": "http://localhost:9009/api/admin/enterprises/1276/users/959/applications", 
      "type": "application/vnd.abiquo.applications+json", 
      "rel": "applications", 
      "title": "applications"
    }, 
    {
      "href": "http://localhost:9009/api/admin/enterprises/1277", 
      "rel": "enterprise"
    }
  ], 
  "locale": "622", 
  "email": "abc@example.com", 
  "nick": "621", 
  "firstLogin": false, 
  "active": true, 
  "locked": false, 
  "id": 959
}

Response payload:

{
  "authType": "ABIQUO", 
  "surname": "620", 
  "name": "619", 
  "links": [
    {
      "href": "http://localhost:9009/api/admin/enterprises/1277", 
      "type": "application/vnd.abiquo.enterprise+json", 
      "rel": "enterprise", 
      "title": "615"
    }, 
    {
      "href": "http://localhost:9009/api/admin/roles/919", 
      "type": "application/vnd.abiquo.role+json", 
      "rel": "role", 
      "title": "617"
    }, 
    {
      "href": "http://localhost:9009/api/admin/enterprises/1277/users/959", 
      "type": "application/vnd.abiquo.user+json", 
      "rel": "edit", 
      "title": "621"
    }, 
    {
      "href": "http://localhost:9009/api/admin/scopes/943", 
      "type": "application/vnd.abiquo.scope+json", 
      "rel": "scope", 
      "title": "Global scope"
    }, 
    {
      "href": "http://localhost:9009/api/admin/enterprises/1277/users/959/action/virtualmachines", 
      "type": "application/vnd.abiquo.virtualmachines+json", 
      "rel": "virtualmachines", 
      "title": "virtual machines"
    }, 
    {
      "href": "http://localhost:9009/api/admin/enterprises/1277/users/959/action/pendingtasks", 
      "type": "application/vnd.abiquo.tasks+json", 
      "rel": "pendingtasks", 
      "title": "pending tasks"
    }, 
    {
      "href": "http://localhost:9009/api/admin/enterprises/1277/users/959/applications", 
      "type": "application/vnd.abiquo.applications+json", 
      "rel": "applications", 
      "title": "applications"
    }
  ], 
  "locale": "622", 
  "email": "abc@example.com", 
  "nick": "621", 
  "firstLogin": false, 
  "active": true, 
  "locked": false, 
  "id": 959
}

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.

    {
      "href": "http://localhost:9009/api/admin/enterprises/1690/datacenterrepositories",
      "type": "application/vnd.abiquo.datacenterrepositories+json",
      "rel": "datacenterrepositories",
      "title": "repositories"
    }, 

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.

    {
      "href": "http://localhost:9009/api/admin/enterprises/1690/datacenterrepositories/1046/virtualmachinetemplates",
      "type": "application/vnd.abiquo.virtualmachinetemplates+json",
      "rel": "virtualmachinetemplates",
      "title": "virtual machine templates"
    },

Get the templates, and find the appropriate template.

https://wiki.abiquo.com/api/latest/VirtualMachineTemplatesResource.html#list-virtual-machine-templates-in-a-datacenter-repository

The template will contain a link to the template disks.

Get the template disks, and find the disk you wish to replace. The above examples are automatically generated by different tests so the IDs of the objects might not match.

  Get the  diskUrl  and  currentPath  of the disk.

curl -X GET -H 'https://my.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/1235/disks' \
    -H "Accept: application/vnd.abiquo.disks+json;version=4.2" \
    -uadmin:xabiquo --verbose 

Response payload:

{
{
    "links": [],
    "collection": [
        {
            "label": "Hard disk 1",
            "sequence": 0,
            "path": "15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ/yVM-disk1.vmdk",
            "diskFormatType": "VMDK_STREAM_OPTIMIZED",
            "diskFileSize": 15189504,
            "hdRequired": 67108864,
            "state": "DONE",
            "diskControllerType": "IDE",
            "creationDate": "2018-04-11T17:26:19.000+0000",
            "bootable": true,
            "links": [
                {
                    "title": "disk",
                    "rel": "edit",
                    "type": "application/vnd.abiquo.disk+json",
                    "href": "https://my.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/1235/disks/1445"
                },
                {
                    "title": "conversions",
                    "rel": "conversions",
                    "type": "application/vnd.abiquo.conversions+json",
                    "href": "https://my.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/1235/disks/1445/conversions"
                },
                {
                    "title": "yVM_M1",
                    "rel": "virtualmachinetemplate",
                    "type": "application/vnd.abiquo.virtualmachinetemplate+json",
                    "href": "https://my.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/1235"
                },
                {
                    "title": "yVM-disk1",
                    "rel": "diskfile",
                    "href": "https://my.abiquo.com:443/am/files/15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ/yVM-disk1.vmdk"
                }
            ]
        },
        {
            "sequence": 1,
            "path": "15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ/disk2.qcow2",
            "diskFormatType": "QCOW2_SPARSE",
            "diskFileSize": 12976128,
            "hdRequired": 104857600,
            "state": "DONE",
            "diskControllerType": "SCSI",
            "diskController": "lsilogic",
            "creationDate": "2018-06-06T12:29:22.000+0000",
            "bootable": true,
            "links": [
                {
                    "title": "disk",
                    "rel": "edit",
                    "type": "application/vnd.abiquo.disk+json",
                    "href": "https://my.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/1235/disks/1561"
                },
                {
                    "title": "conversions",
                    "rel": "conversions",
                    "type": "application/vnd.abiquo.conversions+json",
                    "href": "https://my.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/1235/disks/1561/conversions"
                },
                {
                    "title": "yVM_M1",
                    "rel": "virtualmachinetemplate",
                    "type": "application/vnd.abiquo.virtualmachinetemplate+json",
                    "href": "https://my.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/1235"
                },
                {
                    "title": "9ec02624-b977-4e91-b4df-59bee9bdb26bCore",
                    "rel": "diskfile",
                    "href": "https://my.abiquo.com:443/am/files/15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ/disk2.qcow2"
                }
            ]
        }
    ]
}

 

2. Create the replacement object

From the above response, we need

  • the href URL from the disk edit link
  • the path

From the example above, for the second disk with sequence a number of "1", we have the following.

    "href": "https://my.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/1235/disks/1561"
    "path": "15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ/disk2.qcow2", 

 

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. 

Enter the space required by the disk as requiredHDInMB.

{ 
    "bootable":false,
    "sequence":1,
    "requiredHDInMB":120,
    "diskFileFormat":"QCOW2_SPARSE",
    "virtualMachineTemplateUrl":"https://my.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/1235",
    "diskUrl":"https://my.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/1235/disks/1563",
    "currentPath":"15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ/disk2.qcow2"
} 

 

3. Replace the file

Replace the file using the Appliance manager API.

The URL to post to contains the enteprise ID and the template folder in the following format.

/am/erepos/{enterpriseId}/templates/{templateFolder}

The template folder is the folder path on the NFS Repository, without the file name. In the above example:

15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ

Use this information to build the request to replace the disk.

cURL

curl -k -v -u 'https://my.abiquo.com:443/am/erepos/15/templates/15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ' -F "diskInfo=@diskReplace.json" -F "diskFile=@newdisk.qcow2"

Replace newdisk.qcow2  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

{ 
    "bootable":false,
    "sequence":1,
    "requiredHDInMB":120,
    "diskFileFormat":"QCOW2_SPARSE",
    "virtualMachineTemplateUrl":"https://my.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/1235",
    "diskUrl":"https://my.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/1235/disks/1563",
    "currentPath":"15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ/disk2.qcow2"
} 

Example request:

curl -v -k -X POST 'https://my.abiquo.com:443/am/erepos/15/templates/15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ' -F "diskInfo=@diskReplace.json" -F "diskFile=@newdisk.qcow2" -u"cloudadmin:cloudadmin"
* Hostname was NOT found in DNS cache
*   Trying 10.60.11.9...
* Connected to my.abiquo.com (10.60.11.9) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-AES256-GCM-SHA384
* Server certificate:
* 	 subject: C=ES; O=Abiquo; OU=Engineering; CN=my.abiquo.com
* 	 start date: 2017-02-06 16:14:05 GMT
* 	 expire date: 2027-02-04 16:14:05 GMT
* 	 issuer: C=ES; O=Abiquo; OU=Engineering; CN=my.abiquo.com
* 	 SSL certificate verify result: self signed certificate (18), continuing anyway.
* Server auth using Basic with user 'cloudadmin'
> POST /am/erepos/15/templates/15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ HTTP/1.1
> Authorization: Basic Y2xvdWRhZG1pbjpjbG91ZGFkbWlu
> User-Agent: curl/7.35.0
> Host: my.abiquo.com
> Accept: */*
> Content-Length: 198026
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------1337489fd8ccef17
> 
< HTTP/1.1 100 Continue
< HTTP/1.1 201 201
< Date: Wed, 06 Jun 2018 14:33:36 GMT
* Server Apache is not blacklisted
< Server: Apache
< Location: https://my.abiquo.com/am/erepos/15/templates/15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ/f3cc7e25-e215-4c76-8c83-6cb7738af247-newdisk.qcow2
< Content-Length: 0
< 
* Connection #0 to host my.abiquo.com left intact

Success status code: 201 Created

4. Check the disk file

You 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 that the details of the disk file in the API.

                {
                    "title": "f3cc7e25-e215-4c76-8c83-6cb7738af247-newdisk",
                    "rel": "diskfile",
                    "href": "https://my.abiquo.com:443/am/files/15/13b620da-0c2d-4a94-a31e-a4db6a00434d-yVM_MJ/f3cc7e25-e215-4c76-8c83-6cb7738af247-newdisk.qcow2"
                }