A Machine Template represents the set of metadata and instructions used in the creation of a Machine. A Machine Template Collection resource represents the collection of Machine Template resources within a Provider.
The CIMI specification follows a distinctive pattern with respect to creation of new resources - the machine template is a good example of this:
machineConfiguration + machineImage = machineTemplate ===> machine
A CIMI client (a consumer in CIMI terminology) uses a Machine Template to create a new Machine; a Machine Template consists of (amongst other attributes) a Machine Configuration and a Machine Image. Generally speaking - many CIMI resources require the use of a template for their creation and a template will typically consist of an image plus a configuration resource.
Example request:
GET /cimi/machine_templates HTTP/1.1 Authorization: Basic bW9ja3VzZXI6bW9ja3Bhc3N3b3Jk User-Agent: curl/7.24.0 (i686-redhat-linux-gnu) Host: localhost:3001 Accept: application/xml
Server response:
HTTP/1.1 200 OK Content-Type: application/xml CIMI-Specification-Version: 1.0.1 Content-Length: 1275 ETag: fba471ae32eca2b58fa02644b81b73aa Cache-Control: max-age=0, private, must-revalidate Date: Thu, 03 Jan 2013 15:04:26 GMT Connection: keep-alive Server: thin 1.5.0 codename Knife <Collection xmlns="http://schemas.dmtf.org/cimi/1" resourceURI="http://schemas.dmtf.org/cimi/1/MachineTemplateCollection"> <id>http://localhost:3001/cimi/machine_templates</id> <count>2</count> <MachineTemplate> <id>http://localhost:3001/cimi/machine_templates/1</id> <name>myXmlTestMachineTemplate1</name> <description>Description of my MachineTemplate</description> <property key="test">value</property> <machineConfig href="http://localhost:3001/cimi/machine_configurations/m1-xlarge" /> <machineImage href="http://localhost:3001/cimi/machine_images/img3" /> <operation rel="http://schemas.dmtf.org/cimi/1/action/delete" href="http://localhost:3001/cimi/machine_templates/1" /> </MachineTemplate> <MachineTemplate> <id>http://localhost:3001/cimi/machine_templates/2</id> <name>my_template_2</name> <description>Description of my MachineTemplate</description> <property key="test">value</property> <machineConfig href="http://localhost:3001/cimi/machine_configurations/m1-small" /> <machineImage href="http://localhost:3001/cimi/machine_images/img1" /> <operation rel="http://schemas.dmtf.org/cimi/1/action/delete" href="http://localhost:3001/cimi/machine_templates/2" /> </MachineTemplate> </Collection>
Example request:
GET /cimi/machine_templates/2 HTTP/1.1 Authorization: Basic bW9ja3VzZXI6bW9ja3Bhc3N3b3Jk User-Agent: curl/7.24.0 (i686-redhat-linux-gnu) Host: localhost:3001 Accept: application/xml
Server response:
HTTP/1.1 200 OK Content-Type: application/xml CIMI-Specification-Version: 1.0.1 Content-Length: 607 ETag: 8f720ffacb6439a6920a5f5b0ec7bbfc Cache-Control: max-age=0, private, must-revalidate Date: Thu, 03 Jan 2013 15:06:14 GMT Connection: keep-alive Server: thin 1.5.0 codename Knife <MachineTemplate xmlns="http://schemas.dmtf.org/cimi/1" resourceURI="http://schemas.dmtf.org/cimi/1/MachineTemplate"> <id>http://localhost:3001/cimi/machine_templates/2</id> <name>my_template_2</name> <description>Description of my MachineTemplate</description> <property key="test">value</property> <machineConfig href="http://localhost:3001/cimi/machine_configurations/m1-small" /> <machineImage href="http://localhost:3001/cimi/machine_images/img1" /> <operation rel="http://schemas.dmtf.org/cimi/1/action/delete" href="http://localhost:3001/cimi/machine_templates/2" /> </MachineTemplate>
Example request:
POST /cimi/machine_templates HTTP/1.1 Authorization: Basic bW9ja3VzZXI6bW9ja3Bhc3N3b3Jk User-Agent: curl/7.24.0 (i686-redhat-linux-gnu) Host: localhost:3001 Content-Type: application/xml Accept: application/xml Content-Length: 334 <MachineTemplateCreate> <name>myXmlTestMachineTemplate1</name> <description>Description of my MachineTemplate</description> <property key="test">value</property> <machineConfig href="http://localhost:3001/cimi/machine_configurations/m1-xlarge"/> <machineImage href="http://localhost:3001/cimi/machine_images/img3"/> </MachineTemplateCreate>
Server response:
HTTP/1.1 201 Created Content-Type: application/xml Location: http://localhost:3001/cimi/machine_templates/1 CIMI-Specification-Version: 1.0.1 Content-Length: 620 ETag: e848e33fa0886e6c3d2df3cb674485d7 Cache-Control: max-age=0, private, must-revalidate Date: Thu, 03 Jan 2013 14:48:03 GMT Connection: keep-alive Server: thin 1.5.0 codename Knife <MachineTemplate xmlns="http://schemas.dmtf.org/cimi/1" resourceURI="http://schemas.dmtf.org/cimi/1/MachineTemplate"> <id>http://localhost:3001/cimi/machine_templates/1</id> <name>myXmlTestMachineTemplate1</name> <description>Description of my MachineTemplate</description> <property key="test">value</property> <machineConfig href="http://localhost:3001/cimi/machine_configurations/m1-xlarge" /> <machineImage href="http://localhost:3001/cimi/machine_images/img3" /> <operation rel="http://schemas.dmtf.org/cimi/1/action/delete" href="http://localhost:3001/cimi/machine_templates/1" /> </MachineTemplate>
Example request:
DELETE /cimi/machine_templates/2 HTTP/1.1 Authorization: Basic bW9ja3VzZXI6bW9ja3Bhc3N3b3Jk User-Agent: curl/7.24.0 (i686-redhat-linux-gnu) Host: localhost:3001 Accept: application/xml
Server response:
HTTP/1.1 200 OK X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff Content-Type: text/html;charset=utf-8 CIMI-Specification-Version: 1.0.1 Content-Length: 0 Date: Thu, 03 Jan 2013 15:06:38 GMT Connection: keep-alive Server: thin 1.5.0 codename Knife