You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by Francesco Vollero <fv...@redhat.com> on 2013/03/25 17:57:33 UTC

[PATCH core 4/6] core: even more tilt fixes

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

Signed-off-by: Michal fojtik <mf...@redhat.com>
Signed-off-by: Francesco Vollero <fv...@redhat.com>
---
 server/lib/deltacloud/collections/addresses.rb     |  4 +-
 server/lib/deltacloud/collections/buckets.rb       | 34 +++++++-------
 server/lib/deltacloud/collections/drivers.rb       |  8 ++--
 server/lib/deltacloud/collections/firewalls.rb     | 10 ++--
 server/lib/deltacloud/collections/images.rb        |  4 +-
 .../lib/deltacloud/collections/instance_states.rb  |  8 ++--
 server/lib/deltacloud/collections/instances.rb     | 12 ++---
 server/lib/deltacloud/collections/keys.rb          |  4 +-
 .../lib/deltacloud/collections/load_balancers.rb   | 10 ++--
 .../deltacloud/collections/storage_snapshots.rb    |  6 +--
 .../lib/deltacloud/collections/storage_volumes.rb  |  8 ++--
 server/lib/deltacloud/helpers/deltacloud_helper.rb | 35 +++++++-------
 server/lib/deltacloud/server.rb                    |  8 ++--
 server/views/addresses/index.xml.haml              |  2 +-
 server/views/api/show.html.haml                    |  2 +-
 server/views/api/show.xml.haml                     |  2 +-
 server/views/blobs/show.xml.haml                   | 14 +++---
 server/views/buckets/index.xml.haml                |  2 +-
 server/views/drivers/index.xml.haml                |  2 +-
 server/views/drivers/show.html.haml                | 12 ++---
 server/views/drivers/show.xml.haml                 | 10 ++--
 .../errors/backend_capability_failure.xml.haml     |  6 +--
 server/views/errors/common.html.haml               | 14 +++---
 server/views/errors/common.xml.haml                | 10 ++--
 server/views/firewalls/index.xml.haml              |  2 +-
 server/views/firewalls/show.xml.haml               | 18 ++++----
 server/views/hardware_profiles/index.xml.haml      |  2 +-
 server/views/images/index.xml.haml                 |  2 +-
 server/views/instance_states/show.png.erb          |  4 +-
 server/views/instance_states/show.xml.haml         |  2 +-
 server/views/instances/index.html.haml             |  2 +-
 server/views/instances/index.xml.haml              |  2 +-
 server/views/instances/run.html.haml               |  4 +-
 server/views/instances/run.xml.haml                |  6 +--
 server/views/instances/run_command.html.haml       |  8 ++--
 server/views/instances/show.html.haml              | 54 +++++++++++-----------
 server/views/keys/index.xml.haml                   |  2 +-
 server/views/load_balancers/index.xml.haml         |  2 +-
 server/views/metrics/index.xml.haml                |  2 +-
 server/views/realms/index.xml.haml                 |  2 +-
 server/views/storage_snapshots/index.xml.haml      |  2 +-
 server/views/storage_volumes/index.xml.haml        |  2 +-
 42 files changed, 171 insertions(+), 174 deletions(-)

diff --git a/server/lib/deltacloud/collections/addresses.rb b/server/lib/deltacloud/collections/addresses.rb
index fabbb59..fb877d8 100644
--- a/server/lib/deltacloud/collections/addresses.rb
+++ b/server/lib/deltacloud/collections/addresses.rb
@@ -39,8 +39,8 @@ module Deltacloud::Collections
           status 201    # Created
           response['Location'] = address_url(@address.id)
           respond_to do |format|
-            format.xml  { haml :"addresses/show", :ugly => true }
-            format.html { haml :"addresses/_address", :layout => false }
+            format.xml  { haml :"addresses/show", :ugly => true, :locals => { :address => @address } }
+            format.html { haml :"addresses/_address", :layout => false, :locals => { :address => @address } }
             format.json { JSON::dump(:address => @address.to_hash(self)) }
           end
         end
diff --git a/server/lib/deltacloud/collections/buckets.rb b/server/lib/deltacloud/collections/buckets.rb
index 9b60121..18d1d15 100644
--- a/server/lib/deltacloud/collections/buckets.rb
+++ b/server/lib/deltacloud/collections/buckets.rb
@@ -27,7 +27,7 @@ module Deltacloud::Collections
     get '/buckets/:bucket/%s' % NEW_BLOB_FORM_ID do
       @bucket_id = params[:bucket]
       respond_to do |format|
-        format.html {haml :"blobs/new"}
+        format.html {haml :"blobs/new", :locals=>{:bucket_id => @bucket_id} }
       end
     end
 
@@ -65,14 +65,12 @@ module Deltacloud::Collections
             report_error(400) # likely blob size < 112 KB (didn't hit streaming patch)
           end
         when "finalize" then
-          bucket_id = params[:bucket]
-          blob_id = params[:blob]
           segmented_blob_manifest = BlobHelper.extract_segmented_blob_manifest(request)
           segmented_blob_id = BlobHelper.segmented_blob_id(request)
           @blob = driver.create_blob(credentials, params[:bucket], params[:blob], nil, {:segment_manifest=>segmented_blob_manifest, :segmented_blob_id=>segmented_blob_id})
           respond_to do |format|
-            format.xml { haml :"blobs/show" }
-            format.html { haml :"blobs/show" }
+            format.xml { haml :"blobs/show", :locals => { :blob => @blob } }
+            format.html { haml :"blobs/show", :locals => { :blob => @blob } }
             format.json { xml_to_json 'blobs/show' }
           end
         else
@@ -89,8 +87,8 @@ module Deltacloud::Collections
         @blob = driver.blob(credentials, {:id => params[:blob],
                                           'bucket' => params[:bucket]})
         respond_to do |format|
-          format.xml { haml :"blobs/show" }
-          format.html { haml :"blobs/show" }
+          format.xml { haml :"blobs/show", :locals => { :blob => @blob } }
+          format.html { haml :"blobs/show", :locals => { :blob => @blob } }
           format.json { JSON::dump(:blob => @blob.to_hash(self) ) }
         end
       elsif(env["BLOB_FAIL"])
@@ -108,8 +106,8 @@ module Deltacloud::Collections
         @blob = driver.create_blob(credentials, bucket_id, blob_id, blob_data, user_meta)
         temp_file.delete
         respond_to do |format|
-          format.xml  { haml :"blobs/show", :locals=> {blob=>@blob} }
-          format.html { haml :"blobs/show", :locals =>{blob=>@blob} }
+          format.xml  { haml :"blobs/show", :locals => { :blob => @blob } }
+          format.html { haml :"blobs/show", :locals => { :blob => @blob } }
           format.json { JSON::dump(:blob => @blob.to_hash(self)) }
         end
       end
@@ -128,7 +126,7 @@ module Deltacloud::Collections
           status 201
           response['Location'] = bucket_url(@bucket.id)
           respond_to do |format|
-            format.xml  { haml :"buckets/show", :locals=>{bucket=>@bucket} }
+            format.xml  { haml :"buckets/show", :locals=> { :bucket => @bucket } }
             format.json { JSON::dump(:bucket => @bucket.to_hash(self)) }
             format.html do
               redirect bucket_url(@bucket.id) if @bucket and @bucket.id
@@ -158,8 +156,8 @@ module Deltacloud::Collections
             @blob = driver.blob(credentials, { :id => params[:blob_id], 'bucket' => params[:id]} )
             if @blob
               respond_to do |format|
-                format.xml { haml :"blobs/show" }
-                format.html { haml :"blobs/show" }
+                format.xml { haml :"blobs/show", :locals => { :blob => @blob } }
+                format.html { haml :"blobs/show", :locals => { :blob => @blob } }
                 format.json { JSON::dump(:blob => @blob.to_hash(self)) }
               end
             else
@@ -192,8 +190,8 @@ module Deltacloud::Collections
             @blob = driver.create_blob(credentials, bucket_id, blob_id, blob_data, user_meta)
             status 201
             respond_to do |format|
-              format.xml { haml :"blobs/show" }
-              format.html { haml :"blobs/show"}
+              format.xml { haml :"blobs/show", :locals => { :blob => @blob } }
+              format.html { haml :"blobs/show", :locals => { :blob => @blob }}
               format.json { JSON::dump(:blob => @blob.to_hash(self)) }
             end
           end
@@ -225,8 +223,8 @@ module Deltacloud::Collections
               @blob = driver.blob(credentials, {:id => params[:blob],
                                                 'bucket' => params[:bucket]})
               respond_to do |format|
-                format.xml { haml :"blobs/show" }
-                format.html { haml :"blobs/show" }
+                format.xml { haml :"blobs/show", :locals => { :blob => @blob } }
+                format.html { haml :"blobs/show", :locals => { :blob => @blob } }
                 format.json { JSON::dump(@blob.to_hash(self)) }
               end
             elsif(env["BLOB_FAIL"])
@@ -244,8 +242,8 @@ module Deltacloud::Collections
               @blob = driver.create_blob(credentials, bucket_id, blob_id, blob_data, user_meta)
               temp_file.delete
               respond_to do |format|
-                format.xml { haml :"blobs/show" }
-                format.html { haml :"blobs/show" }
+                format.xml { haml :"blobs/show", :locals => { :blob => @blob } }
+                format.html { haml :"blobs/show", :locals => { :blob => @blob } }
                 format.json { JSON::dump(@blob.to_hash(self)) }
               end
             end
diff --git a/server/lib/deltacloud/collections/drivers.rb b/server/lib/deltacloud/collections/drivers.rb
index 8c51019..c49ab43 100644
--- a/server/lib/deltacloud/collections/drivers.rb
+++ b/server/lib/deltacloud/collections/drivers.rb
@@ -22,9 +22,9 @@ module Deltacloud::Collections
         control do
           @drivers = Deltacloud::Drivers.driver_config
           respond_to do |format|
-            format.xml { haml :"drivers/index" }
+            format.xml { haml :"drivers/index", :locals => { :drivers => @drivers } }
             format.json { @drivers.to_json }
-            format.html { haml :"drivers/index" }
+            format.html { haml :"drivers/index", :locals => { :drivers => @drivers } }
           end
         end
       end
@@ -38,9 +38,9 @@ module Deltacloud::Collections
           @driver = Deltacloud::Drivers.driver_config[@name]
           halt 404 unless @driver
           respond_to do |format|
-            format.xml { haml :"drivers/show" }
+            format.xml { haml :"drivers/show", :locals => { :driver => @driver, :name => @name, :providers => @providers } }
             format.json { { :driver => @driver.merge(:id => params[:id]) }.to_json }
-            format.html { haml :"drivers/show" }
+            format.html { haml :"drivers/show",  :locals => { :driver => @driver, :name => @name, :providers => @providers }}
           end
         end
       end
diff --git a/server/lib/deltacloud/collections/firewalls.rb b/server/lib/deltacloud/collections/firewalls.rb
index 1f35c58..e6ae4ee 100644
--- a/server/lib/deltacloud/collections/firewalls.rb
+++ b/server/lib/deltacloud/collections/firewalls.rb
@@ -25,7 +25,7 @@ module Deltacloud::Collections
     get '/firewalls/:id/new_rule' do
       @firewall_name = params[:id]
       respond_to do |format|
-        format.html {haml :"firewalls/new_rule" }
+        format.html { haml :"firewalls/new_rule", :locals => { :firewall_name => @firewall_name } }
       end
     end
 
@@ -64,8 +64,8 @@ module Deltacloud::Collections
           status 201  # Created
           response['Location'] = firewall_url(@firewall.id)
           respond_to do |format|
-            format.xml  { haml :"firewalls/show" }
-            format.html { haml :"firewalls/show" }
+            format.xml  { haml :"firewalls/show", :locals => { :firewall => @firewall } }
+            format.html { haml :"firewalls/show", :locals => { :firewall => @firewall } }
             format.json { JSON::dump(:firewall => @firewall.to_hash(self)) }
           end
         end
@@ -107,8 +107,8 @@ module Deltacloud::Collections
           @firewall = driver.firewall(credentials, {:id => params[:id]})
           status 201
           respond_to do |format|
-            format.xml  { haml :"firewalls/show" }
-            format.html { haml :"firewalls/show" }
+            format.xml  { haml :"firewalls/show", :locals => { :firewall => @firewall} }
+            format.html { haml :"firewalls/show", :locals => { :firewall => @firewall} }
             format.json { JSON::dump(:firewall => @firewall.to_hash(self) ) }
           end
         end
diff --git a/server/lib/deltacloud/collections/images.rb b/server/lib/deltacloud/collections/images.rb
index 80fbf08..687f931 100644
--- a/server/lib/deltacloud/collections/images.rb
+++ b/server/lib/deltacloud/collections/images.rb
@@ -49,9 +49,9 @@ module Deltacloud::Collections
           status 201  # Created
           response['Location'] = image_url(@image.id)
           respond_to do |format|
-            format.xml  { haml :"images/show" }
+            format.xml  { haml :"images/show", :locals => { :image => @image } }
             format.json { JSON::dump(:image => @image.to_hash(self)) }
-            format.html { haml :"images/show" }
+            format.html { haml :"images/show", :locals => { :image => @image } }
           end
         end
       end
diff --git a/server/lib/deltacloud/collections/instance_states.rb b/server/lib/deltacloud/collections/instance_states.rb
index 6e16568..aba153b 100644
--- a/server/lib/deltacloud/collections/instance_states.rb
+++ b/server/lib/deltacloud/collections/instance_states.rb
@@ -26,7 +26,7 @@ module Deltacloud::Collections
         control do
           @machine = driver.instance_state_machine
           respond_to do |format|
-            format.xml { haml :'instance_states/show', :layout => false }
+            format.xml { haml :'instance_states/show', :layout => false, :locals => { :machine => @machine } }
             format.json do
               out = []
               @machine.states.each do |state|
@@ -37,12 +37,12 @@ module Deltacloud::Collections
               end
               out.to_json
             end
-            format.html { haml :'instance_states/show'}
-            format.gv { erb :"instance_states/show" }
+            format.html { haml :'instance_states/show', :locals => { :machine => @machine }}
+            format.gv { erb :"instance_states/show", :locals => { :machine => @machine } }
             format.png do
               # Trick respond_to into looking up the right template for the
               # graphviz file
-              gv = erb(:"instance_states/show")
+              gv = erb(:"instance_states/show", :locals => { :machine => @machine })
               png =  ''
               cmd = 'dot -Kdot -Gpad="0.2,0.2" -Gsize="5.0,8.0" -Gdpi="180" -Tpng'
               ::Open3.popen3( cmd ) do |stdin, stdout, stderr|
diff --git a/server/lib/deltacloud/collections/instances.rb b/server/lib/deltacloud/collections/instances.rb
index dd02981..7ee662d 100644
--- a/server/lib/deltacloud/collections/instances.rb
+++ b/server/lib/deltacloud/collections/instances.rb
@@ -34,7 +34,7 @@ module Deltacloud::Collections
     get '/instances/:id/run' do
       respond_to do |format|
         @instance = driver.instances(credentials, :id => params[:id]).first
-        format.html {haml :"instances/run_command" }
+        format.html {haml :"instances/run_command", :locals => @instance }
       end
     end
 
@@ -59,7 +59,7 @@ module Deltacloud::Collections
           end
           status 201  # Created
           respond_to do |format|
-            format.xml  { haml :"instances/#{action_handler}", :locals=>{:instance=>@instance} }
+            format.xml  { haml :"instances/#{action_handler}", :locals => {:instance=>@instance} }
             format.json do
               if @elements
                 JSON::dump(:instances => @elements.map { |i| i.to_hash(self) })
@@ -69,10 +69,10 @@ module Deltacloud::Collections
             end
             format.html do
               if @elements
-                haml :"instances/index"
+                haml :"instances/index", :locals => { :elements => @elements }
               elsif @instance and @instance.id
                 response['Location'] = instance_url(@instance.id)
-                haml :"instances/show"
+                haml :"instances/show", :locals => { :instance => @instance }
               else
                 redirect instances_url
               end
@@ -113,8 +113,8 @@ module Deltacloud::Collections
         control do
           @output = driver.run_on_instance(credentials, params)
           respond_to do |format|
-            format.xml { haml :"instances/run" }
-            format.html { haml :"instances/run" }
+            format.xml { haml :"instances/run", :locals => { :output => @output } }
+            format.html { haml :"instances/run", :locals => { :output => @output } }
             format.json { JSON::dump({:instance => { :id => params[:id], :public_address => @output.ssh.network.ip, :command => @output.ssh.command, :output => @output.body}})}
           end
         end
diff --git a/server/lib/deltacloud/collections/keys.rb b/server/lib/deltacloud/collections/keys.rb
index 8d5c460..d1b5541 100644
--- a/server/lib/deltacloud/collections/keys.rb
+++ b/server/lib/deltacloud/collections/keys.rb
@@ -40,8 +40,8 @@ module Deltacloud::Collections
           status 201
           response['Location'] = key_url(@key.id)
           respond_to do |format|
-            format.xml  { haml :"keys/show", :ugly => true }
-            format.html { haml :"keys/show" }
+            format.xml  { haml :"keys/show", :ugly => true, :locals => { :key => @key } }
+            format.html { haml :"keys/show", :locals => { :key => @key } }
             format.json { JSON::dump(:key => @key.to_hash(self)) }
           end
         end
diff --git a/server/lib/deltacloud/collections/load_balancers.rb b/server/lib/deltacloud/collections/load_balancers.rb
index 92c7a36..7a75c85 100644
--- a/server/lib/deltacloud/collections/load_balancers.rb
+++ b/server/lib/deltacloud/collections/load_balancers.rb
@@ -40,9 +40,9 @@ module Deltacloud::Collections
           end
           @unregistered_instances = all_instances - @registered_instances
           respond_to do |format|
-            format.xml { haml :'load_balancers/show' }
+            format.xml { haml :'load_balancers/show', :locals => { :load_balancer => @load_balancer } }
             format.json { JSON::dump(:load_balancer => @load_balancer.to_hash(self)) }
-            format.html { haml :'load_balancers/show' }
+            format.html { haml :'load_balancers/show' } # FIXME: Fix the HTML view + instance variables
           end
         end
       end
@@ -58,7 +58,7 @@ module Deltacloud::Collections
           status 201  # Created
           response['Location'] = load_balancer_url(@load_balancer.id)
           respond_to do |format|
-            format.xml  { haml :"load_balancers/show" }
+            format.xml  { haml :"load_balancers/show", :locals => { :load_balancer => @load_balancer } }
             format.json { JSON::dump(:load_balancer => @load_balancer.to_hash(self)) }
             format.html { redirect load_balancer_url(@load_balancer.id)}
           end
@@ -72,7 +72,7 @@ module Deltacloud::Collections
           driver.lb_register_instance(credentials, params)
           @load_balancer = driver.load_balancer(credentials, :id => params[:id])
           respond_to do |format|
-            format.xml { haml :'load_balancers/show' }
+            format.xml { haml :'load_balancers/show', :locals => { :load_balancer => @load_balancer } }
             format.json { JSON::dump(:load_balancer => @load_balancer.to_hash(self) ) }
             format.html { redirect load_balancer_url(@load_balancer.id)}
           end
@@ -86,7 +86,7 @@ module Deltacloud::Collections
           driver.lb_unregister_instance(credentials, params)
           @load_balancer = driver.load_balancer(credentials, :id => params[:id])
           respond_to do |format|
-            format.xml { haml :'load_balancers/show' }
+            format.xml { haml :'load_balancers/show', :locals => { :load_balancer => @load_balancer } }
             format.json { JSON::dump(:load_balancer => @load_balancer.to_hash(self)) }
             format.html { redirect load_balancer_url(@load_balancer.id) }
           end
diff --git a/server/lib/deltacloud/collections/storage_snapshots.rb b/server/lib/deltacloud/collections/storage_snapshots.rb
index c18bb41..c9836fa 100644
--- a/server/lib/deltacloud/collections/storage_snapshots.rb
+++ b/server/lib/deltacloud/collections/storage_snapshots.rb
@@ -34,9 +34,9 @@ module Deltacloud::Collections
           status 201  # Created
           response['Location'] = storage_snapshot_url(@storage_snapshot.id)
           respond_to do |format|
-            format.xml { haml :"storage_snapshots/show" }
-            format.html { haml :"storage_snapshots/show" }
-            format.json { xml_to_json "storage_snapshots/show" }
+            format.xml { haml :"storage_snapshots/show", :locals => { :storage_snapshot => @storage_snapshot } }
+            format.html { haml :"storage_snapshots/show", :locals => { :storage_snapshot => @storage_snapshot } }
+            format.json { JSON::dump(:storage_snapshot => @storage_snapshot.to_hash(self)) }
           end
         end
       end
diff --git a/server/lib/deltacloud/collections/storage_volumes.rb b/server/lib/deltacloud/collections/storage_volumes.rb
index 3af8015..e02418f 100644
--- a/server/lib/deltacloud/collections/storage_volumes.rb
+++ b/server/lib/deltacloud/collections/storage_volumes.rb
@@ -46,8 +46,8 @@ module Deltacloud::Collections
           status 201
           response['Location'] = storage_volume_url(@storage_volume.id)
           respond_to do |format|
-            format.xml  { haml :"storage_volumes/show" }
-            format.html { haml :"storage_volumes/show" }
+            format.xml  { haml :"storage_volumes/show", :locals => { :storage_volume => @storage_volume } }
+            format.html { haml :"storage_volumes/show", :locals => { :storage_volume => @storage_volume } }
             format.json { JSON::dump(:storage_volume => @storage_volume.to_hash(self)) }
           end
         end
@@ -62,7 +62,7 @@ module Deltacloud::Collections
           status 202
           respond_to do |format|
             format.html { redirect(storage_volume_url(params[:id]))}
-            format.xml  { haml :"storage_volumes/show" }
+            format.xml  { haml :"storage_volumes/show", :locals => { :storage_volume => @storage_volume } }
             format.json { JSON::dump(:storage_volume => @storage_volume.to_hash(self)) }
           end
         end
@@ -78,7 +78,7 @@ module Deltacloud::Collections
           status 202
           respond_to do |format|
             format.html { redirect(storage_volume_url(params[:id]))}
-            format.xml  { haml :"storage_volumes/show" }
+            format.xml  { haml :"storage_volumes/show", :locals => { :storage_volume => @storage_volume } }
             format.json { JSON::dump(:storage_volume => @storage_volume.to_hash(self)) }
           end
         end
diff --git a/server/lib/deltacloud/helpers/deltacloud_helper.rb b/server/lib/deltacloud/helpers/deltacloud_helper.rb
index edcb087..32f13b0 100644
--- a/server/lib/deltacloud/helpers/deltacloud_helper.rb
+++ b/server/lib/deltacloud/helpers/deltacloud_helper.rb
@@ -75,8 +75,8 @@ module Deltacloud::Helpers
         headers['X-Backend-Runtime'] = @benchmark.real.to_s
         instance_variable_set(:"@#{model}", @elements)
         respond_to do |format|
-          format.html { haml :"#{model}/index" }
-          format.xml { haml :"#{model}/index" }
+          format.html { haml :"#{model}/index", :locals => { :elements => @elements } }
+          format.xml { haml :"#{model}/index", :locals => { :elements => @elements } }
           format.json { JSON::dump({ model => @elements.map { |el| el.to_hash(self) }}) }
         end
       else
@@ -109,30 +109,29 @@ module Deltacloud::Helpers
     def report_error(code=nil, message=nil)
 
       if !code.nil?
-        @error = Deltacloud::Exceptions.exception_from_status(code, message || translate_error_code(code)[:message])
-        @code = code
-        message = @error.message
+        error = Deltacloud::Exceptions.exception_from_status(code, message || translate_error_code(code)[:message])
+        message = error.message
       else
-        @error = request.env['sinatra.error'] || @exception
-        @code = @error.respond_to?(:code) ? @error.code : 500
-        message = @error.respond_to?(:message) ? @error.message : translate_error_code(code)[:message]
+        error = request.env['sinatra.error'] || @exception
+        code = error.respond_to?(:code) ? error.code : 500
+        message = error.respond_to?(:message) ? error.message : translate_error_code(code)[:message]
       end
 
-      response.status = @code
+      response.status = code
 
-      backtrace = (@error.respond_to?(:backtrace) and !@error.backtrace.nil?) ?
-        "\n\n#{@error.backtrace[0..20].join("\n")}\n\n" : ''
+      backtrace = (error.respond_to?(:backtrace) and !error.backtrace.nil?) ?
+        "\n\n#{error.backtrace[0..20].join("\n")}\n\n" : ''
 
-      if @code.to_s =~ /5(\d+)/
-        log.error(@code.to_s) { "[#{@error.class.to_s}] #{message}#{backtrace}" }
+      if code.to_s =~ /5(\d+)/
+        log.error(code.to_s) { "[#{error.class.to_s}] #{message}#{backtrace}" }
       end
 
       respond_to do |format|
-        format.xml {  haml :"errors/common", :layout => false }
-        format.json { JSON::dump({ :code => @code || @error.code, :message => message, :error => @error.class.name }) }
+        format.xml {  haml :"errors/common", :layout => false, :locals => { :err => error } }
+        format.json { JSON::dump({ :code => code || error.code, :message => message, :err => error.class.name }) }
         format.html {
           begin
-            haml :"errors/common", :layout => :error
+            haml :"errors/common", :layout => :error, :locals => { :err => error }
           rescue RuntimeError
             # If the HTML representation of error is missing, then try to report
             # it through XML
@@ -171,8 +170,8 @@ module Deltacloud::Helpers
         redirect instance_url(params[:id])
       else
         response = respond_to do |format|
-          format.xml { haml :"instances/show" }
-          format.html { haml :"instances/show" }
+          format.xml { haml :"instances/show", :locals => { :instance => @instance } }
+          format.html { haml :"instances/show", :locals => { :instance => @instance } }
           format.json { JSON::dump(@instance.to_hash(self)) }
         end
         halt 202, response
diff --git a/server/lib/deltacloud/server.rb b/server/lib/deltacloud/server.rb
index 0ef925f..e874b44 100644
--- a/server/lib/deltacloud/server.rb
+++ b/server/lib/deltacloud/server.rb
@@ -48,11 +48,11 @@ module Deltacloud
       if params[:force_auth]
         return [401, 'Authentication failed'] unless driver.valid_credentials?(credentials)
       end
-      @collections = driver.supported_collections(credentials)
+      collections = driver.supported_collections(credentials)
       respond_to do |format|
-        format.xml { haml :"api/show" }
-        format.json { collections_to_json(@collections) }
-        format.html { haml :"api/show" }
+        format.xml { haml :"api/show", :locals => { :collections => collections } }
+        format.json { collections_to_json(collections) }
+        format.html { haml :"api/show", :locals => { :collections => collections } }
       end
     end
 
diff --git a/server/views/addresses/index.xml.haml b/server/views/addresses/index.xml.haml
index 7806bda..a944e5e 100644
--- a/server/views/addresses/index.xml.haml
+++ b/server/views/addresses/index.xml.haml
@@ -1,4 +1,4 @@
 !!!XML
 %addresses
-  - @elements.each do |c|
+  - elements.each do |c|
     = haml :'addresses/show', :locals => { :address => c, :partial => true }
diff --git a/server/views/api/show.html.haml b/server/views/api/show.html.haml
index 15a3490..57f32b6 100644
--- a/server/views/api/show.html.haml
+++ b/server/views/api/show.html.haml
@@ -3,7 +3,7 @@
 
 %div{ :'data-role' => :content, :'data-theme' => 'c'}
   %ul{ :'data-role' => :listview, :'data-inset' => 'true'}
-    - @collections.each do |c|
+    - collections.each do |c|
       %li
         %a{ :href => url_for(c.collection_name),  :'data-icon' => "arrow-r"}=c.collection_name.to_s.gsub('_', ' ').titlecase
 
diff --git a/server/views/api/show.xml.haml b/server/views/api/show.xml.haml
index f21f69b..852a599 100644
--- a/server/views/api/show.xml.haml
+++ b/server/views/api/show.xml.haml
@@ -1,5 +1,5 @@
 %api{ :version => settings.version, :driver => driver_symbol, :provider => Thread.current[:provider] || ENV['API_PROVIDER'] }
-  - @collections.each do |c|
+  - collections.each do |c|
     %link{ :rel => c.collection_name, :href => self.send(:"#{c.collection_name}_url")}
       - c.features.select { |f| driver.class.has_feature?(c.collection_name, f.name) }.each do |f|
         - f.operations.each do |operation|
diff --git a/server/views/blobs/show.xml.haml b/server/views/blobs/show.xml.haml
index 4687720..d382c82 100644
--- a/server/views/blobs/show.xml.haml
+++ b/server/views/blobs/show.xml.haml
@@ -1,13 +1,13 @@
 !!! XML
-%blob{:href => bucket_url(@blob.bucket) + '/' + @blob.id, :id => @blob.id}
-  %bucket=@blob.bucket
-  - @blob.attributes.select{ |attr| (attr!=:id && attr!=:user_metadata) }.each do |attribute|
+%blob{:href => bucket_url(blob.bucket) + '/' + blob.id, :id => blob.id}
+  %bucket=blob.bucket
+  - blob.attributes.select{ |attr| (attr!=:id && attr!=:user_metadata) }.each do |attribute|
     - next if attribute == :bucket
     - unless attribute == :content
       - haml_tag(attribute, :<) do
-        - haml_concat @blob.send(attribute)
+        - haml_concat blob.send(attribute)
   %user_metadata
-    - if @blob.user_metadata.respond_to? :each
-      - @blob.user_metadata.each do |k, v|
+    - if blob.user_metadata.respond_to? :each
+      - blob.user_metadata.each do |k, v|
         %entry{:key => k}=render_cdata(v)
-  %content{:href => bucket_url(@blob.bucket) + '/' + @blob.id + '/content', :rel => 'blob_content'}
+  %content{:href => bucket_url(blob.bucket) + '/' + blob.id + '/content', :rel => 'blob_content'}
diff --git a/server/views/buckets/index.xml.haml b/server/views/buckets/index.xml.haml
index 9cc4dc5..f4b1ab7 100644
--- a/server/views/buckets/index.xml.haml
+++ b/server/views/buckets/index.xml.haml
@@ -1,4 +1,4 @@
 !!!XML
 %buckets
-  - @elements.each do |c|
+  - elements.each do |c|
     = haml :'buckets/show', :locals => { :bucket => c, :partial => true }
diff --git a/server/views/drivers/index.xml.haml b/server/views/drivers/index.xml.haml
index 63e809f..84673f3 100644
--- a/server/views/drivers/index.xml.haml
+++ b/server/views/drivers/index.xml.haml
@@ -1,5 +1,5 @@
 %drivers
-  - @drivers.each do |id, details|
+  - drivers.each do |id, details|
     %driver{ :href => driver_url(id), :id => id }
       %name<
         =details[:name]
diff --git a/server/views/drivers/show.html.haml b/server/views/drivers/show.html.haml
index 062a5bc..5a162c1 100644
--- a/server/views/drivers/show.html.haml
+++ b/server/views/drivers/show.html.haml
@@ -1,23 +1,23 @@
-=header @name
+=header name
 =subheader "Deltacloud API #{settings.version}"
 
 %div{ :'data-role' => :content, :'data-theme' => 'c'}
   %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'd'}
     %li{ :'data-role' => 'list-divider'} Identifier
     %li
-      %p{ :'data-role' => 'fieldcontain'}=@name
+      %p{ :'data-role' => 'fieldcontain'}=name
     %li{ :'data-role' => 'list-divider'} Name
     %li
-      %p{ :'data-role' => 'fieldcontain'}=@driver[:name]
+      %p{ :'data-role' => 'fieldcontain'}=driver[:name]
     %li{ :'data-role' => 'list-divider'} Provider
     %li
       %p{ :'data-role' => 'fieldcontain'}
-        - if @providers
-          - @providers.each do |p|
+        - if providers
+          - providers.each do |p|
             %h3= p.id
             %p= p.url
         - else
-          - providers = driver_provider(@driver).keys.collect { |k| k.to_s }.sort
+          - providers = driver_provider(driver).keys.collect { |k| k.to_s }.sort
           - if providers.empty?
             None
           - else
diff --git a/server/views/drivers/show.xml.haml b/server/views/drivers/show.xml.haml
index 3734c4d..4297118 100644
--- a/server/views/drivers/show.xml.haml
+++ b/server/views/drivers/show.xml.haml
@@ -1,12 +1,12 @@
-%driver{ :href => driver_url(@name), :id => @name }
+%driver{ :href => driver_url(name), :id => name }
   %name<
-    = @driver[:name]
-  - if @providers.nil?
-    - driver_provider(@driver).each do |prov, details|
+    = driver[:name]
+  - if providers.nil?
+    - driver_provider(driver).each do |prov, details|
       %provider{ :id => prov }
         - details.each do |kind, url|
           %entrypoint{ :kind => kind }<=cdata(url)
   - else
-    - @providers.each do |p|
+    - providers.each do |p|
       %provider{ :id => p.id }
         %entrypoint{ :kind => p.name }<=p.url
diff --git a/server/views/errors/backend_capability_failure.xml.haml b/server/views/errors/backend_capability_failure.xml.haml
index 4302e4b..48e3e6a 100644
--- a/server/views/errors/backend_capability_failure.xml.haml
+++ b/server/views/errors/backend_capability_failure.xml.haml
@@ -1,5 +1,5 @@
-%error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
-  %capability #{@error.capability}
-  %message< #{cdata @error.message}
+%err{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
+  %capability #{err.capability}
+  %message< #{cdata err.message}
 
 
diff --git a/server/views/errors/common.html.haml b/server/views/errors/common.html.haml
index 8cd3c74..b8e85d2 100644
--- a/server/views/errors/common.html.haml
+++ b/server/views/errors/common.html.haml
@@ -2,28 +2,28 @@
   %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
     %li{ :'data-role' => 'list-divider'} Server message
     %li
-      %h3= h [@error.class.name, @error.message].join(' - ')
+      %h3= h [err.class.name, err.message].join(' - ')
     %li{ :'data-role' => 'list-divider'} Original request URI
     %li
       %a{ :href => request.env['REQUEST_URI'], :'data-ajax' => 'false'}
         %span=request.env['REQUEST_URI']
         %span{ :class => 'ui-li-count'} Retry
-    %li{ :'data-role' => 'list-divider'} Error details
+    %li{ :'data-role' => 'list-divider'} err details
     %li
-      - if @error.class.method_defined? :details
-        %p= h @error.details
+      - if err.class.method_defined? :details
+        %p= h err.details
       - else
         %em No details
     %li{ :'data-role' => 'list-divider'} Backtrace
     %li
-      %pre= bt @error.backtrace
+      %pre= bt err.backtrace
 
-  - if @error.backtrace
+  - if err.backtrace
     %div{ 'data-role' => :collapsible, 'data-collapsed' => "true"}
       %h3 Backtrace
       %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
         %li
-          %pre= h @error.backtrace.join("\n")
+          %pre= h err.backtrace.join("\n")
 
   %div{ 'data-role' => :collapsible, 'data-collapsed' => "true"}
     %h3 Parameters
diff --git a/server/views/errors/common.xml.haml b/server/views/errors/common.xml.haml
index 88ce93f..64344e8 100644
--- a/server/views/errors/common.xml.haml
+++ b/server/views/errors/common.xml.haml
@@ -4,13 +4,13 @@
   %backend{ :driver => driver_symbol, :provider => current_provider }
   %code=response.status
   %message<
-    - if @error.respond_to? :message
-      =cdata @error.message
+    - if err.respond_to? :message
+      =cdata err.message
     - else
-      =translate_error_code(response.status)
-  - if @error.respond_to? :backtrace
+      =translate_err_code(response.status)
+  - if err.respond_to? :backtrace
     %backtrace
-      =cdata @error.backtrace.nil? ? '' : @error.backtrace.join("\n")
+      =cdata err.backtrace.nil? ? '' : err.backtrace.join("\n")
     %request
       - if params
         -params.each do |name, value|
diff --git a/server/views/firewalls/index.xml.haml b/server/views/firewalls/index.xml.haml
index 53a9b6e..44c77ae 100644
--- a/server/views/firewalls/index.xml.haml
+++ b/server/views/firewalls/index.xml.haml
@@ -1,6 +1,6 @@
 !!! XML
 %firewalls
-  - @firewalls.each do |firewall|
+  - firewalls.each do |firewall|
     %firewall{:href => firewall_url(firewall.id), :id => firewall.id}
       %actions
         %link{ :rel => :destroy, :href => destroy_firewall_url(firewall.id), :method => :delete, :id => firewall.id}
diff --git a/server/views/firewalls/show.xml.haml b/server/views/firewalls/show.xml.haml
index 39ed9d2..d7c2bb7 100644
--- a/server/views/firewalls/show.xml.haml
+++ b/server/views/firewalls/show.xml.haml
@@ -1,20 +1,20 @@
 !!! XML
-%firewall{:href => firewall_url(@firewall.id), :id => @firewall.id}
+%firewall{:href => firewall_url(firewall.id), :id => firewall.id}
   %actions
-    %link{ :rel => :destroy, :href => destroy_firewall_url(@firewall.id), :method => :delete}
-    %link{ :rel => :update, :href => "#{firewall_url(@firewall_name)}/rules", :method => :post}
-  - @firewall.attributes.select{ |attr| attr != :id && attr!= :rules}.each do |attribute|
+    %link{ :rel => :destroy, :href => destroy_firewall_url(firewall.id), :method => :delete}
+    %link{ :rel => :update, :href => "#{firewall_url(firewall_name)}/rules", :method => :post}
+  - firewall.attributes.select{ |attr| attr != :id && attr!= :rules}.each do |attribute|
     - haml_tag("#{attribute}".tr('-', '_'), :<) do
       - if [:name, :description].include?(attribute)
         =cdata do
-          - haml_concat @firewall.send(attribute)
+          - haml_concat firewall.send(attribute)
       - else
-        - haml_concat @firewall.send(attribute)
+        - haml_concat firewall.send(attribute)
   %rules
-    - @firewall.rules.each do |rule|
-      %rule{:href => firewall_url(@firewall.id) + '/' + rule.id, :id => rule.id}
+    - firewall.rules.each do |rule|
+      %rule{:href => firewall_url(firewall.id) + '/' + rule.id, :id => rule.id}
         %actions
-          %link{ :rel => :destroy, :href => "#{firewall_url(@firewall.name)}/#{rule.id}", :method => :delete}
+          %link{ :rel => :destroy, :href => "#{firewall_url(firewall.name)}/#{rule.id}", :method => :delete}
         - rule.attributes.select{|attr| attr != :sources && attr != :id}.each do |rule_attrib|
           - haml_tag("#{rule_attrib}".tr('-', '_'), :<) do
             - haml_concat rule.send(rule_attrib)
diff --git a/server/views/hardware_profiles/index.xml.haml b/server/views/hardware_profiles/index.xml.haml
index c977ffb..f12dce2 100644
--- a/server/views/hardware_profiles/index.xml.haml
+++ b/server/views/hardware_profiles/index.xml.haml
@@ -1,4 +1,4 @@
 !!! XML
 %hardware_profiles
-  - order_hardware_profiles(hardware_profiles).each do |prof|
+  - order_hardware_profiles(elements).each do |prof|
     = haml :'hardware_profiles/show', :locals => { :hardware_profile => prof, :partial => true }
diff --git a/server/views/images/index.xml.haml b/server/views/images/index.xml.haml
index 68c8ef8..bde6d05 100644
--- a/server/views/images/index.xml.haml
+++ b/server/views/images/index.xml.haml
@@ -1,5 +1,5 @@
 - unless defined?(partial)
   !!! XML
 %images
-  - @elements.each do |c|
+  - elements.each do |c|
     = haml :'images/show', :locals => { :image => c, :partial => true }
diff --git a/server/views/instance_states/show.png.erb b/server/views/instance_states/show.png.erb
index e3f97a7..5634361 100644
--- a/server/views/instance_states/show.png.erb
+++ b/server/views/instance_states/show.png.erb
@@ -1,6 +1,6 @@
 digraph instance_states {
   rankdir=LR;
-  <% for state in @machine.states do %>
+  <% for state in machine.states do %>
     <%= state %>
       [
         label="<%= state.to_s.titlecase %>",
@@ -23,7 +23,7 @@ digraph instance_states {
       ]
   <% end %>
 
-  <% for state in @machine.states do %>
+  <% for state in machine.states do %>
     <% for transition in state.transitions do %>
       <%= state %> -> <%= transition.destination %>
         [
diff --git a/server/views/instance_states/show.xml.haml b/server/views/instance_states/show.xml.haml
index beba422..96efbe3 100644
--- a/server/views/instance_states/show.xml.haml
+++ b/server/views/instance_states/show.xml.haml
@@ -1,5 +1,5 @@
 %states
-  - for state in @machine.states
+  - for state in machine.states
     %state{ :name=>state }
       - for transition in state.transitions
         - if ( transition.automatically? )
diff --git a/server/views/instances/index.html.haml b/server/views/instances/index.html.haml
index f7efee2..3678a8d 100644
--- a/server/views/instances/index.html.haml
+++ b/server/views/instances/index.html.haml
@@ -4,7 +4,7 @@
 %div{ :'data-role' => :content, :'data-theme' => 'c'}
   %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'a'}
     %li{ :'data-role' => 'list-divider'}=driver_symbol
-    - @elements.each do |instance|
+    - elements.each do |instance|
       %li
         %a{ :href => instance_url(instance.id), :'data-ajax' => 'false'}
           %img{ :class => 'ui-link-thumb', :src => '/images/machine.png'}
diff --git a/server/views/instances/index.xml.haml b/server/views/instances/index.xml.haml
index f0807ed..fa35eaf 100644
--- a/server/views/instances/index.xml.haml
+++ b/server/views/instances/index.xml.haml
@@ -1,4 +1,4 @@
 !!! XML
 %instances
-  - @elements.each do |c|
+  - elements.each do |c|
     = haml :'instances/show', :locals => { :instance => c, :partial => true }
diff --git a/server/views/instances/run.html.haml b/server/views/instances/run.html.haml
index 88c91ee..2951897 100644
--- a/server/views/instances/run.html.haml
+++ b/server/views/instances/run.html.haml
@@ -2,8 +2,8 @@
 
 %p
   %label Command:
-  %em #{@output.ssh.command}
+  %em #{output.ssh.command}
 %p
   %strong Command output
 %pre
-  =@output.body
+  =output.body
diff --git a/server/views/instances/run.xml.haml b/server/views/instances/run.xml.haml
index 4201e20..fa24fff 100644
--- a/server/views/instances/run.xml.haml
+++ b/server/views/instances/run.xml.haml
@@ -1,7 +1,7 @@
 %instance{:id => params[:id], :href=> instance_url(params[:id])}
   %public_address
-    =@output.ssh.network.ip
+    =output.ssh.network.ip
   %command
-    =@output.ssh.command
+    =output.ssh.command
   %output<
-    =@output.body
+    =output.body
diff --git a/server/views/instances/run_command.html.haml b/server/views/instances/run_command.html.haml
index a9d9bf9..d10f7ea 100644
--- a/server/views/instances/run_command.html.haml
+++ b/server/views/instances/run_command.html.haml
@@ -1,15 +1,15 @@
-=header "Run command on #{@instance.name}"
-=subheader "#{@instance.id}"
+=header "Run command on #{instance.name}"
+=subheader "#{instance.id}"
 
 %div{ :'data-role' => :content, :'data-theme' => 'c', :class => 'middle-dialog'}
-  %form{ :action => url_for('/instances/%s/run' % @instance.id), :method => :post }
+  %form{ :action => url_for('/instances/%s/run' % instance.id), :method => :post }
     %p
       %label{ :for => :cmd } Desired command:
       %input{ :name => :cmd, :value => "", :type => :text}
     %p
       %fieldset{ :'data-role' => :fieldcontain}
         %legend Target instance IP address:
-        - (@instance.public_addresses | @instance.private_addresses).each_with_index do |ip, idx|
+        - (instance.public_addresses | instance.private_addresses).each_with_index do |ip, idx|
           %label{ :for => ip.address }= "#{ip.address}"
           %input{ :name => :ip, :value => ip.address, :id => ip.address, :type => :radio, :'data-theme' => 'b', :checked => idx == 0 || nil}/
     %p
diff --git a/server/views/instances/show.html.haml b/server/views/instances/show.html.haml
index ae193aa..58e912e 100644
--- a/server/views/instances/show.html.haml
+++ b/server/views/instances/show.html.haml
@@ -1,67 +1,67 @@
 =header "Instance"
-=subheader @instance.id
+=subheader instance.id
 
 %div{ :'data-role' => :content, :'data-theme' => 'c'}
   %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'd'}
     %li{ :'data-role' => 'list-divider'} Name
     %li
-      %p{ :'data-role' => 'fieldcontain'}=@instance.name
+      %p{ :'data-role' => 'fieldcontain'}=instance.name
     %li{ :'data-role' => 'list-divider'} Owner
     %li
-      %p{ :'data-role' => 'fieldcontain'}=@instance.owner_id
+      %p{ :'data-role' => 'fieldcontain'}=instance.owner_id
     %li{ :'data-role' => 'list-divider'} State
     %li
-      %p{ :'data-role' => 'fieldcontain'}=@instance.state
+      %p{ :'data-role' => 'fieldcontain'}=instance.state
     %li{ :'data-role' => 'list-divider'} Launch Time
     %li
-      %p{ :'data-role' => 'fieldcontain'}=@instance.launch_time
+      %p{ :'data-role' => 'fieldcontain'}=instance.launch_time
     %li{ :'data-role' => 'list-divider'} Image
     %li
-      %a{ :href => image_url(@instance.image_id), :'data-ajax' => 'false' }=@instance.image_id
+      %a{ :href => image_url(instance.image_id), :'data-ajax' => 'false' }=instance.image_id
     %li{ :'data-role' => 'list-divider'} Hardware Profile
     %li
-      - prof = @instance.instance_profile
+      - prof = instance.instance_profile
       %a{ :href => hardware_profile_url(prof.name), :'data-ajax' => 'false'}
         =[prof.name, format_instance_profile(prof)].compact.join(', ')
     %li{ :'data-role' => 'list-divider'} Realm
     %li
-      - if @instance.realm_id
-        %a{ :href => realm_url(@instance.realm_id), :'data-ajax' => 'false' }=@instance.realm_id
+      - if instance.realm_id
+        %a{ :href => realm_url(instance.realm_id), :'data-ajax' => 'false' }=instance.realm_id
       - else
         default
     %li{ :'data-role' => 'list-divider'} Public addresses
     %li
-      %p{ :'data-role' => 'fieldcontain'}=@instance.public_addresses.join(',')
+      %p{ :'data-role' => 'fieldcontain'}=instance.public_addresses.join(',')
     %li{ :'data-role' => 'list-divider'} Private addresses
     %li
-      %p{ :'data-role' => 'fieldcontain'}=@instance.private_addresses.join(',')
-    - if @instance.password or @instance.keyname
+      %p{ :'data-role' => 'fieldcontain'}=instance.private_addresses.join(',')
+    - if instance.password or instance.keyname
       %li{ :'data-role' => 'list-divider'} Authentication
-    - if @instance.password
+    - if instance.password
       %li{ :'data-role' => 'list-divider'} Username
-      %li=@instance.username
+      %li=instance.username
       %li{ :'data-role' => 'list-divider'} Password
-      %li=@instance.password
-    - if @instance.keyname
+      %li=instance.password
+    - if instance.keyname
       %li{ :'data-role' => 'list-divider'} SSH key name
       %li
-        %a{ :href => key_url(@instance.keyname), :'data-ajax' => 'false'}=@instance.keyname
-    - if @instance.firewalls
+        %a{ :href => key_url(instance.keyname), :'data-ajax' => 'false'}=instance.keyname
+    - if instance.firewalls
       %li{ :'data-role' => 'list-divider'} Firewalls
-      - @instance.firewalls.each do |firewall|
+      - instance.firewalls.each do |firewall|
         %li
           %a{ :href => firewall_url(firewall), :'data-ajax' => 'false'}=firewall
-    - if @instance.storage_volumes
+    - if instance.storage_volumes
       %li{ :'data-role' => 'list-divider'} Attached Storage Volumes
-      -@instance.storage_volumes.each do |vol|
+      -instance.storage_volumes.each do |vol|
         %li
           %a{ :href => storage_volume_url("#{vol.keys.first}"), :'data-ajax' => 'false'}=["#{vol.keys.first}", "#{vol.values.first}"].compact.reject{ |e| e.empty? }.join(' <---> ')
     %li{ :'data-role' => 'list-divider'} Actions
     %li
       %div{ :'data-role' => 'controlgroup', :'data-type' => "horizontal" }
-        - @instance.actions.each do |action|
-          =link_to_action action.to_s.capitalize, self.send(:"#{action}_instance_url", @instance.id), instance_action_method(action)
-        - if @instance.state=="RUNNING" and driver.respond_to?(:run_on_instance)
-          =link_to_action 'Run command...', url_for('instances/%s/run' % @instance.id), :get
-        - if @instance.can_create_image?
-          =link_to_action 'Create image...', url_for("images/new?instance_id=#{@instance.id}"), :get
+        - instance.actions.each do |action|
+          =link_to_action action.to_s.capitalize, self.send(:"#{action}_instance_url", instance.id), instance_action_method(action)
+        - if instance.state=="RUNNING" and driver.respond_to?(:run_on_instance)
+          =link_to_action 'Run command...', url_for('instances/%s/run' % instance.id), :get
+        - if instance.can_create_image?
+          =link_to_action 'Create image...', url_for("images/new?instance_id=#{instance.id}"), :get
diff --git a/server/views/keys/index.xml.haml b/server/views/keys/index.xml.haml
index 76ae781..e379e49 100644
--- a/server/views/keys/index.xml.haml
+++ b/server/views/keys/index.xml.haml
@@ -1,4 +1,4 @@
 !!!XML
 %keys
-  - @elements.each do |c|
+  - elements.each do |c|
     = haml :'keys/show', :locals => { :key => c, :partial => true }
diff --git a/server/views/load_balancers/index.xml.haml b/server/views/load_balancers/index.xml.haml
index 2459fcb..994c9cb 100644
--- a/server/views/load_balancers/index.xml.haml
+++ b/server/views/load_balancers/index.xml.haml
@@ -1,4 +1,4 @@
 !!!XML
 %load_balancers
-  - @elements.each do |c|
+  - elements.each do |c|
     = haml :'load_balancers/show', :locals => { :load_balancer => c, :partial => true }
diff --git a/server/views/metrics/index.xml.haml b/server/views/metrics/index.xml.haml
index b67f2a8..36c8ccd 100644
--- a/server/views/metrics/index.xml.haml
+++ b/server/views/metrics/index.xml.haml
@@ -1,5 +1,5 @@
 - unless defined?(partial)
   !!!XML
 %metrics
-  - @elements.each do |c|
+  - elements.each do |c|
     = haml :'metrics/show', :locals => { :metric => c, :partial => true}
diff --git a/server/views/realms/index.xml.haml b/server/views/realms/index.xml.haml
index 2c6cef3..59f55ff 100644
--- a/server/views/realms/index.xml.haml
+++ b/server/views/realms/index.xml.haml
@@ -1,4 +1,4 @@
 !!!XML
 %realms
-  - @elements.each do |c|
+  - elements.each do |c|
     = haml :'realms/show', :locals => { :realm => c, :partial => true }
diff --git a/server/views/storage_snapshots/index.xml.haml b/server/views/storage_snapshots/index.xml.haml
index 3d29a2b..4a8b14f 100644
--- a/server/views/storage_snapshots/index.xml.haml
+++ b/server/views/storage_snapshots/index.xml.haml
@@ -1,4 +1,4 @@
 !!!XML
 %storage_snapshots
-  - @elements.each do |c|
+  - elements.each do |c|
     = haml :'storage_snapshots/show', :locals => { :storage_snapshot => c, :partial => true }
diff --git a/server/views/storage_volumes/index.xml.haml b/server/views/storage_volumes/index.xml.haml
index 6492165..31517a3 100644
--- a/server/views/storage_volumes/index.xml.haml
+++ b/server/views/storage_volumes/index.xml.haml
@@ -1,4 +1,4 @@
 !!!XML
 %storage_volumes
-  - @elements.each do |volume|
+  - elements.each do |volume|
     = haml :'storage_volumes/show', :locals =>  { :storage_volume =>  volume, :partial =>  true }
-- 
1.8.1.4