Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Current »

Introduction

Virtual Machine Templates are master copies of virtual machines that can be used to create and provision virtual machines. Templates by design, cannot be powered on or edited since they offer a more secure way of preserving a virtual machine configuration that you want to deploy many times. With the RESTful API you can build your own Virtual Machines and then mark them as templates, and vice versa. With this resource you can list our publicly available Templates and any you have created. 


On this page:

 The following table shows a brief description and HTTP methods allowed to interact with Virtual Machine Templates

ResourceURIDescriptionGETPOSTPUTPATCH
VM Templates/templateVirtual Machine Template resource. List Virtual Machine Templates.(tick) 


TK stores the Cloud API Token generated as a result of the following POST request to the /auth/request-token resource:

curl -X POST https://vss-api.eis.utoronto.ca/auth/request-token -u <username>

For example, extracting the token with the jq command:

TK=$(curl -X POST https://vss-api.eis.utoronto.ca/auth/request-token -u <username> | jq '.token')


List

In order to list available Virtual Machine Templates you should make a  GET request to the endpoint /v2/template, passing your access token. As a result, you will get a reference URI /v2/vm/<moref> to get detailed information about the object.

The following examples uses HTTPie and CURL to list all templates a user have access to:

http GET "https://vss-api.eis.utoronto.ca/v2/template" "Authorization: Bearer $TK"

curl -H "Authorization: Bearer $TK" -X GET "https://vss-api.eis.utoronto.ca/v2/template"
Response Body
{
    "_links": {
        "api": "https://vss-api.eis.utoronto.ca/v2", 
        "self": "https://vss-api.eis.utoronto.ca/v2/template"
    }, 
    "data": [
        {
            "_links": {
                "self": "https://vss-api.eis.utoronto.ca/v2/vm/5012f4f0-443b-9cc4-1256-3d78093e7d30"
            }, 
            "cpuCount": 1, 
            "folder": {
                "_links": {
                    "self": "https://vss-api.eis.utoronto.ca/v2/folder/group-v6807"
                }, 
                "moref": "group-v6807", 
                "name": "Templates", 
                "parent": "APIDemo"
            }, 
            "guestFullName": "Ubuntu Linux (64-bit)", 
            "ipAddress": null, 
            "memoryMB": 1024, 
            "name": "Ubuntu_64b-14.04", 
            "overallStatus": "green", 
            "powerState": "poweredOff", 
            "provisionedGB": 41, 
            "uuid": "5012f4f0-443b-9cc4-1256-3d78093e7d30"
        }
    ...
    ], 
    "meta": {
        "count": 4, 
        "time": "0.89966s", 
        "user": "jm"
    }
}

As you can see, this resource looks pretty much as the Virtual Machine resource, and in fact it uses the VM resource to provide further information about the Template. At the end a Virtual Machine template is a Virtual Machine with a different state, however you cannot edit a template until it's marked as Virtual Machine.

Filters

This resource has one filter and one flag to narrow down the number of Networks shown in the result.

NameDescription
nameVirtual Machine Template name
summaryEnables VM Template summary in results.

The following examples show how to narrow down a VM template search first by adding name as a parameter in the request and then adding summary for only showing uuid, _links and name.

http GET "https://vss-api.eis.utoronto.ca/v2/template?name=ubuntu&summary=1" "Authorization: Bearer $TK"

curl -X GET -H "Authorization: Bearer" "https://vss-api.eis.utoronto.ca/v2/template?name=ubuntu&summary=1"
Response Body - filtered by name=centos
{
    "_links": {
        "api": "https://vss-api.eis.utoronto.ca/v2/", 
        "self": "https://vss-api.eis.utoronto.ca/v2/template"
    }, 
    "data": [
        {
            "_links": {
                "self": "https://vss-api.eis.utoronto.ca/v2/vm/50122e44-9ddd-2497-7b6c-a3bc52749c52"
            }, 
            "cpuCount": 1, 
            "folder": {
                "_links": {
                    "self": "https://vss-api.eis.utoronto.ca/v2/folder/group-v6807"
                }, 
                "moref": "group-v6807", 
                "name": "Templates", 
                "parent": "APIDemo"
            }, 
            "guestFullName": "CentOS 4/5/6/7 (64-bit)", 
            "ipAddress": null, 
            "memoryMB": 2048, 
            "name": "CentOS_64b-7", 
            "overallStatus": "green", 
            "powerState": "poweredOff", 
            "provisionedGB": 42, 
            "uuid": "50122e44-9ddd-2497-7b6c-a3bc52749c52"
        }
    ], 
    "meta": {
        "count": 1, 
        "time": "0.77485s", 
        "user": "jm"
    }
}
Response Body - filtered by name=centos&summary
{
    "_links": {
        "api": "https://vss-api.eis.utoronto.ca/v2/", 
        "self": "https://vss-api.eis.utoronto.ca/v2/template"
    }, 
    "data": [
        {
            "_links": {
                "self": "https://vss-api.eis.utoronto.ca/v2/vm/50122e44-9ddd-2497-7b6c-a3bc52749c52"
            }, 
            "name": "CentOS_64b-7", 
            "uuid": "50122e44-9ddd-2497-7b6c-a3bc52749c52"
        }
    ], 
    "meta": {
        "count": 1, 
        "time": "0.69355s", 
        "user": "jm"
    }
}
  • No labels