You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2011/02/03 12:45:02 UTC

Create images from running or stopped EBS instances (EC2)

Hi,

This patch will add support for creating images from running or stopped
instances in Amazon EC2. EC2 support 'CreateImage' call for all EBS 
instances.

Deltacloud API implements that in this way:

POST /api/images
Parameters: { :instance_id => 'i-123123', :name => 'image name' }

I checked GoGrid and they have something similar[1] for 'sandbox'
instances. Which means that we will need to add some feature to
instances collection to create 'sandbox' instance in GoGrid.

I didn't check Rackspace but Ovi said that they have something very
similar.

Please let me know what do you think about this approach.

PS: I attached a working example for EC2, *but* you need to have patched
gem installed (you can grab one from my github account[2]). To install it:

git clone git://github.com/mifo/aws.git
git checkout myupstream
gem build aws.gemspec
gem uninstall aws
gem install --local aws.gem

Or wait until Appoxy's integrate my patch to upstream gem.

[1] http://wiki.gogrid.com/wiki/index.php/API:grid.image.save
[2] https://github.com/mifo/aws/tree/myupstream


Re: Create images from running or stopped EBS instances (EC2)

Posted by Michal Fojtik <mf...@redhat.com>.
On 04/02/11 16:40 -0800, David Lutterkort wrote:
>On Thu, 2011-02-03 at 15:17 +0100, Michal Fojtik wrote:
>> On 03/02/11 14:57 +0200, marios@redhat.com wrote:
>> >Hey Michal,
>> >
>> >here's a copy/paste from the notes I made about snapshots back in
>> >July - might be useful to have this in one place/save some time
>> >looking at the APIs (AWS, Rackspace, Rimu, Gogrid, Terremark):
>>
>> Thanks Marios! This seems to be very usefull and save me a lot of time
>> googling and reading all those docs.
>> After brief look, I have few suggestions for API:
>>
>>
>> >
>> ><PAST> :
>> >
>> >
>> >Q. Which of our currently supported clouds allows 'register custom
>> >Image from cloud storage', or, 'save/snapshot an Instance as a new
>> >Image'
>> >-----------------------------------------------------------------
>> >--i--> Amazon AWS allows you to register an object in S3 as an Image
>> >in EC2 [4] (Rackspace 'coming soon' [5])
>> >
>> >    ** The process of 'save this Instance as an Image in S3' is
>> >termed 'bundling'
>> >    ** PROBLEM: different procedure for Windose vs Linux images [6].
>> >	-- For Windows you use the AWS REST API 'BundleInstance' call where
>> >you specify the S3 bucket to upload to (amongst other things).
>>
>> We need to add a <os>Linux|Windows</os> field to instance XML
>> and then decide which method we will choose when creating image.
>> The bucket thing for Windows could be solved by feature param.
>
>I agree that we should expose the OS in instance details; but for image
>creation, I think we should only allow creating Linux images via
>POST /api/images
>
>The creation of Windows images follows a completely different model -
>not only do you have to specify a S3 bucket, but AWS also exposes bundle
>tasks via DescribeBundleTasks and CancelBundleTask. It seems to me that
>that is best expressed by a separate top-level collection 'bundle_tasks'

Yes, you're right. Also BundleInstance needs two additional parameters to
complete: UploadPolicy and UploadPolicySignature, which we doesn't have
in API AFAIK. (Marios: It's possible to obtain those two using storage API?)

The call, according to documentation itself looks like:

<snip>
https://ec2.amazonaws.com/?Action=BundleInstance
&InstanceId=i-e468cd8d
&Storage.S3.AWSAccessKeyId=10QMXFEV71ZS32XQFTR2
&Storage.S3.Bucket=my-bucket 
&Storage.S3.Prefix=winami
&Storage.S3.UploadPolicy=eyJleHBpcmF0aW9uIjogIjIwMDgtMDgtMzBUMDg6NDk6MDlaIiw
&Storage.S3.UploadPolicySignature=fh5tyyyQD8W4COEthj3nlGNtJMU%3D 
&AUTHPARAMS
</snip>

Our calls, when using /api/images collection should looks like:

POST /api/images ?instance_id=i-1234

And for Windows:
POST /api/images ?instance_id=i-1234&bucket_id=images-bucket

(hopefully informations like UploadPolicy could be returned from Bucket)

FYI: I added task for exposing instance OS type into Teambox.

>> >	-- For Linux you must install the 'AMI Tools' command-line utilities
>> >[7] on the Instance you wish to bundle and then 'ec2-bundle-image'.
>> >Confusingly the actual upload is done with 'ec2-upload-bundle' which
>> >takes the S3 bucket name as a parameter.
>>
>> For EBS you just need instance_id and name and there is CreateImage call.
>
>We also have the difficulty that there's currently no way to tell
>whether an instance uses EBS or instance store for its root disk; IOW,
>you can't tell from looking at an instance if 'create image' on it could
>possibly succeed.

In DescribeImages there is: <rootDeviceType>ebs</rootDeviceType> element.
Maybe we can advertise this information in our XML as well, like:

<image>
   ...
   <os type="linux" root="ebs" />
   ...
</image>

Unfortunately, according to my quick look to API docs there is no support for
this in GoGrid (like you can't retrieve information about OS from instance here)
which sux. For this case we can expose OS type as 'unknown'.

>> >-iii-> Gogrid allows you to save a 'MyGSI - Gogrid Server Image' from
>> >your own, preconfigured 'sandbox server'
>>
>> As I said, we will need to add new feature for GoGrid (something like
>> 'sandbox') when launching an Instance and some HTTP proper response from
>> POST /api/images when Instance is not in sandbox.
>
>Since for both GoGrid and EC2, instances need to fulfill specific
>criteria to be snapshottable, wouldn't it be better to make image
>creation for them an action on the instance ? That way, we get to worry
>about under which circumstances you could possibly perform the action.

That could work too but I'm not entirely sure if this is the correct 'REST'
approach here. Like we have 'images' collection and RESTish should be to
create images on top of this collection.

>What I have in mind is that we offer an instance action
>
>        <actions>
>          <link href="http://localhost:3001/api/instances/i-31f16e5d/create_image" method="post" rel="create_image"/>
>        </actions>
>
>In addition, we need to
>      * expose whether an image is ebs/instance store for EC2
>      * allow creation of sandbox instances for GoGrid (can any image be
>        sandboxed or only specific images ?)

Well seems like no, not all images are sandboxable according to this
matrix: http://wiki.gogrid.com/wiki/index.php/Server_Compatibility_Matrix

Currently figuring out if we can query their API to get information if
given image is 'sandboxable' or not (I need to check this with support).

FYI: I added task into Teambox for support sandbox instances.

   -- Michal

-- 
--------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org
--------------------------------------------------------

Re: Create images from running or stopped EBS instances (EC2)

Posted by David Lutterkort <lu...@redhat.com>.
On Thu, 2011-02-03 at 15:17 +0100, Michal Fojtik wrote: 
> On 03/02/11 14:57 +0200, marios@redhat.com wrote:
> >Hey Michal,
> >
> >here's a copy/paste from the notes I made about snapshots back in 
> >July - might be useful to have this in one place/save some time 
> >looking at the APIs (AWS, Rackspace, Rimu, Gogrid, Terremark):
> 
> Thanks Marios! This seems to be very usefull and save me a lot of time
> googling and reading all those docs.
> After brief look, I have few suggestions for API:
> 
> 
> >
> ><PAST> :
> >
> >
> >Q. Which of our currently supported clouds allows 'register custom 
> >Image from cloud storage', or, 'save/snapshot an Instance as a new 
> >Image'
> >-----------------------------------------------------------------
> >--i--> Amazon AWS allows you to register an object in S3 as an Image 
> >in EC2 [4] (Rackspace 'coming soon' [5])
> >
> >    ** The process of 'save this Instance as an Image in S3' is 
> >termed 'bundling'
> >    ** PROBLEM: different procedure for Windose vs Linux images [6].
> >	-- For Windows you use the AWS REST API 'BundleInstance' call where 
> >you specify the S3 bucket to upload to (amongst other things).
> 
> We need to add a <os>Linux|Windows</os> field to instance XML
> and then decide which method we will choose when creating image.
> The bucket thing for Windows could be solved by feature param.

I agree that we should expose the OS in instance details; but for image
creation, I think we should only allow creating Linux images via
POST /api/images

The creation of Windows images follows a completely different model -
not only do you have to specify a S3 bucket, but AWS also exposes bundle
tasks via DescribeBundleTasks and CancelBundleTask. It seems to me that
that is best expressed by a separate top-level collection 'bundle_tasks'

> >	-- For Linux you must install the 'AMI Tools' command-line utilities 
> >[7] on the Instance you wish to bundle and then 'ec2-bundle-image'. 
> >Confusingly the actual upload is done with 'ec2-upload-bundle' which 
> >takes the S3 bucket name as a parameter.
> 
> For EBS you just need instance_id and name and there is CreateImage call.

We also have the difficulty that there's currently no way to tell
whether an instance uses EBS or instance store for its root disk; IOW,
you can't tell from looking at an instance if 'create image' on it could
possibly succeed.

> >-iii-> Gogrid allows you to save a 'MyGSI - Gogrid Server Image' from 
> >your own, preconfigured 'sandbox server'
> 
> As I said, we will need to add new feature for GoGrid (something like
> 'sandbox') when launching an Instance and some HTTP proper response from 
> POST /api/images when Instance is not in sandbox.

Since for both GoGrid and EC2, instances need to fulfill specific
criteria to be snapshottable, wouldn't it be better to make image
creation for them an action on the instance ? That way, we get to worry
about under which circumstances you could possibly perform the action.

What I have in mind is that we offer an instance action

        <actions>
          <link href="http://localhost:3001/api/instances/i-31f16e5d/create_image" method="post" rel="create_image"/>
        </actions>
        
In addition, we need to
      * expose whether an image is ebs/instance store for EC2
      * allow creation of sandbox instances for GoGrid (can any image be
        sandboxed or only specific images ?)

David





Re: Create images from running or stopped EBS instances (EC2)

Posted by Michal Fojtik <mf...@redhat.com>.
On 03/02/11 14:57 +0200, marios@redhat.com wrote:
>Hey Michal,
>
>here's a copy/paste from the notes I made about snapshots back in 
>July - might be useful to have this in one place/save some time 
>looking at the APIs (AWS, Rackspace, Rimu, Gogrid, Terremark):

Thanks Marios! This seems to be very usefull and save me a lot of time
googling and reading all those docs.
After brief look, I have few suggestions for API:


>
><PAST> :
>
>
>Q. Which of our currently supported clouds allows 'register custom 
>Image from cloud storage', or, 'save/snapshot an Instance as a new 
>Image'
>-----------------------------------------------------------------
>--i--> Amazon AWS allows you to register an object in S3 as an Image 
>in EC2 [4] (Rackspace 'coming soon' [5])
>
>    ** The process of 'save this Instance as an Image in S3' is 
>termed 'bundling'
>    ** PROBLEM: different procedure for Windose vs Linux images [6].
>	-- For Windows you use the AWS REST API 'BundleInstance' call where 
>you specify the S3 bucket to upload to (amongst other things).

We need to add a <os>Linux|Windows</os> field to instance XML
and then decide which method we will choose when creating image.
The bucket thing for Windows could be solved by feature param.

>	-- For Linux you must install the 'AMI Tools' command-line utilities 
>[7] on the Instance you wish to bundle and then 'ec2-bundle-image'. 
>Confusingly the actual upload is done with 'ec2-upload-bundle' which 
>takes the S3 bucket name as a parameter.

For EBS you just need instance_id and name and there is CreateImage call.

>    ** In both cases and after bundling is complete you register the 
>newly created S3 object as an Image for EC2 using the REST API 
>'RegisterImage' call.
>
>--ii-> Rackspace allows you to snapshot a running Instance [5]
>
>    ** This is done through a REST API call (POST /images) where you 
>specify the serverid (Instance) that is to be saved.
>    ** Here there is no seperation between 'make snapshot' and 
>'upload to cloud storage' - i.e. cannot export a server image [8].
>    ** Snapshots stay 'attached to the server' [9] (i.e. saved locally?).
>    ** Once process complete the image is available for booting a 
>server [5].
>    ** 'Custom Image Upload' is in the Cloud Server API Roadmap [5].
>
>-iii-> Gogrid allows you to save a 'MyGSI - Gogrid Server Image' from 
>your own, preconfigured 'sandbox server'

As I said, we will need to add new feature for GoGrid (something like
'sandbox') when launching an Instance and some HTTP proper response from 
POST /api/images when Instance is not in sandbox.

>    ** You create a MyGSI from a configured, running 'image sandbox 
>server' and the new image is added to Gogrid's cloud storage [11]
>    ** Weirdly this cloud storage is not exposed at all via the API
>    ** The API call is grid.image.save [12] - you create a new 'image 
>sandbox server' using 'grid.server.add', configure it and run the 
>'prep scripts' and then call the save. Once complete the new MyGSI is 
>available in your list of images.
>
>--iv-> Rimuhosting allows you to clone an existing server and deploy 
>a new server from that [10]
>
>    ** However, the clone must be deployed straight away - you cannot 
>save as an image for later instantiation.
>    ** A chat with support confirmed this - you *can* save an image 
>for later use but only by submitting a support ticket (i.e. nothing 
>in the api or the web 'management console' to support this).
>
>--v--> Terremark VCloud Express allows you to 'clone' an existing 
>server (a 'vapp') [13] but you cannot save this as an Image (a 'vapp 
>template').
>
>    ** Similar to the rimuhosting situation - can clone an existing 
>server as another server, but not as an Image
>    ** POST https://{Terremark URI}/vdc/{vDC ID}/action/clonevapp - 
>you specify the vApp id to be cloned within the request body.

So I guess that we will not support creating images in this 'snapshot' way
for Terremark and RimuHosting at this time.

   -- Michal

-- 
--------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org
--------------------------------------------------------

Re: Create images from running or stopped EBS instances (EC2)

Posted by David Lutterkort <lu...@redhat.com>.
On Thu, 2011-02-03 at 14:57 +0200, marios@redhat.com wrote:
> Hey Michal,
> 
> here's a copy/paste from the notes I made about snapshots back in July - 
> might be useful to have this in one place/save some time looking at the 
> APIs (AWS, Rackspace, Rimu, Gogrid, Terremark):

>From looking at your notes, I think only AWS, RAX, and GoGrid qualify
for supporting the 'create image' call.

David



Re: Create images from running or stopped EBS instances (EC2)

Posted by "marios@redhat.com" <ma...@redhat.com>.
Hey Michal,

here's a copy/paste from the notes I made about snapshots back in July - 
might be useful to have this in one place/save some time looking at the 
APIs (AWS, Rackspace, Rimu, Gogrid, Terremark):

<PAST> :


Q. Which of our currently supported clouds allows 'register custom Image 
from cloud storage', or, 'save/snapshot an Instance as a new Image'
-----------------------------------------------------------------
--i--> Amazon AWS allows you to register an object in S3 as an Image in 
EC2 [4] (Rackspace 'coming soon' [5])

     ** The process of 'save this Instance as an Image in S3' is termed 
'bundling'
     ** PROBLEM: different procedure for Windose vs Linux images [6].
	-- For Windows you use the AWS REST API 'BundleInstance' call where you 
specify the S3 bucket to upload to (amongst other things).
	-- For Linux you must install the 'AMI Tools' command-line utilities 
[7] on the Instance you wish to bundle and then 'ec2-bundle-image'. 
Confusingly the actual upload is done with 'ec2-upload-bundle' which 
takes the S3 bucket name as a parameter.
     ** In both cases and after bundling is complete you register the 
newly created S3 object as an Image for EC2 using the REST API 
'RegisterImage' call.

--ii-> Rackspace allows you to snapshot a running Instance [5]

     ** This is done through a REST API call (POST /images) where you 
specify the serverid (Instance) that is to be saved.
     ** Here there is no seperation between 'make snapshot' and 'upload 
to cloud storage' - i.e. cannot export a server image [8].
     ** Snapshots stay 'attached to the server' [9] (i.e. saved locally?).
     ** Once process complete the image is available for booting a 
server [5].
     ** 'Custom Image Upload' is in the Cloud Server API Roadmap [5].

-iii-> Gogrid allows you to save a 'MyGSI - Gogrid Server Image' from 
your own, preconfigured 'sandbox server'

     ** You create a MyGSI from a configured, running 'image sandbox 
server' and the new image is added to Gogrid's cloud storage [11]
     ** Weirdly this cloud storage is not exposed at all via the API
     ** The API call is grid.image.save [12] - you create a new 'image 
sandbox server' using 'grid.server.add', configure it and run the 'prep 
scripts' and then call the save. Once complete the new MyGSI is 
available in your list of images.

--iv-> Rimuhosting allows you to clone an existing server and deploy a 
new server from that [10]

     ** However, the clone must be deployed straight away - you cannot 
save as an image for later instantiation.
     ** A chat with support confirmed this - you *can* save an image for 
later use but only by submitting a support ticket (i.e. nothing in the 
api or the web 'management console' to support this).

--v--> Terremark VCloud Express allows you to 'clone' an existing server 
(a 'vapp') [13] but you cannot save this as an Image (a 'vapp template').

     ** Similar to the rimuhosting situation - can clone an existing 
server as another server, but not as an Image
     ** POST https://{Terremark URI}/vdc/{vDC ID}/action/clonevapp - you 
specify the vApp id to be cloned within the request body.

AWS:
[1] http://aws.amazon.com/documentation/s3/
[2] http://www.supersimplestorageservice.com/
[4] http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/
[6] 
http://developer.amazonwebservices.com/connect/thread.jspa?messageID=107847&#107847
[7] 
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=368&categoryID=88
RACKSPACE:
[3] http://www.rackspacecloud.com/cloud_hosting_products/files/api
[5] http://docs.rackspacecloud.com/servers/api/cs-devguide-latest.pdf
[8] http://www.rackspacecloud.com/cloud_hosting_products/servers/faq
[9] http://www.rackspacecloud.com/cloud_hosting_products/servers/pricing
RIMUHOSTING:
[10] 
http://apidocs.rimuhosting.com/jaxbdocs/com/rimuhosting/jaxrsorders/JAXRSOrders.NewVPSRequest.html
GOGRID:
[11] http://wiki.gogrid.com/wiki/index.php/Cloud_Storage:Cloud_Storage
[12] http://wiki.gogrid.com/wiki/index.php/API:grid.image.save
TERREMARK:
[13] 
https://community.vcloudexpress.terremark.com/en-us/product_docs/w/wiki/6-vcloud-express-api-documention.aspx

On 03/02/11 13:45, mfojtik@redhat.com wrote:
> Hi,
>
> This patch will add support for creating images from running or stopped
> instances in Amazon EC2. EC2 support 'CreateImage' call for all EBS
> instances.
>
> Deltacloud API implements that in this way:
>
> POST /api/images
> Parameters: { :instance_id =>  'i-123123', :name =>  'image name' }
>
> I checked GoGrid and they have something similar[1] for 'sandbox'
> instances. Which means that we will need to add some feature to
> instances collection to create 'sandbox' instance in GoGrid.
>
> I didn't check Rackspace but Ovi said that they have something very
> similar.
>
> Please let me know what do you think about this approach.
>
> PS: I attached a working example for EC2, *but* you need to have patched
> gem installed (you can grab one from my github account[2]). To install it:
>
> git clone git://github.com/mifo/aws.git
> git checkout myupstream
> gem build aws.gemspec
> gem uninstall aws
> gem install --local aws.gem
>
> Or wait until Appoxy's integrate my patch to upstream gem.
>
> [1] http://wiki.gogrid.com/wiki/index.php/API:grid.image.save
> [2] https://github.com/mifo/aws/tree/myupstream
>


Re: [PATCH core] Create an Image from running EBS instance (EC2)

Posted by Michal Fojtik <mf...@redhat.com>.
On 04/02/11 16:41 -0800, David Lutterkort wrote:
>On Thu, 2011-02-03 at 12:45 +0100, mfojtik@redhat.com wrote:
>> From: Michal Fojtik <mf...@redhat.com>
>>
>> ---
>>  server/lib/deltacloud/drivers/ec2/ec2_driver.rb    |    9 +++++++++
>>  .../lib/deltacloud/helpers/application_helper.rb   |    5 ++++-
>>  server/server.rb                                   |   15 +++++++++++++++
>>  server/views/instances/index.html.haml             |    2 ++
>>  4 files changed, 30 insertions(+), 1 deletions(-)
>
>NAK for now until we've figured out how this should all be represented
>in the API across the clouds that allow image creation (EC2, RAX, and
>GoGrid)

Sure, I'll do the same stuff for all other providers (GoGrid, Rackspace) to
see if it will work in this way.
Since we will not deal with Windows images at this point, it should work.

   -- Michal


-- 
--------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org
--------------------------------------------------------

Re: [PATCH core] Create an Image from running EBS instance (EC2)

Posted by David Lutterkort <lu...@redhat.com>.
On Thu, 2011-02-03 at 12:45 +0100, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mf...@redhat.com>
> 
> ---
>  server/lib/deltacloud/drivers/ec2/ec2_driver.rb    |    9 +++++++++
>  .../lib/deltacloud/helpers/application_helper.rb   |    5 ++++-
>  server/server.rb                                   |   15 +++++++++++++++
>  server/views/instances/index.html.haml             |    2 ++
>  4 files changed, 30 insertions(+), 1 deletions(-)

NAK for now until we've figured out how this should all be represented
in the API across the clouds that allow image creation (EC2, RAX, and
GoGrid)

David



[PATCH core] Create an Image from running EBS instance (EC2)

Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>

---
 server/lib/deltacloud/drivers/ec2/ec2_driver.rb    |    9 +++++++++
 .../lib/deltacloud/helpers/application_helper.rb   |    5 ++++-
 server/server.rb                                   |   15 +++++++++++++++
 server/views/instances/index.html.haml             |    2 ++
 4 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index 7436fb8..a825de6 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -145,6 +145,15 @@ module Deltacloud
           img_arr.sort_by { |e| [e.owner_id, e.name] }
         end
 
+        def create_image(credentials, opts={})
+          ec2 = new_client(credentials)
+          image_id = nil
+          safely do
+            image_id = ec2.create_image(opts[:instance_id], opts[:name])
+          end
+          image(credentials, :id => image_id)
+        end
+
         def realms(credentials, opts={})
           ec2 = new_client(credentials)
           zone_id = opts ? opts[:id] : nil
diff --git a/server/lib/deltacloud/helpers/application_helper.rb b/server/lib/deltacloud/helpers/application_helper.rb
index abe78bc..c73e72d 100644
--- a/server/lib/deltacloud/helpers/application_helper.rb
+++ b/server/lib/deltacloud/helpers/application_helper.rb
@@ -144,9 +144,12 @@ module ApplicationHelper
     "<pem><![CDATA[#{text.strip}]]></pem>"
   end
 
-  def link_to_action(action, url, method)
+  def link_to_action(action, url, method, opts=nil)
     capture_haml do
       haml_tag :form, :method => :post, :action => url, :class => :link do
+        opts.each do |name, value|
+          haml_tag :input, :type => :hidden, :name => name, :value => value
+        end if opts
         haml_tag :input, :type => :hidden, :name => '_method', :value => method
         haml_tag :button, :type => :submit do 
           haml_concat action
diff --git a/server/server.rb b/server/server.rb
index a801bea..bab11a5 100644
--- a/server/server.rb
+++ b/server/server.rb
@@ -163,6 +163,21 @@ END
     control { show(:image) }
   end
 
+  operation :create do
+    description 'Create image from instance.'
+    with_capability :create_image
+    param :instance_id, :string,  :required
+    param :name,  :string,  :required
+    control do
+      @image = driver.create_image(credentials, params)
+      respond_to do |format|
+        format.html { haml :"images/show" }
+        format.xml { haml :"images/show" }
+        format.json { convert_to_json(model, @image) }
+      end
+    end
+  end
+
 end
 
 collection :instance_states do
diff --git a/server/views/instances/index.html.haml b/server/views/instances/index.html.haml
index d728ec5..c0aa99e 100644
--- a/server/views/instances/index.html.haml
+++ b/server/views/instances/index.html.haml
@@ -30,3 +30,5 @@
             =link_to_action action, self.send(:"#{action}_instance_url", instance.id), instance_action_method(action)
           - if driver.respond_to?(:run_on_instance) and instance.state=="RUNNING"
             =link_to_action "Run command", url_for("/api/instances/#{instance.id}/run"), :get
+          - if driver.respond_to?(:create_image) and ['RUNNING', 'STOPPPED'].include?(instance.state)
+            =link_to_action "Create image", url_for("/api/images"), :post, { :instance_id => instance.id, :name => Time.now.to_i.to_s }
-- 
1.7.4