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.


Documentation

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 virtual machine 
  • 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 virtual machine, 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 search for a text string in the enterprise names.

 Click here to show or hide the generic request example

If you are not already working with this enterprise, switch enterprise. 

 Click here to show or hide the generic request example

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/506/datacenterrepositories", 
          "type": "application/vnd.abiquo.datacenterrepositories+json", 
          "rel": "datacenterrepositories", 
          "title": "repositories"
        }, 

From this link you can get the datacenter repositories.

 Click here to show or hide the generic request example

 

Select the appropriate repo and then get the link to the virtual machine templates.

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

Get the templates, and find the appropriate template, which will contain a link to the template disks.

 Click here to show or hide the generic request example

Get the template disks, and find the disk you wish to replace. The above examples are generic examples that should be automatically updated for each new release of Abiquo.

 Get the diskUrl and currentPath of the disk.

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

Response payload:

{
    "links": [],
    "collection": [
        {
            "links": [
                {
                    "title": "disk",
                    "rel": "edit",
                    "type": "application/vnd.abiquo.disk+json",
                    "href": "https://my.abiquo.com:443/api/admin/enterprises/8/datacenterrepositories/1/virtualmachinetemplates/10/disks/10"
                },
                {
                    "title": "conversions",
                    "rel": "conversions",
                    "type": "application/vnd.abiquo.conversions+json",
                    "href": "https://my.abiquo.com:443/api/admin/enterprises/8/datacenterrepositories/1/virtualmachinetemplates/10/disks/10/conversions"
                },
                {
                    "title": "m0n0wall",
                    "rel": "virtualmachinetemplate",
                    "type": "application/vnd.abiquo.virtualmachinetemplate+json",
                    "href": "https://my.abiquo.com:443/api/admin/enterprises/8/datacenterrepositories/1/virtualmachinetemplates/10"
                },
                {
                    "title": "m0n0wall-1.3b18-i386-flat",
                    "rel": "diskfile",
                    "href": "https://my.abiquo.com:443/am/files/8/repo.abiquo.com/e707a9e0-586c-4933-98f1-b5a9828c7d6e-m0n0wall.ova/m0n0wall/m0n0wall-1.3b18-i386-flat.vmdk"
                }
            ],
            "label": "scsi0:0",
            "sequence": 0,
            "path": "8/repo.abiquo.com/e707a9e0-586c-4933-98f1-b5a9828c7d6e-m0n0wall.ova/m0n0wall/m0n0wall-1.3b18-i386-flat.vmdk",
            "diskFormatType": "VMDK_FLAT",
            "diskFileSize": 27262976,
            "hdRequired": 27262976,
            "state": "DONE",
            "diskControllerType": "SCSI",
            "diskController": "lsilogic",
            "creationDate": "2015-09-28T10:33:16.000+0000",
            "bootable": true
        }
    ]
}

 

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, we have the following.

    "href": "https://my.abiquo.com:443/api/admin/enterprises/8/datacenterrepositories/1/virtualmachinetemplates/10/disks/10"
    "path": "8/repo.abiquo.com/e707a9e0-586c-4933-98f1-b5a9828c7d6e-m0n0wall.ova/m0n0wall/m0n0wall-1.3b18-i386-flat.vmdk", 

 

diskReplace.json

From this 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":true,
    "sequence":1,
    "requiredHDInMB":69,
    "diskFileFormat":"VMDK_FLAT",
    "virtualMachineTemplateUrl":"https://my.abiquo.com:443/api/admin/enterprises/8/datacenterrepositories/1/virtualmachinetemplates/10",
    "diskUrl":"https://my.abiquo.com:443/api/admin/enterprises/8/datacenterrepositories/1/virtualmachinetemplates/10/disks/10",
    "currentPath":"8/repo.abiquo.com/e707a9e0-586c-4933-98f1-b5a9828c7d6e-m0n0wall.ova/m0n0wall/m0n0wall-1.3b18-i386-flat.vmdk"
}

 

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.

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

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

8/repo.abiquo.com/e707a9e0-586c-4933-98f1-b5a9828c7d6e-m0n0wall.ova/m0n0wall

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

cURL

curl -k -v -u 'https://my.abiquo.com:443/am/erepos/8/templates/8/repo.abiquo.com/e707a9e0-586c-4933-98f1-b5a9828c7d6e-m0n0wall.ova/m0n0wall' -F "diskInfo=@diskReplace.json" -F "diskFile=@newDiskFile.vhd"

Replace newDiskFile.vhd with the name of your disk file on the local file system. Enter the disk capacity.

Here is an example of the diskReplace file.

diskReplace.json

{ 
    "bootable":true,
    "sequence":1,
    "requiredHDInMB":26,
    "diskFileFormat":"VHD_SPARSE",
    "virtualMachineTemplateUrl":"https://my.abiquo.com:443/api/admin/enterprises/8/datacenterrepositories/1/virtualmachinetemplates/10",
    "diskUrl":"https://my.abiquo.com:443/api/admin/enterprises/8/datacenterrepositories/1/virtualmachinetemplates/10/disks/10",
    "currentPath":"8/repo.abiquo.com/e707a9e0-586c-4933-98f1-b5a9828c7d6e-m0n0wall.ova/m0n0wall/m0n0wall-1.3b18-i386-flat.vmdk"
}

Example request:

> POST /am/erepos/8/templates/8/repo.abiquo.com/e707a9e0-586c-4933-98f1-b5a9828c7d6e-m0n0wall.ova/m0n0wall HTTP/1.1
> Authorization: Basic YWRtaW46eGFiaXF1bw==
> User-Agent: curl/7.35.0
> Host: my.abiquo.com
> Accept: */*
> Content-Length: 10491775
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------0cfebb4f05bf81ed
> 
< HTTP/1.1 100 Continue
< HTTP/1.1 201 Created
< Date: Tue, 29 Sep 2015 10:54:51 GMT
< Location: https://my.abiquo.com/am/erepos/8/templates/8/repo.abiquo.com/e707a9e0-586c-4933-98f1-b5a9828c7d6e-m0n0wall.ova/m0n0wall/f121723f-db7a-41da-9f80-c561b01aadeb-newDiskFile.vhd
< Content-Length: 0
< Content-Type: text/plain
< 
* 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 using the details in the Location link.